/*
* GoJS v3.0.7 JavaScript Library for HTML Diagrams, https://gojs.net
* GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://www.nwoods.com.
* Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved.
* THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.7/license.html.
* DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE.
*/
(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Mk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Ig(s),s=Util.vh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static vh(t,i){return root.setTimeout(t,i)}static Ig(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static D(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static HI(t,i,e,s){}static i(t,i,e,s){}static qI(t,i,e){}static WI(t,i,e){}static be(t,i,e,s){}static tt(t,i,e,s){let n=Util.SD(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static Ie(t){}static lr(t,i){}static ri(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static JI(t,i,e){}static eu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static Qa(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Sk=[];static rt(){const t=Util.Sk.pop();return t===void 0?[]:t}static it(t){t.length=0,Util.Sk.push(t)}static $I=Object.freeze([]);static SD(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Oh(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static cw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.ZI;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static ND(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.ct;this.Dt=-1;const s=i.r,n=s.length,o=this.Ts;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.ml(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.ct;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.ct,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.ct!==e&&Util.Ie(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.ct,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.ct!==e&&Util.Ie(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.ct,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.ct!==e&&Util.Ie(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.ct,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.ct!==e&&Util.Ie(i)}const r=new List;return r.r=s,r.Ee(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.ct,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.ct!==e&&Util.Ie(i)}const r=new List;return r.r=s,r.Ee(),r.iterator}get count(){return this.qt.r.length}ml(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;ct;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.ct=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Ee(){let t=this.ct;t++,t>999999999&&(t=0),this.ct=t}g(){return this.h=!0,this}lt(){return this.h=!1,this}toString(){return"List()#"+GSet.cs(this)}add(t){return this.h&&Util.D(this,t),this.r.push(t),this.Ee(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.D(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.tt(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util.tt(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.D(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.D(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.ct,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.D(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Ee()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.D(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Ee(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util.tt(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.D(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Ee()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.D(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.tt(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Ee()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.bo.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.bo.count}ml(){this.key=null,this.value=null,this.ii=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}lt(){return this.h=!1,this}toString(){return"Set()#"+GSet.cs(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static su=1;static Yi(t){t.__gohashid=GSet.su++}static cs(t){return t.__gohashid}}class MapKeySetIterator{Z;ii;constructor(t){this.Z=t,this.ii=t.w.keys()}[Symbol.iterator](){return this.Z.w.keys()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ii=t.w.keys()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ii=this.Z.w.keys(),this.ii.next().value)}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}ml(){this.key=null,this.value=null,this.ii=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{Z;constructor(t){super(),GSet.Yi(this),this.h=!0,this.Z=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}lt(){return this}toString(){return"MapKeySet("+this.Z.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.Z.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.Z.w.size===0?null:this.Z.w.keys().next().value}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.Z.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.Z.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.Z)}toSet(){const t=new GSet,i=this.Z.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.Z.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.Z.w;for(const e of i)t.add(e[0]);return t}get count(){return this.Z.size}get size(){return this.Z.size}get iterator(){return this.Z.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.Z)}}class MapValueSetIterator{Z;ii;constructor(t){this.Z=t,this.ii=t.w.values()}[Symbol.iterator](){return this.Z.w.values()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ii=t.w.values()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ii=this.Z.w.values(),this.ii.next().value)}any(t){for(const i of this.Z.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[1]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}ml(){this.key=null,this.value=null,this.ii=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{Z;ii;constructor(t){this.Z=t,this.ii=t.w.entries()}[Symbol.iterator](){return this.Z.w.entries()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ii=t.w.entries()}next(){const t=this.ii.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.Z.w.size===0)return null;this.ii=this.Z.w.entries();const t=this.ii.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.Z.any(t)}all(t){return this.Z.all(t)}each(t){return this.Z.each(t),this}map(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.Z.size}ml(){this.key=null,this.value=null,this.ii=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}lt(){return this.h=!1,this}toString(){return"Map()#"+GSet.cs(this)}set(t,i){return this.h&&Util.D(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.D(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.JN(t.x-this.b,t.y-this.k)}direction(t,i){return this.JN(t-this.b,i-this.k)}JN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.nu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.nu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ou(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.pl(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.pl(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Eg(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Eg(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}L(t){return t.xt(this),this}Ue(t){return t.ts(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static ko=new Point(0,0).et();static $N=new Point(-1/0,-1/0).et();static ZN=new Point(1/0,1/0).et();static QN=new Point(6,6).et();static Ck=new Point(NaN,NaN).et();static Lk=[];static l(){const t=Point.Lk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Lk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Lk.push(t)}}class Size{H;q;h;constructor(t,i){t===void 0?(this.H=0,this.q=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.H=t,this.q=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.H=t.H,this.q=t.q,this}e(t,i){return this.H=t,this.q=i,this}setTo(t,i){return this.H=t,this.q=i,this}set(t){return this.H=t.H,this.q=t.q,this}copy(){const t=new Size;return t.H=this.H,t.q=this.q,t}et(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}lt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}uw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.H===t.width&&this.q===t.height:!1}equalTo(t,i){return this.H===t&&this.q===i}equalsApprox(t){return Geo.u(this.H,t.width)&&Geo.u(this.q,t.height)}inflate(t,i){const e=this.width+t;this.H=e>=0?e:0;const s=this.height+i;return this.q=s>=0?s:0,this}get width(){return this.H}set width(t){t<0&&Util.tt(t,">= 0",Size,"width"),this.H=t}get height(){return this.q}set height(t){t<0&&Util.tt(t,">= 0",Size,"height"),this.q=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static ru=new Size(0,0).et();static Ak=new Size(1,1).et();static _N=new Size(6,6).et();static lu=new Size(8,8).et();static tC=new Size(10,10).et();static iC=new Size(1/0,1/0).et();static dw=new Size(NaN,NaN).et();static eC=[];static l(){const t=Size.eC.pop();return t===void 0?new Size:t}static s(t){Size.eC.push(t)}}class Rect{b;k;H;q;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.H=0,this.q=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.H=e,this.q=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.H=Math.abs(n-r),this.q=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.H=i.width,this.q=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.H=t.H,this.q=t.q,this}e(t,i,e,s){return this.b=t,this.k=i,this.H=e,this.q=s,this}Po(t,i){return this.H=t,this.q=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.H=e,this.q=s,this}set(t){return this.b=t.b,this.k=t.k,this.H=t.H,this.q=t.q,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.H=t.width,this.q=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.H=this.H,t.q=this.q,t}et(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}lt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}uw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.H===t.width&&this.q===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.H===e&&this.q===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.H,t.width)&&Geo.u(this.q,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.H,e)&&Geo.u(this.q,s)}equalsApproxClose(t){return Geo.Y(this.b,t.x)&&Geo.Y(this.k,t.y)&&Geo.Y(this.H,t.width)&&Geo.Y(this.q,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.H>=t.x&&this.k<=t.y&&this.k+this.q>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.H&&this.k<=t.y&&t.y+t.height<=this.k+this.q}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.H&&this.k<=i&&i+s<=this.k+this.q}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.gw(i,t,i,t)}addMargin(t){return this.gw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.gw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.gw(t,i,e,s)}gw(t,i,e,s){const n=this.H;i+s<=-n?(this.b+=n/2,this.H=0):(this.b-=s,this.H+=i+s);const o=this.q;return t+e<=-o?(this.k+=o/2,this.q=0):(this.k-=t,this.q+=t+e),this}intersectRect(t){return this.sC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.sC(t,i,e,s)}sC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.H,t+e),l=Math.min(this.k+this.q,i+s);return this.b=n,this.k=o,this.H=Math.max(0,r-n),this.q=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.H;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.q;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.H,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.q,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.H,t.q)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.H,t+e),l=Math.max(this.k+this.q,i+s);return this.b=n,this.k=o,this.H=r-n,this.q=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.H,this.k=i-e.offsetY-e.y*this.q,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.nC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.H}set width(t){t<0&&Util.tt(t,">= 0",Rect,"width"),this.H=t}get height(){return this.q}set height(t){t<0&&Util.tt(t,">= 0",Rect,"height"),this.q=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.H}set right(t){this.b+=t-(this.b+this.H)}get bottom(){return this.k+this.q}set bottom(t){this.k+=t-(this.k+this.q)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.H,this.q)}set size(t){this.H=t.width,this.q=t.height}get center(){return new Point(this.b+this.H/2,this.k+this.q/2)}set center(t){this.b=t.x-this.H/2,this.k=t.y-this.q/2}get centerX(){return this.b+this.H/2}set centerX(t){this.b=t-this.H/2}get centerY(){return this.k+this.q/2}set centerY(t){this.k=t-this.q/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static Tk=new Rect(0,0,0,0).et();static LD=new Rect(NaN,NaN,NaN,NaN).et();static Dk=[];static l(){const t=Rect.Dk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Dk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Dk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}et(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}lt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}uw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Ug=new Margin(0,0,0,0).et();static oC=new Margin(2,2,2,2).et();static rC=[];static l(){const t=Margin.rC.pop();return t===void 0?new Margin:t}static s(t){Margin.rC.push(t)}}class Spot{b;k;Ds;Fs;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.Ds=0,this.Fs=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.Ds=t.Ds,this.Fs=t.Fs,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.Ds=e,this.Fs=s,this}set(t){return this.b=t.b,this.k=t.k,this.Ds=t.Ds,this.Fs=t.Fs,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.Ds=this.Ds,t.Fs=this.Fs,t}et(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}lt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}uw(t){}Be(t){return this.b=NaN,this.k=NaN,this.Ds=t,this}QI(t,i){(isNaN(t)||t>1||t<0)&&Util.tt(t,"0 <= "+i+" <= 1",Spot,i)}_I(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.tt(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Ds===0&&this.Fs===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.Ds===t.offsetX&&this.Fs===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.Ds,-this.Fs)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Fs,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.Ds}set offsetX(t){this.Ds=t}get offsetY(){return this.Fs}set offsetY(t){this.Fs=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Be(0).et();static Default=new Spot(0,0,-1,0).Be(-1).et();static TopLeft=new Spot(0,0,0,0).et();static TopCenter=new Spot(.5,0,0,0).et();static TopRight=new Spot(1,0,0,0).et();static LeftCenter=new Spot(0,.5,0,0).et();static Center=new Spot(.5,.5,0,0).et();static RightCenter=new Spot(1,.5,0,0).et();static BottomLeft=new Spot(0,1,0,0).et();static BottomCenter=new Spot(.5,1,0,0).et();static BottomRight=new Spot(1,1,0,0).et();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Be(1).et();static LeftSide=new Spot(0,0,1,2).Be(1).et();static RightSide=new Spot(0,0,1,4).Be(1).et();static BottomSide=new Spot(0,0,1,8).Be(1).et();static TopBottomSides=new Spot(0,0,1,9).Be(1).et();static LeftRightSides=new Spot(0,0,1,6).Be(1).et();static TopLeftSides=new Spot(0,0,1,3).Be(1).et();static TopRightSides=new Spot(0,0,1,5).Be(1).et();static BottomLeftSides=new Spot(0,0,1,10).Be(1).et();static BottomRightSides=new Spot(0,0,1,12).Be(1).et();static NotTopSide=new Spot(0,0,1,14).Be(1).et();static NotLeftSide=new Spot(0,0,1,13).Be(1).et();static NotRightSide=new Spot(0,0,1,11).Be(1).et();static NotBottomSide=new Spot(0,0,1,7).Be(1).et();static AllSides=new Spot(0,0,1,15).Be(1).et();static Fk=new Spot(.156,.156).et();static Rk=new Spot(.844,.844).et();static lC=[];static l(){const t=Spot.lC.pop();return t===void 0?new Spot:t}static s(t){Spot.lC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}vk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Jt(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}_a(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}hC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}mw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}fs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Zi(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Zi(-i,-e),this}Zi(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}K(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}AD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ts(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x,a=t.y;return t.e(h*e+a*n+r,h*s+a*o+l)}pw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}yw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let b=f,k=f,P=u,M=u;return b=Math.min(b,d),k=Math.max(k,d),P=Math.min(P,m),M=Math.max(M,m),b=Math.min(b,g),k=Math.max(k,g),P=Math.min(P,p),M=Math.max(M,p),b=Math.min(b,y),k=Math.max(k,y),P=Math.min(P,x),M=Math.max(M,x),t.e(b,P,k-b,M-P),t}static aC=[];static l(){const t=Transform.aC.pop();return t===void 0?new Transform:t}static s(t){Transform.aC.push(t)}static Ok="54a702f3e53909c447824c6706603faf4c"}const Geo={TD:"7da71ca0ad381e90",En:4*((Math.sqrt(2)-1)/3),cC:null,ww:w=>{if(w<=0)return 0;let t=Geo.cC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.cC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},Y:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},xw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,b=(d+g)/2,k=(m+p)/2,P=(y+b)/2,M=(x+k)/2;return Geo.xw(w,t,f,u,y,x,P,M,l,h,a,c)||Geo.xw(P,M,b,k,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},fC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},DD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},hu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,b=(g+y)/2,k=(p+x)/2;Geo.hu(w,t,a,c,g,p,b,k,l,h),Geo.hu(b,k,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Un:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,b=(g+y)/2,k=(p+x)/2;Geo.Un(w,t,a,c,g,p,b,k,l,h),Geo.Un(b,k,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ik:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ik(w,t,a,c,d,m,o,r,l,h)||Geo.Ik(d,m,f,u,s,n,o,r,l,h)}},tE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Ek:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Ek(w,t,l,h,f,u,o,r),Geo.Ek(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Vg:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,b=(d+g)/2,k=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(b+P)/2,C=(k+M)/2;let S=1/0,N=!1,T=0,A=0;if(Geo.Vg(w,t,d,m,b,k,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,b=(d+g)/2,k=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(b+P)/2,C=(k+M)/2;u+=Geo.zg(w,t,d,m,b,k,L,C,l,h,a,c,f),u+=Geo.zg(L,C,P,M,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},pl:(w,t,i,e,s,n,o)=>{if(Geo.Y(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.Y(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Bn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.Y(s,o)){if(Geo.Y(w,i))return Geo.pl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.pl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.Y(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.Y(h,a))return Geo.pl(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.Y(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.pl(w,t,i,e,c,f,l)}}}}},iE:(w,t,i,e,s)=>Geo.Bn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),eE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,M){const L=(P-w)*(P-w)+(M-t)*(M-t);Lw?i-w:w-i)<.5){const P=1-(i-b)*(i-b)/(y*y);if(P<0)return l;const M=Math.sqrt(P),L=x*M+k,C=-x*M+k;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),M=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*k/(x*x)-2*b/(y*y),C=2*P*w*k/(x*x)-2*t*k/(x*x)+k*k/(x*x)+b*b/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),S=L*L-4*M*C;if(S<0)return l;const N=Math.sqrt(S),T=(-L+N)/(2*M);c(T,P*T-P*w+t);const A=(-L-N)/(2*M);c(A,P*A-P*w+t)}return l},yl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Bn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.nC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),nC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ou(l,a,h,a,s,n,o,r)||Geo.ou(h,a,h,c,s,n,o,r)||Geo.ou(h,c,l,c,s,n,o,r)||Geo.ou(l,c,l,a,s,n,o,r))},ou:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.nu(w,t,i,e,s,n)*Geo.nu(w,t,i,e,o,r)<=0&&Geo.nu(s,n,o,r,w,t)*Geo.nu(s,n,o,r,i,e)<=0,nu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Xg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),uC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.FD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},FD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Eg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},RD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(b<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Gg;jg;tc;au;cu;Vn;zn;Xn;_;ke;Pe;Qi;_i;Rs;ic;ec;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this._=t,this.ke=0,this.Pe=0,this.Qi=0,this._i=0,t===4?this.Rs=new List:this.Rs=Geometry.kw,this.Gg=this.Rs.ct,this.jg=new Rect().g(),this.tc=null,this.au=null,this.cu=NaN,this.Vn=Spot.TopLeft,this.zn=Spot.BottomRight,this.ic=NaN,this.ec=NaN,this.Xn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t._=this._,t.ke=this.ke,t.Pe=this.Pe,t.Qi=this.Qi,t._i=this._i,this._===4){const i=this.Rs.r,e=t.Rs;for(let s=0;si.toString(t)}li(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.be(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=b-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const b=o.length,k=GeoStream.mC(null);let P=!1,M=!1,L=!1,C=!0,S=null;const N=new RegExp("["+Geometry.Hg+"]");for(;!(r>=b-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,M=!1;break;case"M":for(S=p(),k.Mi===null||C===!0?(k.fu(S.x,S.y,P,!1,!M,L),C=!1):k.OD(S.x,S.y),a.a(f);!d();)S=p(),k.ur(S.x,S.y);break;case"L":for(;!d();)S=p(),k.ur(S.x,S.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),k.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),k.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();k.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();k.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();k.Pw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();k.Pw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let U=O,X=!1;d()||(U=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),k.ID(D,F,R,v,O,U,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,U=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),U=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(U=f.x+U,X=f.y+X),f.e(U,X),k.ED(D,F,R,v,O,U,X)}u&&(A=!0);break;case"Z":k.UD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:k.BD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:k.VD(!1);break}default:if(l==="0"||l==="1")break;Util.ri("Unknown geometry command: "+l);break}if(A){Util.ri(`Bad geometry command: ${l}, next token: ${m()},
string: ${t}`);break}}const T=k.qg;if(GeoStream.pC(k),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static yC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}xC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],b=g[f*2+3];return i.e(p+(x-p)*m,y+(b-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],b=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(b-y)*m;let k;return Math.abs(x-p)<1&&Math.abs(b-y)<1?k=0:Math.abs(x-p)<1?k=b-y>=0?90:270:Math.abs(b-y)<1?k=x-p>=0?0:180:k=Math.atan2(b-y,x-p)*180/Math.PI,i[2]=k,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.pl(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.bC(),this.tc}bC(){if(this.tc===null){const t=this.tc=[],i=this.au=[];this.KD(t,i)}}get flattenedLengths(){return this.bC(),this.au}get flattenedTotalLength(){let t=this.cu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Un(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.So(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.zk(e)))}}}get type(){return this._}set type(t){this._!==t&&(this.h&&Util.D(this,t),this._=t,t===4?this.Rs=new List:(Geometry.kw===null&&(Geometry.kw=new List().g()),this.Rs=Geometry.kw),this.bt=!0)}get startX(){return this.ke}set startX(t){this.ke!==t&&(this.h&&Util.D(this,t),this.ke=t,this.bt=!0)}get startY(){return this.Pe}set startY(t){this.Pe!==t&&(this.h&&Util.D(this,t),this.Pe=t,this.bt=!0)}get endX(){return this.Qi}set endX(t){this.Qi!==t&&(this.h&&Util.D(this,t),this.Qi=t,this.bt=!0)}get endY(){return this._i}set endY(t){this._i!==t&&(this.h&&Util.D(this,t),this._i=t,this.bt=!0)}get figures(){return this.Rs}set figures(t){this.Rs!==t&&(this.h&&Util.D(this,t),this.Rs=t,this.bt=!0)}add(t){return this.Rs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.D(this),this.Vn=new Spot(t,i,n,o).g(),this.zn=new Spot(e,s,r,l).g(),this}get spot1(){return this.Vn}set spot1(t){this.h&&Util.D(this,t),this.Vn=t.N()}get spot2(){return this.zn}set spot2(t){this.h&&Util.D(this,t),this.zn=t.N()}get defaultStretch(){return this.Xn}set defaultStretch(t){this.Xn=t}get bounds(){return this.Uk()&&this.Mw(),this.jg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;ke;Pe;sc;Wg;Ve;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.ke=t:this.ke=0,i!==void 0?this.Pe=i:this.Pe=0,this.sc=new List,this.Wg=this.sc.ct,this.Ve=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.ke=this.ke,t.Pe=this.Pe;const i=this.sc.r,e=i.length,s=t.sc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{_;n;Qi;_i;hn;wl;xl;gr;vs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this._=t,this.n=2,i!==void 0?this.Qi=i:this.Qi=0,e!==void 0?this._i=e:this._i=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.wl=0,this.xl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.wl=n,t===5&&(o=Math.max(o,0)),this.xl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.vs=null}copy(){const t=new PathSegment;return t._=this._,t.n=this.n&-2,t.Qi=this.Qi,t._i=this._i,t.hn=this.hn,t.wl=this.wl,t.xl=this.xl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}li(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}lt(){return this.h=!1,this}close(){return this.isClosed=!0,this}So(t){if(this.vs!==null&&t.bt===!1)return this.vs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.vs=[],this.vs;const s=this.hn,n=this.wl,o=Geo.uC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,b=y*-r*m/o;isNaN(x)&&(x=0),isNaN(b)&&(b=0);const k=(s+c)/2+u*x-d*b,P=(n+f)/2+d*x+u*b,M=(V,B)=>Math.sqrt(V*V+B*B),L=(V,B,Y,G)=>(V*Y+B*G)/(M(V,B)*M(Y,G)),C=(V,B,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,U=o>r?r/o:1,X=Geo.uC(0,0,v,S,S+F,!0),E=Transform.l();return E.Jt(),E.Zi(k,P),E.fs(this.hn,0,0),E.K(O,U),Geometry.yC(X,E),Transform.s(E),this.vs=X,this.vs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this._}set type(t){this.h&&Util.D(this,t),this._=t,this.bt=!0}get endX(){return this.Qi}set endX(t){this.h&&Util.D(this,t),this.Qi=t,this.bt=!0}get endY(){return this._i}set endY(t){this.h&&Util.D(this,t),this._i=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.D(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.wl}set point1Y(t){this.h&&Util.D(this,t),this.wl=t,this.bt=!0}get point2X(){return this.xl}set point2X(t){this.h&&Util.D(this,t),this.xl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.D(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.D(this,t),this.hn=t,this.bt=!0}get centerY(){return this.wl}set centerY(t){this.h&&Util.D(this,t),this.wl=t,this.bt=!0}get radiusX(){return this.xl}set radiusX(t){t<0&&Util.tt(t,">= zero",PathSegment,"radiusX"),this.h&&Util.D(this,t),this.xl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util.tt(t,">= zero",PathSegment,"radiusY"),this.h&&Util.D(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Qi}set startAngle(t){this.h&&Util.D(this,t),t=t%360,t<0&&(t+=360),this.Qi=t,this.bt=!0}get sweepAngle(){return this._i}set sweepAngle(t){this.h&&Util.D(this,t),t>360&&(t=360),t<-360&&(t=-360),this._i=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.D(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.D(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.D(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Nw;Cw;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;om;No;rm;lm;hm;Me;constructor(){this.p=null,this.Nw=new Point(0,0).g(),this.Cw=new Point(0,0).g(),this.Jg=0,this.$g=0,this.Zg=1,this.Qg="",this._g="",this.tm=!1,this.im=!1,this.em=0,this.sm=0,this.nm=!1,this.om=!1,this.No=!1,this.rm=null,this.lm=0,this.hm=null,this.Me=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Nw.a(this.viewPoint),t.Cw.a(this.documentPoint),t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.No=this.No,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.Me=this.Me,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Nw}set viewPoint(t){this.Nw.a(t)}get documentPoint(){return this.Cw}set documentPoint(t){this.Cw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.kC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.kC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Jg}set modifiers(t){this.Jg=t}get button(){return this.$g}set button(t){if(this.$g=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.Zg}set buttons(t){this.Zg=t}get key(){return this.Qg}set key(t){this.Qg=t}get code(){return this._g}set code(t){this._g=t}get down(){return this.tm}set down(t){this.tm=t}get up(){return this.im}set up(t){this.im=t}get clickCount(){return this.em}set clickCount(t){this.em=t}get delta(){return this.sm}set delta(t){this.sm=t}get isMultiTouch(){return this.nm}set isMultiTouch(t){this.nm=t}get handled(){return this.om}set handled(t){this.om=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.rm}set event(t){this.rm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.lm}set timestamp(t){this.lm=t}get targetDiagram(){return this.hm}set targetDiagram(t){this.hm=t}get targetObject(){return this.Me}set targetObject(t){this.Me=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;St;am;cm;constructor(){this.p=null,this.St="",this.am=null,this.cm=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.St=this.St,t.am=this.am,t.cm=this.cm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.St}set name(t){this.St=t}get subject(){return this.am}set subject(t){this.am=t}get parameter(){return this.cm}set parameter(t){this.cm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{uu;fm;an;Si;p;du;nc;oc;rc;lc;constructor(){this.uu=2,this.fm="",this.an="",this.Si=null,this.p=null,this.du=null,this.nc=null,this.oc=null,this.rc=null,this.lc=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Si=null,this.p=null,this.du=null,this.nc=null,this.oc=null,this.rc=null,this.lc=null}copy(){const t=new ChangedEvent;t.uu=this.uu,t.fm=this.fm,t.an=this.an,t.Si=this.Si,t.p=this.p,t.du=this.du;let i=this.nc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.nc=i.copyFrozen():t.nc=i,i=this.oc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.oc=i.copyFrozen():t.oc=i,i=this.rc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,t}li(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.PC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.PC(this,!1))}get model(){return this.Si}set model(t){this.Si=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.uu}set change(t){this.uu=t}get modelChange(){return this.fm}set modelChange(t){this.fm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.uu===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.du}set object(t){this.du=t}get oldValue(){return this.nc}set oldValue(t){this.nc=t}get oldParam(){return this.oc}set oldParam(t){this.oc=t}get newValue(){return this.rc}set newValue(t){this.rc=t}get newParam(){return this.lc}set newParam(t){this.lc=t}}class Transaction{MC;St;Xk;constructor(){this.MC=new List().g(),this.St="",this.Xk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.lt(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.lt();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.MC}get name(){return this.St}set name(t){this.St=t}get isComplete(){return this.Xk}set isComplete(t){this.Xk=t}}class UndoManager{Lw;Oi;SC;Os;Kk;um;Kn;Yk;Gk;cn;hc;Aw;Is;Tw;Dw;dm;Fw;constructor(t){this.Lw=new GSet,this.Oi=!1,this.SC=new List().g(),this.Os=-1,this.Kk=999,this.Is=!1,this.um=null,this.Kn=0,this.Yk=!1,this.Gk=23,this.cn=new List().g(),this.hc=new List,this.Aw=!0,this.Tw=!1,this.Dw=!1,this.dm=!1,this.Fw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.Os=-1,t.g(),this.Is=!1,this.um=null,this.Kn=0,this.cn.lt(),this.cn.clear(),this.cn.g(),this.hc.clear(),this.Tw=!1,this.Dw=!1,this.dm=!1,this.Fw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.gm=t.gm}addModel(t){this.Lw.add(t)}removeModel(t){this.Lw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Aw===!0&&(this.Aw=!1,this.Kn++,this.bl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Kn>0&&this.Kn--),this.isEnabled&&(this.cn.lt(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.hc.add(0):this.hc.add(this.currentTransaction.changes.count)),this.Kn++;const i=this.transactionLevel===1;return i&&(this.bl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.NC(!0,t)}rollbackTransaction(){return this.NC(!1,"")}NC(t,i){if(this.isUndoingRedoing)return!1;this.gm&&this.transactionLevel<1&&Util.ri("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.bl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Kn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.lt(),this.cn.removeAt(o-1),this.cn.g());const r=this.hc.count;r>0&&(n=this.hc.elt(r-1),this.hc.removeAt(r-1))}if(e){if(t){if(this.dm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.lt();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.Os--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.Os++),r.g(),s=o}this.bl||this.t("CommittedTransaction",i,s)}else{this.Is=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.bl||this.t("RolledBackTransaction",i,s),this.Is=!1}s!==null&&s.clear()}return this.um=null,this.Rw&&this.clear(),this.Rw=!1,this.vw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.YD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.lt();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.dm=!0}t.g()}sE(t){this.Kn+=t,this.Kn<0&&(this.Kn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Is=!0,this.t("StartingUndo","Undo",t),this.Os--,t.undo()}catch(i){Util.ri("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Is=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Is=!0,this.t("StartingRedo","Redo",t),this.Os++,t.redo()}catch(i){Util.ri("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Is=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ow(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.um=i);const e=t.copy(),s=i.changes;if(s.lt(),s.add(e),s.g(),this.gm&&this.Gk>0&&this.transactionLevel<=0&&!this.Aw){const n=t.diagram;if(n!==null&&n.Eh===!1)return;Util.ri("Change not within a transaction: "+e.toString()),this.Gk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Lw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get gm(){return this.Yk}set gm(t){this.Yk=t}get nestedTransactionNames(){return this.cn}get Rw(){return this.Tw}set Rw(t){this.Tw=t}get vw(){return this.Dw}set vw(t){this.Dw=t}get bl(){return this.Fw}set bl(t){this.Fw=t}get isJustDiscarded(){return this.dm}}class Tool{p;St;Oi;jk;Hk;mm;CC;constructor(){GSet.Yi(this),this.p=Diagram.pm(),this.St="",this.Oi=!0,this.jk=!1,this.Hk=null,this.CC=new InputEvent,this.mm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.qk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Wk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Wk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.qk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.GD(n,s,e),s.handled}GD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.xi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.ac){let o=t.ac;const r=o;for(t.ac=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.ac}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.CC);this.mm=Util.vh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.mm!==-1&&Util.Ig(this.mm),this.mm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.St}set name(t){Util.i(t,"string",Tool,"name"),this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.jk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.jk=t}get transactionResult(){return this.Hk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.Hk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{LC;AC;TC;Jk;$k;Zk;Qk;_k;tP;iP;ym;Uh;constructor(t){super(),this.name="ToolManager",this.LC=new List,this.AC=new List,this.TC=new List,this.Jk=850,this.$k=850,this.Zk=new Size(2,2).et(),this.Qk=5e3,this._k=1,this.tP=1,this.iP=null,this.ym=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this._k}set mouseWheelBehavior(t){this._k=t}get gestureBehavior(){return this.tP}set gestureBehavior(t){this.tP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.ym===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.vh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Ew(),t.Uw(this.draggedParts),t.pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.HD()}gP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.uc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Es(t){return t===void 0?new DraggingInfo(Point.ko):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.dP,t.pu=!1,t.kl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.mP(),t.xm(this.draggedParts),this.mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.gu=!1,DraggingTool.qD(),this.FC(),this.cc.e(NaN,NaN),DraggingTool.Vh!==null&&(DraggingTool.Vh.currentCursor=""),DraggingTool.Vh=null,DraggingTool.yt=null,this.Pl(),t.isMouseCaptured=!1,t.currentCursor="",t.fc=!1,this.stopTransaction(),t.pP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}mP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.RC(e,null),t.skipsUndoManager=i,this.mr.length=0}vC(){this.Pl(),this.yP();const t=this.diagram;this.cc.isReal()&&(t.position=this.cc),t.stopAutoScroll()}doCancel(){this.Pl(),this.yP();const t=this.diagram;this.cc.isReal()&&(t.position=this.cc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}WD(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}wP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.yP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Se()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Es(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Es())}if(this.copiedParts=o,this.gP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Pl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}FC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}dc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Ml===null&&e.avgSpf>30&&(e.Ew(),e.yu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.xP(t,i,this.dragOptions,e)}yP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Se()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Es()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}JD(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}bP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.OC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.RC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.kP(t,null,i=>!this.JD(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}RC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.ZD(i,l,o)}Rect.s(o)}$D(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}ZD(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.SP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.wP(!1),t.Uw(this.copiedParts),this.dc(this.copiedParts,!1),t.xm(this.copiedParts)):this.mayMove()?(this.Pl(),this.dc(this.draggedParts,!0)):this.mayDragOut()?(this.wP(!1),this.dc(this.copiedParts,!1)):this.Pl(),this.bP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Pl(),this.wP(!0),t.Uw(this.copiedParts),this.dc(this.copiedParts,!1),t.xm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Pl(),this.mayMove()&&(this.dc(this.draggedParts,!0),this.bP(t.lastInput.documentPoint))),this.gu=!0,this.UC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.QD(),t.invalidateDocumentBounds(),t.xm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Vh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Vh=e,e!==null&&e!==s){DraggingTool.yt.vC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.BC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.Vh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Vh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.vC(),r.BC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}QD(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}BC(){DraggingTool.Bw.has(this)||DraggingTool.Bw.add(this)}static qD(){if(DraggingTool.Bw.count>0){const t=DraggingTool.Bw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.UC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.fc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.wu=!1}VC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.WD(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.wm,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Es())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Se()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Es(c))}}if(Point.s(c),this.copiedParts=a,this.gP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}HD(){this.isDragOutStarted=!0,this.gu=!1,DraggingTool.yt=this,DraggingTool.Vh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.fc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static Bw=new List;static yt=null;static Vh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{NP;CP;Sl;LP;AP;zh;TP;Xh;DP;FP;RP;vP;OP;IP;zC;EP;Nl;UP;constructor(){super(),this.NP=100,this.CP=!1,this.Sl="pointer",this.LP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).hi(),this.zh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Ak}).theme("stroke","tempPort"),this.AP=new Node({selectable:!1,layerName:"Tool"}).add(this.zh).hi(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Ak}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).hi(),this.DP=null,this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=!0,this.zC=new GMap,this.EP=null,this.Nl=null,this.UP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.NP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.NP=t)}get isUnconnectedLinkValid(){return this.CP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.CP=t}get linkingCursor(){return this.Sl}set linkingCursor(t){this.Sl=t}get temporaryLink(){return this.LP}set temporaryLink(t){t.hi(),this.LP=t}get temporaryFromNode(){return this.AP}set temporaryFromNode(t){t.hi(),this.AP=t,t&&(this.zh=t.port)}get temporaryFromPort(){return this.zh}set temporaryFromPort(t){if(this.zh!==null){const i=this.zh.panel;if(i!==null){const e=i.T.indexOf(this.zh);i.removeAt(e),i.insertAt(e,t)}}this.zh=t}get temporaryToNode(){return this.TP}set temporaryToNode(t){t.hi(),this.TP=t,t&&(this.Xh=t.port)}get temporaryToPort(){return this.Xh}set temporaryToPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.T.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get originalLink(){return this.DP}set originalLink(t){this.DP=t}get originalFromNode(){return this.FP}set originalFromNode(t){this.FP=t}get originalFromPort(){return this.RP}set originalFromPort(t){this.RP=t}get originalToNode(){return this.vP}set originalToNode(t){this.vP=t}get originalToPort(){return this.OP}set originalToPort(t){this.OP=t}get isForwards(){return this.IP}set isForwards(t){this.IP=t}get validPortsCache(){return this.zC}get targetPort(){return this.EP}set targetPort(t){this.EP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Ak,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.BP(e,i,s)}BP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.BP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.BP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram.validCycle;if(s===1)return!0;if(s===5){const n=e||this.temporaryLink;if(n!==null&&!n.isTreeLink)return!0;const o=i.linksConnected;for(;o.next();){const r=o.value;if(r!==e&&r.isTreeLink&&r.toNode===i)return!1}return!this.xu(t,i,e,!0)}else if(s===6){const n=e||this.temporaryLink;if(n!==null&&!n.isTreeLink)return!0;const o=t.linksConnected;for(;o.next();){const r=o.value;if(r!==e&&r.isTreeLink&&r.fromNode===t)return!1}return!this.xu(t,i,e,!0)}else{if(s===2)return!this._D(t,i,e);if(s===3)return!this.xu(t,i,e,!1);if(s===4)return!this.tF(t,i,e)}return!0}xu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.xu(r,i,e,s))return!0}return!1}_D(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.XC(s,t,i,e)}XC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.XC(t,r,e,s))return!0}return!1}tF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.KC(s,t,i,e)}KC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.KC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Nl}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Nl=t}get portTargeted(){return this.UP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.UP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{VP;zP;S;XP;constructor(t){super(),this.name="Linking",this.VP={},this.zP=null,this.S=1,this.XP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.VP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.VP=t}get archetypeLabelNodeData(){return this.zP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.zP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.XP}set startObject(t){this.XP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Vw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{KP;YP;us;GP;constructor(t){super(),this.name="Relinking",this.KP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.YP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.us=null,this.GP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().bm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.KP}set fromHandleArchetype(t){this.KP=t}get toHandleArchetype(){return this.YP}set toHandleArchetype(t){this.YP=t}get handle(){return this.us}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Vw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.GP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.ru),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.ru),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.GP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;jP;HP;us;zw;qP;km;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size._N,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.jP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=3,this.us=null,this.zw=null,this.qP=new Point,this.km=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.WP!==t.pointsCount||i.JP!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.WP=t.pointsCount,i.JP=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.iF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}iF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.us}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.us=t}get adornedObject(){return this.ds}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.ds=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.pu=!0,this.startTransaction(this.name),this.Pm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.mc.set(this.adornedObject.part.location),this.ZP.set(this.adornedObject.desiredSize),this.Yw=this.computeCellSize(),this.Xw=this.computeMinSize(),this.Kw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.pu=!1,t.kl=!0,this.stopTransaction(),this.handle=null,this.ds=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Xw,e=this.Kw,s=this.Yw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Xw,e=this.Kw,s=this.Yw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Eg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.QP()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.gc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.gc=t}get dragsMembers(){return this.$P}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.$P=t}get oppositePoint(){return this.Pm}set oppositePoint(t){this.Pm.equals(t)||this.Pm.a(t)}get originalDesiredSize(){return this.ZP}get originalLocation(){return this.mc}}class RotatingTool extends Tool{_P;tM;ds;Co;us;iM;Mm;mc;eM;sM;constructor(t){super(),this.name="Rotating",this._P=45,this.tM=2,this.mc=new Point,this.ds=null,this.Co=new Shape("Ellipse",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.us=null,this.iM=0,this.Mm=new Point(NaN,NaN),this.eM=0,this.sM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Ll()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().bm())}else if(e.hi(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.us}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.us=t}get adornedObject(){return this.ds}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.ds=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.iM=this.adornedObject.angle,this.Mm=this.computeRotationPoint(this.adornedObject),this.mc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ds=null,this.Mm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.mc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this._P}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this._P=t}get snapAngleEpsilon(){return this.tM}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.tM=t}get originalAngle(){return this.iM}get rotationPoint(){return this.Mm}set rotationPoint(t){this.Mm=t.copy()}get handleAngle(){return this.eM}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.eM=t}get handleDistance(){return this.sM}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.sM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{pc;constructor(t){super(),this.name="Action",this.pc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.pc=e,t.ac=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.pc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.pc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.pc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.pc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.pc=null}}class ClickCreatingTool extends Tool{Al;nM;gc;oM;constructor(t){super(),this.name="ClickCreating",this.Al=null,this.nM=!0,this.gc=!1,this.oM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.oM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.oM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Se()&&(e.hi(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.rM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Al}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Al=t}get isDoubleClick(){return this.nM}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.nM=t}get isGridSnapEnabled(){return this.gc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.gc=t}}class DragSelectingTool extends Tool{Bh;lM;Tl;constructor(t){super(),this.name="DragSelecting",this.Bh=175,this.lM=!1,this.Tl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).hi(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Ni(root.document,"scroll",i.hM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.hM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Gw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Gw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.GC()}doMouseUp(){this.GC(),this.stopTool()}GC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.YC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Gw}}class HTMLInfo{jw;Hw;aM;cM;constructor(t){this.jw=null,this.Hw=null,this.aM=null,this.cM=null,t&&Object.assign(this,t)}get mainElement(){return this.aM}set mainElement(t){this.aM=t}get show(){return this.jw}set show(t){this.jw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.jw=t)}get hide(){return this.Hw}set hide(t){this.Hw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Hw=t)}get valueFunction(){return this.cM}set valueFunction(t){this.cM=t}}class ContextMenuButtonInfo{ai;Sm;wc;constructor(t,i,e){this.ai=t,this.Sm=i,this.wc=e}}class ContextMenuTool extends Tool{fM;qw;uM;dM;Ww;Jw;$w;constructor(t){super(),this.name="ContextMenu",this.fM=null,this.qw=null,this.uM=null,this.dM=new Point,this.Ww=null,this.$w=!1;const i=this;this.Jw=()=>i.stopTool(),t&&Object.assign(this,t)}eF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.bu=t;const i=this;this.Jw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Kh,!1),o.Vt(e,"selectstart",ContextMenuTool.Kh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Kh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Nm=e,ContextMenuTool.Cm=s,ContextMenuTool.gM=!0}static bu=null;static gM=!1;static Cm=null;static Nm=null;static Kh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.dM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.$w)return;this.$w=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.$w=!1,!e){this.isActive=!0;const s=ContextMenuTool.bu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.Ww===null&&(this.Ww=this.sF()),ContextMenuTool.Nm.innerHTML="",ContextMenuTool.Cm.addEventListener("pointerdown",this.Jw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Nm.appendChild(e),e.innerHTML="";const s=this.Ww.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.wc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ai,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Nm.style.display="block",ContextMenuTool.Cm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.bu)return;ContextMenuTool.Nm.style.display="none",ContextMenuTool.Cm.style.display="none";const t=this.diagram;t!==null&&t.Ni(ContextMenuTool.Cm,"pointerdown",this.Jw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.fM}set currentContextMenu(t){this.fM=t,this.qw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.gM===!1&&ContextMenuTool.bu===null&&Diagram.isUsingDOM()&&this.eF(),ContextMenuTool.bu}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.gM=!0),ContextMenuTool.bu=t}get currentObject(){return this.uM}set currentObject(t){this.uM=t}get mouseDownPoint(){return this.dM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Ne;mM;pM;Dl;Yt;yM;wM;xM;Zw;Qw;constructor(t){super(),this.name="TextEditing",this.Ne=new TextBlock,this.mM=null,this.pM=2,this.Dl=null,this.Yt=1,this.yM=1,this.wM=!0,this.xM=null,this.Zw=new HTMLInfo,this.Qw=null,this.nF(this.Zw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;nF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this.Qw=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.oF(s)},!1),i.addEventListener("blur",function(s){e.rF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.mM}set textBlock(t){this.mM=t}get currentTextEditor(){return this.xM}set currentTextEditor(t){this.xM=t}get defaultTextEditor(){return this.Zw}set defaultTextEditor(t){this.Zw=t}get starting(){return this.pM}set starting(t){this.pM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.xc&&TextEditingTool.xc!==this&&(TextEditingTool.xc.acceptText(2),TextEditingTool.xc&&TextEditingTool.xc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.xc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Ne=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break}}jC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.xc=null}oF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.Qw;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}rF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.Qw;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Dl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Dl=t}get minimumEditorScale(){return this.yM}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.yM=t}get selectsTextOnActivate(){return this.wM}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.wM=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Ne;return i.text=t,i.ut(this.textBlock.Fl,1/0),i}static xc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ci;Oi;kr;Yn;Ao;bM;kM;Lm;xi;bc;un;Am;Yh;_w;Tm;tx;kc;wu;Dm;constructor(t){this.p=Diagram.pm(),this.Ci=!1,this.Lm=!1,this.xi=!1,this.bc=!1,this.tx=!0,this.kc=1,this.wu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.bM=!1,this.kM=!1,this.Yn=new GSet,this.un=new Animation,this.Am=new Animation,this.un.gs=this,this.Yh=new GSet,this._w=new GSet,this.Tm=new GSet,this.Dm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}oE(){return this.p}canStart(t){return!0}Rl(t){return!this.Oi||!this.canStart(t)?!1:(this.Yn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Li(),this.xi=!0,!0)}getBundleAnimation(){return this.Am}PM(){if(!this.Oi||(this.Am.ue.count>0&&this.Am.start(),!this.xi))return;const t=this.un,i=this.p,e=this.Yn.has("Model");if(e&&(this.bc=!0,this.kc===1?(t.isViewportUnconstrained=!0,t.ue.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.kc===3&&t.ue.clear(),this.kc===2&&i.ix.equals(i.st)?this.tx=!0:this.tx=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ue.count===0){this.Yn.clear(),this.xi=!1,t.ue.clear(),t.ex(i),this.bc=!1,i.C();return}this.Yn.clear(),i.Pr=!1;const s=t.ue.get(i);i.autoScale!==1&&s!==null&&(delete s.ei.scale,delete s.ms.scale);const n=this;root.requestAnimationFrame(()=>{n.xi===!1||t.Ci||(i.getRenderingHint("temporaryPixelRatio")&&i.Ew(),i.MM(),n.xi=!1,t.start(),t.Ci&&(n.ku(),i.invalidateDocumentBounds(),t.HC(0),i.yr(!0),n.Pu(),i.v("AnimationStarting",n)))})}SM(){return this.Yn.has("Trigger")&&this.Yn.count===1}qC(t,i,e,s){this.isTicking||this.SM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}sx(t){return this.un.sx(t)}NM(t){return this.un.NM(t)}lF(t){const i=this.Yh,e=this;function s(){if(e.Tm.count>0&&(i.addAll(e.Tm),e.Tm.clear(),e.Ci=!0),e.Ci===!1||i.count===0)return;e._w.addAll(i);const n=e._w.iterator;for(;n.next();){const o=n.value;o.Ci!==!1&&(o.hF()?o.WC(!1):o.Pc=!0)}if(e._w.clear(),e.Ci===!1){root.requestAnimationFrame(s);return}e.ku(),e.p.yr(),e.Pu(),root.requestAnimationFrame(s)}this.Ci?this.aF(t):(this.Ci=!0,i.add(t),root.requestAnimationFrame(()=>s()))}aF(t){this.Tm.add(t)}cF(){const t=this.Yh.iterator;for(;t.next();)t.value.Pc=!1}ku(){if(this.Lm)return;const t=this.p;this.bM=t.skipsUndoManager,this.kM=t.de,t.skipsUndoManager=!0,t.de=!0,this.Lm=!0}Pu(){const t=this.p;t.skipsUndoManager=this.bM,t.de=this.kM,this.Lm=!1}stopAnimation(t){const i=this.un;if(this.xi===!0&&(this.xi=!1,this.bc=!1,this.Yn.clear(),i.fF()&&this.p.requestUpdate()),!this.Ci){i.ue.clear(),i.ex(this.p);return}if(i.Mu(!0),i.ex(null),t===!0){const e=this.Yh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util.tt(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ci}get isTicking(){return this.Lm}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Yh}get initialAnimationStyle(){return this.kc}set initialAnimationStyle(t){this.kc=t}static nx=new GMap;static defineAnimationEffect(t,i){AnimationManager.nx.set(t,i)}static AM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.nx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.AM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.AM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.AM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{ox;Fm;Ci;Su;Ao;ps;QC;Nc;ue;rx;ei;Gn;Nu;Cc;lx;hx;Pc;TM;ax;gs;p;DM;FM;RM;constructor(t){this.p=null,this.gs=null,this.TM=null,this.ax=null,this.DM=!1,this.Ci=!1,this.Pc=!1,this.ei=0,this.Gn=0,this.ox=Animation.EaseInOutQuad,this.Fm=Animation.EaseInOutQuad,this.Nu=!1,this.Cc=!1,this.lx=1,this.hx=0,this.Ao=NaN,this.ps=NaN,this.FM=0,this.Su=null,this.QC=Point.ko,this.ue=new GMap,this.rx=new GMap,this.Nc=new GSet,this.RM=1,t&&Object.assign(this,t)}suspend(){this.Pc=!0}advanceTo(t,i){i&&(this.Pc=!1),this.Nu&&t>=this.ps&&(this.Cc=!0,t=t-this.ps),this.FM=t,this.WC(!0),this.gs.ku(),this.p.yr(),this.gs.Pu(),this.p.redraw()}ex(t){if(this.rx.clear(),this.Cc=!1,this.hx=0,this.ps=NaN,this.Nc.count>0&&this.Nc.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Mr=null}}fF(){return this.ue.count>0}start(){if(this.ue.count===0)return this;if(this.Ci)return this;let t=this.p;const i=this.ue.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.gs=t.animationManager;else return this;const e=this.gs;return e.isEnabled===!1?this:(this.ps=isNaN(this.Ao)?e.duration:this.Ao,this.Fm=this.ox,e.bc&&e.kc===1&&this===e.defaultAnimation&&(this.Fm=Animation.EaseOutExpo,this.ps=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.RM=t.scrollMode,this.isViewportUnconstrained&&(t.Gh=2),e.ku(),this.Nc.each(s=>{s.data=null,t.add(s)}),e.Pu(),this.Ci=!0,this.ei=+new Date,this.Gn=this.ei+this.ps,e.lF(this),this)}addTemporaryPart(t,i){return t.Se()?(this.Nc.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.CM(t,i,e,s,n),this}CM(t,i,e,s,n){const o=this.ue;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.vM(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.vM(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.ei,h=r.ms,l[i]===void 0&&(l[i]=this.Cu(e)),h[i]=this.Cu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Cu(e),h[i]=this.Cu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.QC),n&&i.indexOf("position:")===0&&t instanceof Part?r.cx.location=this.Cu(t.location):n&&(r.cx[i]=this.Cu(e))}Cu(t){return t instanceof Point||t instanceof Size?t.copy():t}uF(t){const i=this.ue;if(i.has(t)){const e=i.get(t);e.fx=!0}}sx(t){if(!this.Ci)return!1;const i=this.ue.get(t);return i!==null&&i.fx}NM(t){if(!this.Ci)return!1;const i=this.ue.get(t);return i!==null&&!!(i.ei.position||i.ei["position:part"]||i.ei.location)}hF(){if(this.Nc.count>0)return!0;const t=this.ue.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}WC(t){if(this.Pc&&!t)return;const i=this.gs;if(this.Ci===!1)return;const e=+new Date;let s=e>this.Gn?this.ps:e-this.ei;t&&(s=this.FM,sthis.Gn&&(this.Nu&&!this.Cc?(this.ei=+new Date,this.Gn=this.ei+this.ps,this.Cc=!0):this.Mu(!1))}HC(t){const i=this.ps,e=this.ue.iterator,s=this.Cc;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.ms:o.ei,l=s?o.ei:o.ms,h=AnimationManager.nx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Fm,t,i,this)}}stop(){return this.Ci?(this.Mu(!0),this):this}Mu(t){if(this.ax!==null&&this.ax.dF(this.TM),!this.Ci)return;const i=this.p,e=this.gs;e.bc=!1,this.Ci=!1,this.Pc=!1,e.ku();const s=this.ue,n=this.Nc.iterator;for(;n.next();)i.remove(n.value);const o=this.Nu,r=s.iterator,l=AnimationManager.nx;for(;r.next();){const a=r.key,c=r.value,f=o?c.ms:c.ei,u=o?c.ei:c.ms,d=c.cx;for(const m in u)if(l.get(m)!==null){let g=m;c.ux&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.ux?f[m]:u[m],this.Fm,this.ps,this.ps,this)}c.ux&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.fx&&a instanceof Part&&a.Ei(!1)}this.hx++;const h=!t&&this.lx>this.hx;if(!h&&(this===e.Am||this===e.defaultAnimation)&&this.ue.clear(),i.gx.clear(),i.pP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Dm.iterator;for(;a.next();)a.value.gF();e.Dm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.RM),e.Pu(),h){this.Cc=!1,this.start();return}this.ex(null),e.Mu(this),this.Su&&this.Su(this),i.requestUpdate()}Mc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.mF(t,i)}mF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Mc(s,i)}}Sc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.uF(t),t instanceof Group&&this.pF(t,i)}pF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Sc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util.tt(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Nu}set reversible(t){this.Nu=t}get runCount(){return this.lx}set runCount(t){t>0?this.lx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Su}set finished(t){this.Su!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Su=t)}get easing(){return this.ox}set easing(t){this.ox=t}get isViewportUnconstrained(){return this.DM}set isViewportUnconstrained(t){this.DM=t}get isAnimating(){return this.Ci}getTemporaryState(t){let i=this.rx.get(t);return i===null&&(i={},this.rx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{ei;ms;cx;ux;fx;constructor(t,i,e){this.ei=t,this.ms=i,this.cx={},this.ux=e,this.fx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Me;an;Lu;Lc;constructor(t,i,e){this.Me=null,this.an=t,this.Lu=e||1,this.Lc=null,i!==void 0&&(this.Lc=i,e===void 0&&(this.Lu=2))}copy(){const t=new AnimationTrigger(this.an);t.Lu=this.Lu;const i=this.Lc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Lc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Lc}set animationSettings(t){this.Lc=t}yF(t){const i=this.Lc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Lu}set startCondition(t){this.Lu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;St;Wt;Sr;vl;Ol;Il;El;Ul;Bl;Vl;zl;Xl;Kl;Yl;Gl;wc;jl;mx;Rm;Au;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.St="",this.Wt=1,this.Sr=!1,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Gl=!0,this.wc=!0,this.jl=!0,this.mx=!0,this.Rm=!1,this.Au=[],t&&Object.assign(this,t)}wF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=`
`+c.toString();const f=c.data;f!==null&&GSet.cs(f)&&(h+=" #"+GSet.cs(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.jl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Cl()===!1||!h.isVisible())continue;n.a(t),n.Ue(h.ys);let a=h._C(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.jl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Cl()===!1||!a.isVisible())continue;o.a(t),o.Ue(a.ys);let c=a;a.tL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.jl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Cl()===!1||!a.isVisible())continue;let c=a;a.vm(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}SP(t,i,e,s,n,o,r){if(this.jl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Cl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.vm(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.jl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Cl()===!1||!u.isVisible())continue;l.a(t),l.Ue(u.ys),h.e(t.x+i,t.y),h.Ue(u.ys);let d=u;u.iL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}IM(){return this.At.r}Us(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.rt(),o=Util.rt();for(let r=0;r0&&o.push(l))}for(let r=0;re.Im||a.height*n>e.Im?i.Gi(t,e):this.PF(t,i),c&&(t.restore(),t.clearContextCache(!0))}PF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.L;if(i.background===null&&(i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height)),i.background!==null&&(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.vk())){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}kF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Em(e);const n=this.diagram;return n!==null&&(e?n.C():n.Hh(i)),this.px(t,i),t}te(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.te(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Um(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n.te(i)),i.OM(null),t}px(t,i){t=this.MF(t,i),i instanceof Group&&this.SF(t,i),i.svg!==null&&i.svg.remove()}MF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.tt(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.Rm}set isViewportAligned(t){const i=this.Rm;i!==t&&(this.Rm=t,this.diagram&&(this.sL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}sL(){if(!this.Rm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{gs;gi;BM;yx;Nr;Fu;wx;xx;bx;kx;Px;Mx;Ac;Gh;Sx;Nx;Cx;Hl;Tc;Cr;Bm;Lx;Ax;Ru;jn;Lr;qh;Fo;Vm;Dc;zm;Fc;vu;Ar;Hn;VM;zM;Tx;Dx;XM;Fx;KM;YM;GM;Rx;Xm;Tr;Dr;Fr;Rr;vr;Or;vx;Ir;Ox;Er;Ur;Br;Vr;Ix;jM;Ro;HM;Ex;Ux;qM;Si;WM;JM;$M;Os;vo;Oi;Bx;vl;Ol;Vx;zx;Il;El;Ul;Xx;Bl;Vl;zl;Xl;Kl;Yl;Gl;Kx;Yx;ZM;Ou;Iu;Gx;jx;Hx;qx;Km;Wx;Jx;$x;Zt;QM;Zx;_M;Eu;gn;qn;ie;Wn;nL;ql;tS;iS;Ym;Qx;Uu;Gm;_x;zr;Wl;Wh;eS;sS;jm;tb;ib;is;Hm;qm;Bu;Jl;Rc;Wm;Xr;Jh;nS;Jm;Ht;L;ze;Pr;Ui;ws;oS;$l;Kr;kl;Yr;$h;vc;rS;Vu;Zh;zu;Gt;Zl;st;K;Xu;kt;Pt;dt;Oc;Iw;eb;Qh;Ic;sb;nb;ob;LF;AF;Bi;Ml;Im;$m;lS;hS;oL;Zm;TF;DF;FF;rb;RF;vF;OF;_h;rL;Ql;ta;ia;ea;sa;yu;Kh;ni;Tt;Ec;qk;Wk;ac;Wt;static lb=null;static lL=new GMap;static aS;static cS=null;pu;hb;ab;cb;fb;ub;Qm;fS;_m;t0;i0;ix;uS;db;Uc;constructor(t,i){if(Diagram.fw||(Diagram.Ok(),Diagram.fw=!0),GSet.Yi(this),Diagram.hL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Ni(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Oc=null,Diagram.dS("Model",PartManager);const e=this;return this.WM=s=>e.partManager.doModelDataChanged(s),this.JM=s=>e.partManager.doModelChanged(s),this.sb=null,this.nb=null,this.aL(),this.model=Model.initDiagramModel(),this.db=null,this.themeManager=new ThemeManager,this.Ro=!0,this.cL(),this.layout=new Layout,this.Ro=!1,this.TF=null,this.DF=null,this.FF=null,this.rb=null,this.RF=null,this.vF=null,this.OF=null,this._h=null,this.rL=null,this.Ql=null,this.ta=null,this.ia=null,this.ea=null,this.sa=null,this.yu=()=>{},this.Kh=null,this.Bu=!1,this.Ec=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.gS(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}jD(){return this.dt!==null}get renderer(){return this.Rc}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Rc;if(i===e)return;this.Rc=i;let s=null;i==="default"||i==="canvas"?(s=this.Jl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.ni=this.dt.ci)):i==="svg"?(this.Jl.has("svg")?s=this.Jl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.ni=s.ci,this.dt&&(this.dt.ci.setTransform(this.Bi,0,0,this.Bi,0,0),this.dt.ci.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Jl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}aL(){this.Uc=new List,this.setupRouters(),this.gs=new AnimationManager,this.gs.To(this),this.gi=17,this.BM=!1,this.Xu=!1,this.yx="default",this.Gt=new List,this.Jl=new GMap,this.Rc="default",this.resetRenderingHints(),this.IF(),this.Wt=1,this.st=new Point(NaN,NaN).g(),this.ix=new Point(NaN,NaN),this.K=1,this.Jm=1,this.wx=new Point(NaN,NaN).g(),this.xx=NaN,this.bx=1e-4,this.kx=100,this.L=new Transform,this.Px=new Point(NaN,NaN).g(),this.Mx=new Rect(NaN,NaN,NaN,NaN).g(),this.Ac=new Margin(0,0,0,0).g(),this.Gh=1,this.Sx=!1,this.Nx=null,this.Cx=null,this.Hl=1,this.Tc=Spot.Default,this.Cr=1,this.Bm=Spot.Default,this.Lx=Spot.None,this.Ax=Spot.None,this.ze=!0,this.Ru=!1,this.jn=new Set,this.Lr=new GSet,this.qh=new GSet,this.Fo=!1,this.Zl=new GMap,this.Vu=!0,this.Vm=250,this.Dc=-1,this.zm=new Margin(16,16,16,16).g(),this.Pr=!1,this.Fc=!1,this.vu=!0,this.Wm=new InputEvent,this.Wm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.Jh=new InputEvent,this.Jh.diagram=this,this.Ar=null,this.Hn=null,this.Iw=!1,this.EF(),this.Yr=new GSet,this.Tx=!0,this.Dx=1,this.XM=!1,this.Fx=1,this.Rx="auto",this.Xm="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.vx=null,this.Ir=null,this.Ox=!1,this.Er=null,this.Ur=null,this.Br=null,this.Vr=null,this.Ix=!1,this.eb={},this.Qh=[null,null],this.Ro=!1,this.HM=!1,this.Ex=!1,this.Ux=!1,this.qM=!0,this.ws=!1,this.Zh=!1,this.$M=!0,this.Os=-2,this.$l=new GMap,this.zu=new List,this.vo=!1,this.Oi=!0,this.Bx=!0,this.vl=!0,this.Ol=!0,this.Vx=!1,this.zx=!0,this.Il=!0,this.El=!0,this.Ul=!0,this.Xx=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Gl=!0,this.Kx=!0,this.Yx=!0,this.ZM=!1,this.Ic=!1,this.Ou=!0,this.Iu=!0,this.Gx=!0,this.jx=!0,this.Hx=16,this.qx=16,this.Km=!1,this.Wx=!1,this.Jx=0,this.$x=0,this.Zt=new Margin(5).g(),this.QM=new GSet().g(),this.Zx=999999999,this._M=new GSet().g(),this.$h=!0,this.Eu=!0,this.vc=!0,this.gn=!1,this.qn=!1,this.Kr=!0,this.kl=!1,this.Wn=!1,this.nL=new GSet,this.rS=new GSet,this.ql=null,this.tS=new Size(8,8),this.iS=999,this.Ym=!1,this.qk=1,this.Wk=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.Qx=new Rect(NaN,NaN,NaN,NaN).g(),this.Uu=new Size(NaN,NaN).g(),this.Gm=new Rect(NaN,NaN,NaN,NaN).g(),this._x=!1,this.UF(),this.is=null,this.Hm=!1,this.ac=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.ab=null,this.cb=new DraggingOptions,this.fb=null,this.ub=null,this.hb=!1,this.pu=!1,this.commandHandler=new CommandHandler,this.t0=null,this.i0=Point.Ck,this.uS=!1,this.Bi=1,this.Ml=null,this.Im=1,this.Qm=0,this.fS=[0,0,0,0,0],this._m=0,this.$m=1,this.lS=0,this.hS=new Point,this.oL=500,this.qm=new Point,this.Zm=!1}static fL=root.document!==void 0;static isUsingDOM(){return Diagram.fL}static useDOM(t){Diagram.fL=t?root.document!==void 0:!1}static ee=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.uL(),this.dL(!1),this.zu.clear(),this.gL(),this.ql=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}dL(t){this.animationManager.stopAnimation(!0),this.QM=new GSet().g(),this._M=new GSet().g();const i=this.skipsUndoManager,e=this.Si!==null&&this.Si!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.is!==null&&(s=this.is.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.tb=this.jm,this.ib=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.yx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.cS,n=Diagram.aS;s===null&&(Diagram.cS=Util.en("p"),s=Diagram.cS,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.aS=Util.en("div"),n=Diagram.aS,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.gi=e,this.BM=!0}li(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=`
`+n.toString(t-1)}return e}static hL(t){Diagram.lb=t}static pm(){return Diagram.lb}static fromDiv(t){let i=t;return typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement&&Diagram.ee.has(i)?Diagram.ee.get(i):null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.ee.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Ni(s,"pointermove",this.ta,!1),this.Ni(s,"pointerdown",this.Ql,!1),this.Ni(s,"pointerup",this.ia,!1),this.Ni(s,"pointerout",this.ea,!1),this.Ni(s,"pointercancel",this.sa,!1),this.dt.dispose()}this.Oc&&(this.Oc.disconnect(),this.Oc=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Ni(root,"resize",this.rb,!1),this.Ni(root,"wheel",this._h,!0),Diagram.pm()===this&&Diagram.hL(null)}else this.Ql===null&&(this.Wn=!1);if(this.Tt=null,t!==null){const e=Diagram.ee.get(t);e&&(e.div=null),this.gS(t),this.yu(),this.themeManager&&this.themeManager.BF()}else this.themeManager&&this.themeManager.VF()}}setupRouters(){this.Uc.push(new AvoidsNodesRouter)}gS(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.ee.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Oc&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Mk(()=>i.requestUpdate(),250,!1);i.Oc=new c(()=>f()),i.Oc.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.ee.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Xu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.ni=o.ci;const r=i.ni;i.Bi=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.mL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.LF=h,i.AF=h.ci,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.zF,c.addEventListener("pointerdown",Diagram.XF),c.p=i,c.KF=!0,c.YF=!0,i.sb=c,i.nb=f}i.yu=Util.Mk(()=>{i.Ml=null,i.C()},300,!1),i.rb=Util.Mk(()=>{i.MM()},250,!1),i.Kh=c=>(c.preventDefault(),!1),i._h=c=>{if(!l.isEnabled)return;const f=l.Bc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.na(f,c)},i.rL=c=>{if(!l.isEnabled)return;i.Ic=!1,l.Bc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Ql=c=>{if(!l.isEnabled)return;i.Ic=!0;const f=l.eb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l.Qh;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Iw=!1,l.Zm=!0);const g=l.GF(c,c,d),p=l.hS,y=m?25:10;if(c.timeStamp-l.lSy||Math.abs(p.y-c.screenY)>y)?l.$m++:l.$m=1,g.clickCount=l.$m,l.lS=c.timeStamp,l.hS.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.na(g,c)},i.ta=c=>{if(!l.isEnabled)return;i.Ic=!0;const f=l.Qh;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.jF(c,c,f[1]!==null);l.doMouseMove(),l.na(u,c)},i.ia=c=>{if(!l.isEnabled)return;i.Ic=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.eb;if(f&&l.Iw){delete u[c.pointerId],c.preventDefault();return}const d=l.Qh;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.mS(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.s0(c,m),g===null&&(g=c.target),l.s0(c,m),m.clickCount=l.$m,m.targetDiagram=l.pS(c,g),m.targetObject=null,l.doMouseUp(),l.na(m,c),f&&(l.Zm=!1)},i.ea=c=>{if(!l.isEnabled)return;i.Ic=!1;const f=l.eb;f[c.pointerId]&&delete f[c.pointerId];const u=l.Qh;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.sa=c=>{const f=l.Qh;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Zm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.ob=a.B[Util.As("7eba17a4ca3b1a8346")][Util.As("78a118b7")](a.B,Diagram.Ku,s,s),r.clearContextCache(!0),i.HF(),this.Rc==="svg"){const c=this.Jl.get("svg");this.Tt.appendChild(c.Ft),this.ni=c.ci}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Ni(t,i,e,s){t.removeEventListener(i,e,{capture:s})}HF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Ql,!1),this.Vt(i,"pointermove",t.ta,!1),this.Vt(i,"pointerup",t.ia,!1),this.Vt(i,"pointerout",t.ea,!1),this.Vt(i,"pointercancel",t.sa,!1),this.Vt(i,"pointerenter",t.qF,!1),this.Vt(i,"pointerleave",t.WF,!1),this.Vt(i,"wheel",t._h,!1),this.Vt(i,"keydown",t.JF,!1),this.Vt(i,"keyup",t.$F,!1),this.Vt(i,"blur",t.ZF,!1),this.Vt(i,"focus",t.QF,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.rb,!1)}Ew(){this.Qm>30&&(this.Ml=1)}pP(t){this.Ml!==null&&(this.Ml=null,t&&this.yu(),this.Qm=0,this.fS=[0,0,0,0,0],this._m=0)}computePixelRatio(){return this.Ml!==null?this.Ml:root.devicePixelRatio||1}get avgSpf(){return this.Qm}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}QF(t){Diagram.ee.get(this).v("GainedFocus")}ZF(t){Diagram.ee.get(this).v("LostFocus")}MM(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.BM||this.setScrollWidth();const e=this.qn?this.gi:0,s=this.gn?this.gi:0,n=this.Bi;if(this.Bi=this.computePixelRatio(),this.Bi!==n&&(this.Ru=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.oa(),this.ze=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Fc=!0,o.invalidateLayout()),this.ws||this.requestUpdate()}}cL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.jr(i,t++),i=new Layer,i.name="Background",this.jr(i,t++),i=new Layer,i.name="",this.jr(i,t++),i=new Layer,i.name="Foreground",this.jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.jr(i,t++)}pL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static zF(){const t=Diagram.ee.get(this.parentElement||this);if(t){if(t.Wx){t.Wx=!1;return}if(!t.isEnabled){t.yL();return}t.diagramScroll(this)}}static XF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.Jx=t.target.scrollTop,this.p.$x=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.sb,e=this.nb;this.Km=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Ac;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let b,k=t.scrollLeft;if(this.Xu)switch(this.yx){case"negative":k=k+t.scrollWidth-t.clientWidth;break;case"reverse":k=t.scrollWidth-k-t.clientWidth;break}const P=k;if(mp)){const M=i.scrollWidth-this.kt;this.position=b.e(-M+P-this.kt/x+c,this.position.y)}if(t.YF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.Pt;this.position=b.e(this.position.x,-M+t.scrollTop-this.Pt/x+f)}Point.s(b),this._l(),this.Km=!1,this.Eu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Li(),this.wL(t)}wL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.Zt),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.gi)/n:a=(o-this.gi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Gh;this.Gh=1,this.scale=this.Yu(2),t!==1&&(this.Bs(!1),this.yS(this.documentBounds,this.kt/this.K,this.Pt/this.K,this.Tc,!1)),this.Gh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.gi:0))/s:n=(o-(this.qn?this.gi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get _F(){return this.Ht}set _F(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.t0=t;const i=Point.l();this.i0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.t0=null,this.i0=Point.Ck}yS(t,i,e,s,n){const o=Point.X(this.st.x,this.st.y);let r=o.x,l=o.y;if(this.t0!==null){let h=Point.l();h=this.t0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.i0.x/this.scale,l=h.y-this.i0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Ac,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.kP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Li();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}kP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Li();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.iR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}iR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Li();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Li();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.eR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Li();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}SP(t,i,e,s,n,o){const r=new GSet;this.Li();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.SP(t,i,e,s,r,n,o)}return r}eR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Li();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.sR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Li();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}sR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Li();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Bc(t,t instanceof MouseEvent)}Bc(t,i){const e=this.Xr;this.Xr=this.Jh,this.Jh=e,e.diagram=this,e.event=t,i?this.s0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.pS(t,t.target),e.targetObject=null,e}pS(t,i){if(i===null)return null;const e=Diagram.ee.get(i);if(e)return e;let s=t.path;return!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]&&Diagram.ee.has(s[0])?Diagram.ee.get(s[0]):null}GF(t,i,e){const s=this.mS(t,!0,!1,!1,!0,e);return this.s0(i,s),s.targetDiagram=this.pS(t,t.target),s.targetObject=null,e||s.clone(this.Wm),s}jF(t,i,e){const s=this.mS(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;return n&&Diagram.ee.get(n)&&(r=i,o=Diagram.ee.get(n)),s.targetDiagram=o,this.s0(r,s),s.targetObject=null,s}mS(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.Jh,this.Jh=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}na(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}JF(t){const i=Diagram.ee.get(this);if(!i.isEnabled)return!1;const e=i.Bc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.na(e,t)}$F(t){const i=Diagram.ee.get(this);if(!i.isEnabled)return!1;const e=i.Bc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.na(e,t)}qF(t){const i=Diagram.ee.get(this);if(!i.isEnabled)return!1;const e=i.Bc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.na(e,t)}WF(t){const i=Diagram.ee.get(this);if(!i.isEnabled)return!1;const e=i.Bc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.na(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return this.L!==null?new Point(s,n).Ue(this.L):new Point(s,n)}s0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const o=e.getBoundingClientRect();s=(t.clientX-o.left)*(this.kt/o.width),n=(t.clientY-o.top)*(this.Pt/o.height)}if(i.viewPoint.e(s,n),this.L!==null){const o=Point.X(s,n);this.L.ts(o),i.documentPoint.a(o),Point.s(o)}else i.documentPoint.e(s,n)}kC(t,i,e){let s;if(this.Qh[0]!==null)s=this.Qh[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.$h||(this.$h=!0,this.requestUpdate(!1))}nR(){this.ws||this.Li(),this.ensureBounds()}redraw(){this.Ht||this.ws||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Wn=!1,this.ix=new Point(NaN,NaN),i.isEnabled=e,this.ws=!0;const s=this;t!==null&&Util.vh(()=>{s.ws=!1,i.Rl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ws)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.vu&&!this.Pr||(this.vu&&(this.vu=!1),this.yr())}wS(t,i){!this.Eu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.yL()||(t&&this.Li(),i&&this.Bs(!1))}yr(t){if(this.ws||(this.Pr=!1,this.Tt===null&&!this.Uu.isReal()))return;this.ws=!0;const i=this.animationManager,e=this.zu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.xS()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.xi||this.MM(),t||this.wS(!1,!0),this.is!==null&&(this.is.visible&&!this.Hm&&(this.Hr(),this.Hm=!0),!this.is.visible&&this.Hm&&(this.Hm=!1));const r=!this.undoManager.isUndoingRedoing&&(this.kl||this.Uc.count!==0&&this.Lr.size!==0),l=!this.Wn||this.Kr;this.Li(!0);let h=!1;(l||r)&&(this.Wn?this.bS(!this.Fc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.bS(!1,r)),h=l),this.Fc=!1,this.kl=!1,this.Li(),this.Ex||this.nR(),t||this.wS(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Wn||(this.Wn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Rw=!0),this.undoManager.vw=!0,this.oR()),this.rR(),this.Li(!1),t||this.wS(!0,!0),Rect.s(c)}else if(i.bc&&i.tx){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.Hl!==1)this.scale=this.Yu(this.Hl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Bs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.ni),o&&(this.skipsUndoManager=n),this.ws=!1}get Eh(){return this.Wn}oR(){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.Hl!==1)this.scale=this.Yu(this.Hl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Bs(!0);const t=this.Gt.r;this.Us(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ix.a(this.st),this.Hr()}rR(){this.v("LayoutCompleted")}o0(t){this.jn.add(t)}addInvalidRoute(t){this.Fo?this.qh.add(t):this.Lr.add(t)}Li(t){if(this.jn.size!==0&&!(!this.ws&&this.animationManager.isTicking)){if(this.ws||(this.kl=!0),t){this.xL(this.jn);return}for(let i=0;i<23&&this.jn.size!==0;i++){const e=new Set(this.jn);this.jn.clear(),this.xS(e,this.jn)}this.nodes.each(i=>{i instanceof Group&&i.bL(!1)})}}xL(t,i){for(const e of t)!e.Se()||e instanceof Group||(e.qr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.mb(e)}}xS(t,i){this.xL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.qr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.qr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}r0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.jn;if(i)this.Li(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Se()||n instanceof Group||n.qr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.mb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.qr()&&(n.ut(1/0,1/0),n.zt())}}mb(t){const i=Util.rt(),e=Util.rt(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.es()||o.th())&&this.mb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ok.Du())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.cw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.cw(t.toolManager,r))o=t.toolManager;else if(s&&t.kL(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}aR(){if(this.Zl.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.Zl.count>0;){const t=this.Zl;this.Zl=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ne()}}this.C()}}C(t){if(t===void 0)this.ze=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.ze=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.ze===!0)return;if(this.ze=!0,this.Rc==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Ew(),this.maybeUpdate(),this.pP(!0)):this.maybeUpdate()}oa(){this.Eu=!0}_l(){this.vc=!0}l0(){this.Ru!==!1&&(this.Ru=!1,this.mL(this.kt,this.Pt))}mL(t,i){this.Gr();const e=this.Bi,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.ze=!0,this.ni.clearContextCache(!0))}yL(){const t=this.dt;if(t===null||this.Uu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.qn?this.gi:0,r=this.gn?this.gi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.qn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.Ru=!0,n=!0,this.Gr()),!this.Wn||!this.viewportBounds.isReal())return!0;const m=this.sb,g=this.nb;if(this.Eu=!1,!n&&!this.qn&&!this.gn&&!this.Ou&&!this.Iu)return!0;const p=this.documentBounds;let y=0,x=0,b=0,k=0;const P=a.width,M=a.height,L=this.Ac;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>M&&(b=L.top,k=L.bottom)):(y=L.left,x=L.right,b=L.top,k=L.bottom);const C=p.width+y+x,S=p.height+b+k,N=this.scale,T=N;let A=C>l/N,D=S>h/N;if(!n&&!this.qn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const U=p.y-b,X=a.y,E=p.bottom+k;let V=a.bottom+r,B="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),M+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),M+1O+1&&(J=this.position.x*N)),this.Xu)switch(this.yx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.qn?this.gi:0)+"px",m.style.height=h+(this.gn?this.gi:0)+"px",i!==l||e!==h||this.animationManager.xi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Hh(t){this.partManager.Hh(t);const i=this;t.Wr(s=>i.PL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.Wr(s=>i.partManager.PS(s,null)),(t.es()===!0||t.th()===!0)&&this.o0(t),t.ML(!0,this),t.SL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}te(t){t.clearAdornments(),this.partManager.te(t);const i=this;t.data!==null&&t.Wr(s=>i.partManager.MS(s,i)),this.jn.delete(t),t instanceof Link&&this.Lr.delete(t),t.SL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}remove(t){this.SS(t,!0)}SS(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Vc();const s=e.te(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Si!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.NS(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.st.x+l/t-l/i,this.st.y+h/t-h/i);this.position=c,Point.s(c),this.K=i,this.Gr(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Bs(!1),e.ZC(t,this.K),this.C()}tR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Hr(t){const i=this.is;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.Qx;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.bi===null&&(i.bi=new GridPanelSettings);const o=i.bi.zc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Eg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){const i=this.L;i.Jt(),this.K!==1&&i.K(this.K);const e=this.st;return(e.x!==0||e.y!==0)&&isFinite(e.x)&&isFinite(e.y)&&i.Zi(-e.x,-e.y),t.copy().L(i)}transformViewToDoc(t){const i=this.L;i.Jt(),this.K!==1&&i.K(this.K);const e=this.st;return(e.x!==0||e.y!==0)&&isFinite(e.x)&&isFinite(e.y)&&i.Zi(-e.x,-e.y),t.copy().Ue(i)}CF(t){const i=this.L;i.Jt(),this.K!==1&&i.K(this.K);const e=this.st;return(e.x!==0||e.y!==0)&&isFinite(e.x)&&isFinite(e.y)&&i.Zi(-e.x,-e.y),t.Ue(this.L)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.tt(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Fx}set validCycle(t){const i=this.Fx;i!==t&&(this.Fx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Si;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Si;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Bx}set allowClipboard(t){const i=this.Bx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Bx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.vl}set allowCopy(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.vl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.Ol}set allowDelete(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.Ol=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.Vx}set allowDragOut(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.Vx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.zx}set allowDrop(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.zx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Il}set allowTextEdit(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Il=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.El}set allowGroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.El=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.Ul}set allowUngroup(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.Ul=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Xx}set allowInsert(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Xx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Bl}set allowLink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Bl=t,this.t("allowLink",i,t))}get allowRelink(){return this.Vl}set allowRelink(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Vl=t,this.t("allowRelink",i,t))}get allowMove(){return this.zl}set allowMove(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.zl=t,this.t("allowMove",i,t))}get allowReshape(){return this.Xl}set allowReshape(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.Xl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Kl}set allowResize(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Kl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Yl}set allowRotate(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Yl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Gl}set allowSelect(t){const i=this.Gl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Gl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Kx}set allowUndo(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Kx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Yx}set allowZoom(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Yx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Iu}set hasVerticalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Iu=t,this.oa(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Bs(!1))}get hasHorizontalScrollbar(){return this.Ou}set hasHorizontalScrollbar(t){const i=this.Ou;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ou=t,this.oa(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Bs(!1))}get allowHorizontalScroll(){return this.Gx}set allowHorizontalScroll(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.Gx=t,this.t("allowHorizontalScroll",i,t),this.Bs(!1))}get allowVerticalScroll(){return this.jx}set allowVerticalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.jx=t,this.t("allowVerticalScroll",i,t),this.Bs(!1))}get scrollHorizontalLineChange(){return this.Hx}set scrollHorizontalLineChange(t){const i=this.Hx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.tt(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.Hx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.qx}set scrollVerticalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.tt(t,">= 0",Diagram,"scrollVerticalLineChange"),this.qx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.Jh}set lastInput(t){this.Jh=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Wm}set firstInput(t){this.Wm=t}get currentCursor(){return this.Rx}set currentCursor(t){if(t===""&&(t=this.Xm),this.Rx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.Rx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Xm}set defaultCursor(t){t===""&&(t="auto");const i=this.Xm;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Xm=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.vx}set mouseDragOver(t){const i=this.vx;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.vx=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ox}set handlesDragDropForTopLevelParts(t){const i=this.Ox;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ox=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Br}set toolTip(t){const i=this.Br;i!==t&&(this.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.jM}set commandHandler(t){this.jM!==t&&(this.jM=t,t.To(this))}get toolManager(){return this.KM}set toolManager(t){this.KM!==t&&(this.KM=t,t.diagram=this)}get defaultTool(){return this.YM}set defaultTool(t){const i=this.YM;i!==t&&(this.YM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.GM}set currentTool(t){const i=this.GM;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.GM=t,t.diagram=this,t.doStart())}get selection(){return this.QM}get maxSelectionCount(){return this.Zx}set maxSelectionCount(t){const i=this.Zx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Zx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.jm}set nodeSelectionAdornmentTemplate(t){const i=this.jm;i!==t&&(this.jm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.tb}set groupSelectionAdornmentTemplate(t){const i=this.tb;i!==t&&(this.tb=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.ib}set linkSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this._M}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Bu&&this.Os!==t.historyIndex:this.Bu}set isModified(t){if(this.Bu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Bu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.Os=e.historyIndex),t||this.RL()}}RL(){const t=this.isModified;this.$M!==t&&(this.$M=t,this.v("Modified"))}get model(){return this.Si}set model(t){const i=this.Si;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.dL(!0);this.Wn=!1,this.vu=!0,this.Os=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Rl("Model"),i&&(this.Hn!==null&&this.Hn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.JM)),this.Si=t,this.partManager=this.cR(this.Si.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.db}set themeManager(t){const i=this.db;i!==t&&(i!==null&&i.removeDiagram(this),this.db=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static dS(t,i){Diagram.lL.set(t,i)}static get licenseKey(){return Diagram.LS.last()}static set licenseKey(t){Diagram.LS.add(t.replace(/\s/g,""))}static get version(){return Diagram.fR}static LS=new List;static fR="3.0.7";cR(t){const i=Diagram.lL.get(t);return i!==null?new i:new PartManager}get G(){return this.qM}set G(t){this.qM=t}get gx(){return this.nL}uR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ws&&!this.Wn&&(this.Fc=!0,this.vu&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.G){this.G=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Li());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.aR(),this.Fc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.PM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.Os=Math.min(this.Os,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.vw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.RL(),this.gx.clear(),this.animationManager.cF()),!this.Ix&&n&&this.lastInput.targetDiagram){this.Ix=!0;const o=this;Util.vh(()=>{o.currentTool.standardMouseOver(),o.Ix=!1},10)}}}finally{this.G=!0}}}get de(){return this.HM}set de(t){this.HM=t}get fc(){return this.Ex}set fc(t){this.Ex=t}PL(t){const i=t.T.r;for(const e of i)e instanceof Picture&&this.AS(e)}AS(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ss instanceof GSet&&i.ss.add(this),t.dR(),!i.c0))return;const e=i.getAttribute("src")||"",s=this.$l.get(e);if(s===null){Picture.vL(t,i);const n=[];n.push(t),this.$l.set(e,n)}else{for(let n=0;n0?(this.bx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util.tt(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.kx}set maxScale(t){const i=this.kx;i!==t&&(t>0?(this.kx=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Px}set zoomPoint(t){this.Px.equals(t)||(t=t.N(),this.Px=t)}get contentAlignment(){return this.Tc}set contentAlignment(t){const i=this.Tc;i.equals(t)||(t=t.N(),this.Tc=t,this.t("contentAlignment",i,t),this.Bs(!1))}get initialContentAlignment(){return this.Bm}set initialContentAlignment(t){const i=this.Bm;i.equals(t)||(t=t.N(),this.Bm=t,this.t("initialContentAlignment",i,t))}get padding(){return this.Zt}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zt;i.equals(t)||(t=t.N(),this.Zt=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.nS}set partManager(t){const i=this.nS;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.nS=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.Uc}doLinkRouting(t){this.Fo=!0;const i=this.Uc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.xb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.OS(l,e,o)}Rect.s(o)}s.la=n,s.FS=e,s.Eo=!1}else t&&s.VL();return s}get avoidanceCellSize(){return this.tS}set avoidanceCellSize(t){this.ql=null,this.tS=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.iS}set avoidanceLimit(t){this.iS=Math.max(1,t)}BL(t){return t.canAvoid()?t:t.containingGroup!==null?this.BL(t.containingGroup):null}OS(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.ql.pR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.OS(o,i,e)}}}IS(t){this.ql!==null&&!this.ql.Eo&&(t===void 0||t.canAvoid())&&(this.ql.Eo=!0)}get autoScrollInterval(){return this.Vm}set autoScrollInterval(t){const i=this.Vm;i!==t&&(this.Vm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.zm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.zm;i.equals(t)||(t=t.N(),this.zm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.qm.a(t),this.computeAutoScrollPosition(this.qm).equalsApprox(this.position)?this.stopAutoScroll():this.zL()}zL(){if(this.Dc!==-1)return;const t=this.Vm,i=this;this.Dc=Util.vh(()=>{if(i.Dc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.qm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.qm),i.doMouseMove(),i.$h=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.OL(n),Rect.s(n),i.ze=!0,i.maybeUpdate(),i.zL()},t)}stopAutoScroll(){this.Dc!==-1&&(Util.Ig(this.Dc),this.Dc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.zm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.ko)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Jl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.XL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.KL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Jl.set(t,i)}removeRenderer(t){this.Jl.delete(t)}cacheGroupExternalLinks(t){this.uS=t,t||this.nodes.each(i=>{i instanceof Group&&(i.u0=null)})}KL(t,i){const e=i.callback;let s=!0;const o=this.$l.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.KL(this.yR,t)}static img="image";yR(t,i,e){const s=e.XL(t,"canvas",null);if(s===null)return null;const n=s.B.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static wR=!1;XL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.ni.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ci;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.Gu=m,this.pb(e.ci,c,new Size(y.width,y.height),this.K,this.st,a,f,g,p),e.ci):(this.Vu=!1,this.pb(x,c,new Size(y.width,y.height),this.K,this.st,a,f,g,p),this.Vu=!0,y.ci);const b=this.Jm,k=this.documentBounds.copy();if(k.subtractMargin(this.Zt),g){const A=this.Gt.r,D=A.length;for(let F=0;Fb?(r=b,N=k.width,T=k.height):(N=l.width,T=l.height)):(N=k.width*r,T=k.height*r):(r=b,N=k.width,T=k.height),c!==null?(N+=M,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.wR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.Gu=m,this.pb(e.ci,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ci):(this.Vu=!1,this.pb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.Vu=!0,y.ci)}static Ku=null;static YL="5da73c80a36555d4038e4972187c3cae51fd22";static fw=!1;static Ok=()=>{if(Diagram.YL[5]===void 0&&(Transform.prototype.ts=Transform.prototype.pw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.As("7ca11abfd022028846");i[e]=Util.As("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.YL,Util.fw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ok+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.As(s)](Util.As(n[l-1]),o,l*15+r);i[e]=Util.As("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.As(s)](Util.As(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ts=Transform.prototype.pw),Diagram.Ku=t}}class DiagramHelper{GL;jL;ES;Le;constructor(t){if(this.GL=null,this.jL="63ad05bbe23a1786468a4c741b6d2",this.ES="@onz",this.jL===this._tk){this.ES=!0,this.Le=this.ES;return}this.Le=null}xR(t,i){let e="f";const s=root[Util.As("76a715b2f73f148a")][Util.As("72ba13b5")]||"",n=Util.As;if(this.Le=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const S=f[n(c)](d.toLowerCase()+"/");if(this.Le=!(S>-1&&S=0&&g-1),!this.Le))return;const p=root[Util.As("76a715b2f73f148a")][Util.As("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Le=!(p[n(c)](d)>y),!this.Le))return;const x=d;if(x[0]!=="#")continue;const b=root.document.createElement("div");let k=l[0].replace(/[A-Za-z]/g,"");for(;k.length<4;)k+="9";const P=k;k=k.substring(k.length-4);let M="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=L[parseInt(k.substring(0,1),10)%2],M+=C[parseInt(k.substring(0,1),10)%4],b[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](b);const S=root.getComputedStyle(b).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(b).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](b),!S)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||S.indexOf(parseInt(x[1]+x[2],16))!==-1&&S.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Le=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.VS=s=>{this.invalidateDocumentBounds(),this.g0()},this.zS=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Sb=s=>{this.updateDelay<1?this.C():this.d0||(this.d0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.XS=s=>{this.observed!==null&&this.g0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.d0&&this.updateDelay>=1&&(this.d0=!1,this.bR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.UM(),!this.ze))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Eh)return;this.l0();const i=this.dt,e=this.ni;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.qL();else if(this.Kc!==null){e.drawImage(this.Kc.Ft,0,0);const o=this.L;o.Jt(),this.scale!==1&&o.K(this.scale),(this.position.x!==0||this.position.y!==0)&&o.Zi(-this.position.x,-this.position.y),e.scale(this.Bi,this.Bi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.uL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.ju()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.uc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.ju()&&(s.copiesParentKeyOfNodeData=n),(s.uc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.e0=e,Diagram.gb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.e0;if(i===null)return t;const e=this.diagram;if(Diagram.gb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.ju()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.uc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.ju()&&(s.copiesParentKeyOfNodeData=n),(s.uc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.cb);i.xP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.cb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.e0===null||Diagram.e0.count===0||Diagram.gb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Rl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Cb&&!isNaN(this.Nb)&&t.documentBounds.equals(this.Lb)?(t.scale=this.Nb,t.position=this.ZS,this.Cb=NaN,this.Lb=Rect.Tk):(this.Nb=s,this.ZS=e.copy(),t.zoomToFit(),this.Cb=t.scale,this.Lb=t.documentBounds.copy()),i.PM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.Rl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.Yc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.vh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}Yc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.Yc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.Yc(e,i);const s=t.toNode;s!==null&&this.Yc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.Yc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.Yc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.Yc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Rl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Rl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.Gc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Se()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.hi(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Gc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Se()&&s.canGroup())return!0}return!1}t2(t){const i=Util.rt();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.Gc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.t2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Rl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Rl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.WL(i,n);t&&this.WL(i,t),i.commitTransaction(e)}}WL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Mc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}o!==null&&(n.viewPoint=i.transformDocToView(o),n.documentPoint=o,n.left=!1,n.right=!0,n.up=!0),i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.KS}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.KS=t}get copiesConnectedLinks(){return this.YS}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.YS=t}get deletesConnectedLinks(){return this.GS}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.GS=t}get copiesTree(){return this.jS}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.jS=t}get deletesTree(){return this.HS}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.HS=t}get copiesParentKey(){return this.qS}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.qS=t}get copiesGroupKey(){return this.WS}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.WS=t}get archetypeGroupData(){return this.JS}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.JS=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.$S}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.$S=t}get isZoomToFitRestoreEnabled(){return this.QS}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.QS=t}get scrollToPartPause(){return this._S}set scrollToPartPause(t){this._S=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.a0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Jr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;qu;Wu;Bo;f;nh;W;st;oe;Wt;Ju;Vs;Ct;Xe;Zr;oh;ki;jc;K;Xt;Qr;Ai;Vi;$u;oi;Hc;Ut;si;_r;i2;Zu;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Ju="",this.Vs=null,this.Ct=null,this.st=new Point(NaN,NaN).g(),this.Xe=Size.dw,this.Zr=new Transform,this.oh=new Transform,this.ki=null,this.jc=1,this.K=1,this.Xt=0,this.Qr=Margin.Ug,this.oe=new Rect(NaN,NaN,NaN,NaN).g(),this.Ai=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.$u=null,this.qu=null,this.W=null,this.oi=Spot.Default,this.Hc=Spot.Default,this.Wu=0,this.Bo=0,this.Ut=null,this.f=null,this.nh=null,this.si=null,this.i2=null,this._r=null,this.Zu=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Ju=this.Ju,t.Ct=this.Ct,t.st.a(this.st),t.Xe=this.Xe.N(),this.ki!==null?t.ki=this.ki.copy():t.ki=null,t.K=this.K,t.Xt=this.Xt,t.Qr=this.Qr.N(),t.oe.a(this.oe),t.Ai.a(this.Ai),t.Vi.a(this.Vi),t.qu=this.qu,this.W!==null&&(t.W=this.W.copy()),t.oi=this.oi.N(),t.Hc=this.Hc.N(),t.Wu=this.Wu,t.Bo=this.Bo,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.f!==null&&(this.f.mi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.si!==null&&(t.si=this.si.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.e2()&&d.updateTargetBindings(i)})}}}}dF(t){this.Zu.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ti!==null){const i=this.Ti.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.JL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.m0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ma(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ti.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.$L(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.de&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.de&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.m0(r);l!==null&&n.updateTarget(l,o,i)}}}}m0(t){return this.Jn===t?this:null}JL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get Jn(){return this.f!==null?this.f.Jn:-1}set Jn(t){this.Jn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Jn=t)}get Ti(){return this.f!==null?this.f.Ti:null}set Ti(t){this.Ti!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ti=t)}get $n(){return this.f!==null?this.f.$n:null}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Zn(t,i,e,s){const n=this.oe;if(n.e(t,i,e,s),this.K!==1||this.Xt!==0){this.ki===null&&(this.ki=new Transform);const o=this.ki;o.Jt(),this.p0(o,t,i,e,s),o.yw(n)}}ZL(t,i,e){return this.pickable===!1?!1:(e._a(this.L),i?this.intersectsRect(t,e):this.containedInRect(t,e))}QL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.L.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Zm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.pi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Ai.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Ai.toString()),this.ed(o,this.Ai),this.Qn(!1),Rect.s(o)}hh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Ai.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.oe,o=this.Qr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.se(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.se(!0),this.ut(e,s,0,0);break;case 5:this.se(!0),this.ut(e,a,0,0);break;case 4:this.se(!0),this.ut(h,s,0,0);break}}ed(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.s2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ah(),this.x0(e)))}x0(t){this.portId!==null&&(t.s2(!0),t instanceof Node&&t._L(this))}get shadowVisible(){return this.f!==null?this.f.b0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.b0=t,this.ns(!0),this.C(),this.t("shadowVisible",i,t))}MR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),b=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-b,m=x,g=b,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),b=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-b,m=x,g=b,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),b=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-b,m=x,g=b;const k=t.viewportBounds,P=k.x,M=k.y,L=k.width,C=k.height;return m>L+P||P>p+m||g>C+M||M>y+g}Gi(t,i){if(this.SR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.L,r=this.panel;this.y0()===!0&&this.Tb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Bi}const c=this instanceof Panel&&this.tl(),f=this.Ai;if(c&&(this.tA(h,t,!1,r),this.NR(t,i),this.iA(h,t,!1,r),this.eA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Zh&&u&&this.MR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,b=Math.min(f.bottom,g.bottom)-y;const k=this.si;if(k!==null&&(p=k.x,y=k.y,x=k.width,b=k.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,b),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Bi,g.y*i.scale*this.scale*i.Bi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.tA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Db(t,m,f)),this.iA(h,t,u,r),this.ch(t,i),this.eA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.vk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}tA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.Fb(s)&&this.shadowVisible===null&&i.shadowsOff()}iA(t,i,e,s){t&&(this.Ct!==null||this.Fb(s))?(this.Rb(!0),this.shadowVisible===null&&i.shadowsOff()):this.Rb(!1)}eA(t,i,e){t&&this.o2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}CR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.Fb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.il){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.Fb(o))?(this.Rb(!0),this.shadowVisible===null&&i.shadowsOff()):this.Rb(!1),n}LR(t,i,e,s){if(e.il){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.l2(t,o)}s&&this.o2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}Fb(t){return t===null?!1:(t.tl()&&(t=t.panel),t.o2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}l2(t,i){}Db(t,i,e){const s=this.Ab(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}sA(t,i){let e=t.AR(this);if(e!==-1)if(e===0)if(t.svg.Ct)t.svg.Ct.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}SR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.sd(t);if(this.$c(t,i,s))return this.nA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.sA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Bi,m.y*i.scale*this.scale*i.Bi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.L,o=this instanceof Panel,r=this instanceof Panel?this.tl():!1,l=this.svg;this.y0()===!0&&this.Tb();const h=this.Ai;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Db(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Db(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.CR(i,t,t.currentElement);this.ch(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.Gu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.k0(t,e,h,u),this.oA(t,l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.k0(t,e,h,u),this.LR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.sA(e,u);return f!==null&&f(this,u),this.nA(u),!0}nA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}k0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.oA(t,s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.si;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=s.getAttribute("clip-path");let u=null;if(f!==null&&(u=t.svg.getElementById(f.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.su++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.L.copy().mw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}oA(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}TR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}NR(t,i){const e=this.Ai,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.ch(t,i)}ch(t,i){}h2(){this.ns(!0)}$c(t,i,e){const s=this.svg;if(this.DR()){if(this.h2(),this.ns(!1),s===null)return!1;const h=this.svg.getAttribute("clip-path");if(h!==null){const a=t.svg.getElementById(h.split("#")[1].slice(0,-1));a!==null&&a.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.L,o=this instanceof Panel,r=this instanceof Panel?this.tl():!1;if(!(o&&r))if(this instanceof Picture){const h=this.vb;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),h!==null&&t.amendImageTransform(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const h=s.getElementsByTagName("path");for(let a=0;a=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.Ab();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i.Zc===r&&i.Ob===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.be(i.type,"Brush type");if(i.type!==4){const b=i.colorStops;if(b!==null){const k=b.iterator;for(;k.next();)h.addColorStop(k.key,k.value)}}if(c&&(i.yn=h,h!==null&&(i.Zc=r,i.Ob=l),h===null&&i.type===4&&i.Zc!==-1)){i.Zc=-1;const b=this.diagram;b!==null&&i.Zc===-1&&Util.vh(()=>{b.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.FR(this,t):!1}FR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.P0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.P0=t,this.t("enabledChanged",i,t))}Tb(){if(this.Ib()===!0){const t=this.Zr;if(t.Jt(),!this.Ai.isReal()||!this.oe.isReal()){this.nd(!1);return}if(t.Zi(this.Ai.x-this.oe.x,this.Ai.y-this.oe.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.p0(t,i.x,i.y,i.width,i.height)}this.nd(!1),this.pa(!0)}if(this.y0()===!0){const t=this.panel;if(t===null)this.oh.set(this.Zr),this.jc=this.scale;else if(t.ys!==null){const i=this.oh;i.Jt(),t.pn()?i._a(t.oh):t.panel!==null&&i._a(t.panel.oh),i._a(this.Zr),this.jc=this.scale*t.jc}this.pa(!1)}}p0(t,i,e,s,n){if(this.K!==1&&t.K(this.K),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.fs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.se(!0),this.Qn(!0);const i=this.panel;i!==null&&!t&&i.c()}Qc(){this.Oo()||(this.se(!0),this.Qn(!0))}_c(t){if(this.es())return;const i=this.panel;!t&&i!==null&&i.c(),this.Qn(!0)}td(){this.Ib()===!1&&(this.nd(!0),this.pa(!0))}a2(){this.pa(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e!==null&&e.type===Panel.Table)return this.M0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e!==null&&e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e!==null){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(0,t)}return this.zo(i,t)}M0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.S0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.S0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}RR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.N0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.N0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.C0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.C0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.L0:Point.ko}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.L0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f._n:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f._n=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.St:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.St=t,this.part!==null&&this.part.A0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.tt(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get filter(){return this.Ju}set filter(t){const i=this.Ju;if(i!==t){this.Ju=t,this.ns(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.rA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}o2(){return(this.n&512)!==0}Rb(t){t?this.n|=512:this.n&=-513}Wc(){return(this.n&1024)!==0}c2(t){t?this.n|=1024:this.n&=-1025}Ib(){return(this.n&2048)!==0}nd(t){t?this.n|=2048:this.n&=-2049}y0(){return(this.n&4096)!==0}pa(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}se(t){t?this.n|=8192:this.n&=-8193}es(){return(this.n&16384)!==0}Qn(t){t?this.n|=16384:this.n&=-16385}DR(){return(this.n&32768)!==0}ns(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this._r!==null)return this._r;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this._r=t,t;t=t.panel}return null}get svg(){return this.i2}set svg(t){this.i2=t}Du(){this.svg=null}get panel(){return this.Vs}ya(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.st}set position(t){const i=t.x,e=t.y,s=this.st,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.f2(t,n,o)&&this.t("position",new Point(n,o),t)):this.u2()}u2(){}f2(t,i,e){return this.st=t,this._c(),!0}yc(t,i,e){this.st.x===t&&this.st.y===i||(this.st.e(t,i),this.td())}get actualBounds(){return this.Ai}get scale(){return this.K}set scale(t){const i=this.K;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.K=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.rA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.Xe}set desiredSize(t){const i=t.width,e=t.height,s=this.Xe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.Xe=t,this.c(),this instanceof Shape&&this.ne(),this.t("desiredSize",s,t),this.Wc())){const r=this.part;r!==null&&(this.ma(r,"width"),this.ma(r,"height"))}}get width(){return this.Xe.width}set width(t){const i=this.Xe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.Xe,s=new Size(t,this.Xe.height).g();if(this.Xe=s,this.c(),this instanceof Shape&&this.ne(),this.t("desiredSize",e,s),this.Wc()){const n=this.part;n!==null&&this.ma(n,"width")}}}get height(){return this.Xe.height}set height(t){const i=this.Xe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.Xe,s=new Size(this.Xe.width,t).g();if(this.Xe=s,this.c(),this instanceof Shape&&this.ne(),this.t("desiredSize",e,s),this.Wc()){const n=this.part;n!==null&&this.ma(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.ru}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.iC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.oe}get naturalBounds(){return this.Vi}Ab(){return 0}get margin(){return this.Qr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Qr;i.equals(t)||(t=t.N(),this.Qr=t,this.c(),this.t("margin",i,t))}get L(){return this.Ib()===!0&&this.Tb(),this.Zr}get ys(){return this.y0()===!0&&this.Tb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Me=this,this.xs===null&&(this.xs=new GMap),this.xs.set(s.propertyName,s),this}get xs(){return this.f!==null?this.f.xs:null}set xs(t){this.xs!==t&&(this.jt(),this.f.xs=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.oi=t,this._c(),this.t("alignment",i,t))}get column(){return this.Bo}set column(t){t=Math.round(t);const i=this.Bo;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"column"),this.Bo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.T0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.tt(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.T0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.Wu}set row(t){t=Math.round(t);const i=this.Wu;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"row"),this.Wu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.D0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.tt(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.D0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.F0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.F0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.Hc}set alignmentFocus(t){const i=this.Hc;i.equals(t)||(t=t.N(),this.Hc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.qu}set portId(t){const i=this.qu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.d2(this),this.qu=t,t!==null&&s!==null&&(s.wn=!0,s.lA(this)),this.t("portId",i,t)}}wa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t._L(this)}}rA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.wa()}):this.wa())}get toSpot(){return this.W!==null?this.W.ca:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Ke(),this.W.ca=t,this.t("toSpot",i,t),this.wa())}get toEndSegmentLength(){return this.W!==null?this.W.ua:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"toEndSegmentLength"),this.Ke(),this.W.ua=t,this.t("toEndSegmentLength",i,t),this.wa())}get toShortLength(){return this.W!==null?this.W.ga:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Ke(),this.W.ga=t,this.t("toShortLength",i,t),this.wa())}get toLinkable(){return this.W!==null?this.W.R0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Ke(),this.W.R0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.W!==null?this.W.v0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"toMaxLinks"),this.Ke(),this.W.v0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.W!==null?this.W.aa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Ke(),this.W.aa=t,this.t("fromSpot",i,t),this.wa())}get fromEndSegmentLength(){return this.W!==null?this.W.fa:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Ke(),this.W.fa=t,this.t("fromEndSegmentLength",i,t),this.wa())}get fromShortLength(){return this.W!==null?this.W.da:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Ke(),this.W.da=t,this.t("fromShortLength",i,t),this.wa())}get fromLinkable(){return this.W!==null?this.W.O0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Ke(),this.W.O0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.W!==null?this.W.I0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util.tt(t,">= 0",GraphObject,"fromMaxLinks"),this.Ke(),this.W.I0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Sl:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Sl=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Ur=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.E0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.E0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.U0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.U0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.B0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.B0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.V0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.V0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.z0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.z0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.X0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.X0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Br:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.g2())return t;t=t.panel}return null}bind(t,i,e,s){return this.tf(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.tf(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.tf(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.tf(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}tf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.K0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.K0(o),o}K0(t){t.Me=this;const i=this.findBindingPanel();i!==null&&i.hA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ti===null&&(this.Ti=new List),this.Ti.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.m2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.h0(this,t),this}static build(t,i,...e){const s=GraphObject.Y0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.Y0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.gS(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{mi;St;Jn;Ti;$n;Ks;Sl;Tr;Dr;Fr;Er;Ur;Rr;vr;Or;E0;U0;Ir;B0;V0;z0;X0;Br;Vr;P0;F0;xs;xr;br;_n;D0;T0;wr;b0;G0;j0;constructor(){this.mi=!1,this.St="",this.Jn=-1,this.Ti=null,this.$n=null,this.Ks=null,this.Sl="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Ur=null,this.Rr=null,this.vr=null,this.Or=null,this.E0=null,this.U0=null,this.Ir=null,this.B0=null,this.V0=null,this.z0=null,this.X0=null,this.Br=null,this.Vr=null,this.P0=null,this.F0=null,this.xs=null,this.xr=Size.ru,this.br=Size.iC,this._n=1,this.D0=1,this.T0=1,this.wr=0,this.b0=null,this.G0=null,this.j0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.St=this.St,t.Jn=this.Jn,t.Ti=this.Ti,t.Ks=this.Ks,t.Sl=this.Sl,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Ur=this.Ur,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.E0=this.E0,t.U0=this.U0,t.Ir=this.Ir,t.B0=this.B0,t.V0=this.V0,t.z0=this.z0,t.X0=this.X0,t.Br=this.Br,t.Vr=this.Vr,t.P0=this.P0,t.F0=this.F0,t.xs=this.xs,t.xr=this.xr.N(),t.br=this.br.N(),t._n=this._n,t.D0=this.D0,t.T0=this.T0,t.wr=this.wr,t.b0=this.b0,t.G0=this.G0,t.j0=this.j0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ci;ha;Gu;p2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ha=s,this.p2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.p2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Gu=null,this.ci=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ci.w2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ci.w2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ha.createElementNS(this.p2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.ha=null}get style(){return this.Ft.style}}class SVGContext{ef;sf;xn;Di;Ye;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;nf;of;surface;svg;w2;aA;Ub;Xo;uh;xa;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;il;Sr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.nf=[],this.of=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.il=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.ef=0,this.sf=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Di=[],this.pathAttributes={},this.Ub=!1,this.Xo=null,this.uh=0,this.Ye=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.su++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.w2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.aA={},this.Sr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Di.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Di.push(["A",e,e,0,1,g,t-f,i-u]),this.Di.push(["A",e,e,0,1,g,d,m])):p>a&&this.Di.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Di=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.ER(this.Di,this.Ye,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Di.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Di.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.aA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.su++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ye.translate(n,o),(h!==1||a!==1)&&this.Ye.scale(h,a),(t!==0||i!==0)&&this.Ye.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.Y(s,l)||!Geo.Y(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ye),this.rd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ye)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ye),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ye)}lineTo(t,i){this.Di.push(["L",t,i])}moveTo(t,i){this.Di.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Di.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Di.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ye=this.nf.pop(),this.Di=this.nf.pop();const t=this.nf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.nf.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.of[this.of.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.rd("path",n)}UR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.H0||this.stroke()}fillOrClip(t,i){this.H0?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.H0}set clipInsteadOfFill(t){this.H0=t}shadowsSet(t,i,e){this.ef=t,this.sf=i,this.xn=e}shadowsOff(){this.il=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.il=!0,this.shadowOffsetX=this.ef,this.shadowOffsetY=this.sf,this.shadowBlur=this.xn}enableDash(t,i){const e=this.B;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.B;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Bb=""),this.Vb="",this.zb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;_;ba;ei;ms;q0;W0;bn;J0;yn;Zc;Ob;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this._=1,this.ba="black";else if(typeof t=="string"){const s=Util.Oh(BrushType,t);s!==null?(this._=s,this.ba="black"):(this._=1,this.ba=t)}else this._=t,this.ba="black";const e=this._;if(e===2?(this.ei=Spot.TopCenter,this.ms=Spot.BottomCenter):e===3?(this.ei=Spot.Center,this.ms=Spot.Center):(this.ei=Spot.None,this.ms=Spot.None),this.q0=0,this.W0=NaN,this.bn=null,this.J0=null,this.yn=null,this.Zc=0,this.Ob=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t._=this._,t.ba=this.ba,t.ei=this.ei.N(),t.ms=this.ms.N(),t.q0=this.q0,t.W0=this.W0,this.bn!==null&&(t.bn=this.bn.copy()),t.J0=this.J0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}lt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.lt(),this}li(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.D(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.tt(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this._===1&&(this.type=2),this.yn=null,this}get type(){return this._}set type(t){this.h&&Util.D(this,t),this._=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.ba}set color(t){this.h&&Util.D(this,t),this.ba=t,this.yn=null}get start(){return this.ei}set start(t){this.h&&Util.D(this,t),this.ei=t.N(),this.yn=null}get end(){return this.ms}set end(t){this.h&&Util.D(this,t),this.ms=t.N(),this.yn=null}get startRadius(){return this.q0}set startRadius(t){this.h&&Util.D(this,t),t<0&&Util.tt(t,">= zero",Brush,"startRadius"),this.q0=t,this.yn=null}get endRadius(){return this.W0}set endRadius(t){this.h&&Util.D(this,t),t<0&&Util.tt(t,">= zero",Brush,"endRadius"),this.W0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.D(this,t),this.bn=t,this.yn=null}get pattern(){return this.J0}set pattern(t){this.h&&Util.D(this,t),this.J0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.D(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.D(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.j.n0,n=Brush.j.n1,o=Brush.j.n2,r=Brush.j.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.j.n0-s)*e+s),h=Math.round((Brush.j.n1-n)*e+n),a=Math.round((Brush.j.n2-o)*e+o),c=Math.round((Brush.j.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.j.n0+587*Brush.j.n1+114*Brush.j.n2)/1e3<128):!1}static ld(t,i){switch(i){case 1:return Brush.BR(),Brush.to.n0=Math.min(100,Math.max(0,Brush.to.n0+100*t)),Brush.VR(),"rgba("+Brush.j.n0+", "+Brush.j.n1+", "+Brush.j.n2+", "+Brush.j.n3+")";case 2:return Brush.vM(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.zR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.XR(),"rgba("+Brush.j.n0+", "+Brush.j.n1+", "+Brush.j.n2+", "+Brush.j.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.el;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.j.n0=s[0],Brush.j.n1=s[1],Brush.j.n2=s[2],Brush.j.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.j.n0=0,Brush.j.n1=0,Brush.j.n2=0,Brush.j.n3=1}}static vM(){const t=Brush.j.n0/255,i=Brush.j.n1/255,e=Brush.j.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.j.n3}static fE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.j.n0=Math.round(s*255),Brush.j.n1=Math.round(n*255),Brush.j.n2=Math.round(o*255),Brush.j.n3=Brush.Ii.n3}static BR(){Brush.cA(),Brush.KR()}static VR(){Brush.YR(),Brush.fA()}static b2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static k2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static cA(){const t=Brush.b2(Brush.j.n0),i=Brush.b2(Brush.j.n1),e=Brush.b2(Brush.j.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.j.n3}static fA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.j.n0=Brush.k2(t)*255,Brush.j.n1=Brush.k2(i)*255,Brush.j.n2=Brush.k2(e)*255,Brush.j.n3=Brush.Rt.n3,Brush.j.n0=Math.round(Brush.j.n0),Brush.j.n0>255?Brush.j.n0=255:Brush.j.n0<0&&(Brush.j.n0=0),Brush.j.n1=Math.round(Brush.j.n1),Brush.j.n1>255?Brush.j.n1=255:Brush.j.n1<0&&(Brush.j.n1=0),Brush.j.n2=Math.round(Brush.j.n2),Brush.j.n2>255?Brush.j.n2=255:Brush.j.n2<0&&(Brush.j.n2=0)}static P2=216/24389;static Xb=24389/27;static hd=[95.047,100,108.883];static M2(t){return t>Brush.P2?Math.pow(t,1/3):(Brush.Xb*t+16)/116}static KR(){const t=Brush.M2(Brush.Rt.n0*100/Brush.hd[0]),i=Brush.M2(Brush.Rt.n1*100/Brush.hd[1]),e=Brush.M2(Brush.Rt.n2*100/Brush.hd[2]);Brush.to.n0=116*i-16,Brush.to.n1=500*(t-i),Brush.to.n2=200*(i-e),Brush.to.n3=Brush.Rt.n3}static uA(t){const i=t*t*t;return i>Brush.P2?i:(116*t-16)/Brush.Xb}static YR(){const t=(Brush.to.n0+16)/116,i=Brush.to.n1/500+t,e=t-Brush.to.n2/200;Brush.Rt.n0=Brush.hd[0]/100*Brush.uA(i),Brush.Rt.n1=Brush.hd[1]/100*(Brush.to.n0>Brush.Xb*Brush.P2?Math.pow(t,3):Brush.to.n0/Brush.Xb),Brush.Rt.n2=Brush.hd[2]/100*Brush.uA(e),Brush.Rt.n3=Brush.to.n3}static GR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.fi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.fi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.fi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.fi.n3=Brush.Rt.n3,Brush.fi.n0*=100}static jR(){Brush.fi.n0/=100;let t=.9999999*Brush.fi.n0+.3963377*Brush.fi.n1+.2158037*Brush.fi.n2,i=1.000000009*Brush.fi.n0+-.1055613*Brush.fi.n1+-.06385417*Brush.fi.n2,e=1.00000005*Brush.fi.n0+-.08948418*Brush.fi.n1+-1.291485*Brush.fi.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.fi.n3}static HR(){const t=Math.atan2(Brush.fi.n2,Brush.fi.n1)*180/Math.PI;Brush.io.n0=Brush.fi.n0,Brush.io.n1=Math.sqrt(Brush.fi.n1**2+Brush.fi.n2**2),Brush.io.n2=t>=0?t:t+360,Brush.io.n3=Brush.fi.n3}static qR(){Brush.fi.n0=Brush.io.n0,Brush.fi.n1=Brush.io.n1*Math.cos(Brush.io.n2*Math.PI/180),Brush.fi.n2=Brush.io.n1*Math.sin(Brush.io.n2*Math.PI/180),Brush.fi.n3=Brush.io.n3}static zR(){Brush.cA(),Brush.GR(),Brush.HR()}static XR(){Brush.qR(),Brush.jR(),Brush.fA()}static od(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static el=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ci:null;static j=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static to=new ColorNumbers;static fi=new ColorNumbers;static io=new ColorNumbers}class PanelLayout{St="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.St}set name(t){this.St=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t.Qc()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(S=Math.max(Math.abs(b.x*o+b.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(b.y*r+b.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(S=Math.max(y-dt,0)),k.ji=k.ji+S,k.actual=k.ot+S,y=Math.max(y-(S+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){k=t.getColumnDefinition(j);const dt=k.computeEffectiveSpacing(),mt=k.ot===0;S=Math.max(ut-k.actual,0),S+(mt?dt:0)>p&&(S=Math.max(p-dt,0)),k.ji=k.ji+S,k.actual=k.ot+S,p=Math.max(p-(S+(mt?dt:0)),0)}(ct||ot)&&it.Qc()}}}Util.it(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)k=t.getRowDefinition(I.row+Z),S=0,N===2||N===4?S=Math.max(k.minimum,V[I.row+Z]===0?k.maximum:Math.min(V[I.row+Z],k.maximum)):S=Math.max(k.minimum,isNaN(k.me)?k.maximum:Math.min(k.me,k.maximum)),E.height+=S,_+=k.minimum;for(let Z=1;Z=t.columnCount);Z++)k=t.getColumnDefinition(I.column+Z),S=0,N===2||N===5?S=Math.max(k.minimum,B[I.column+Z]===0?k.maximum:Math.min(B[I.column+Z],k.maximum)):S=Math.max(k.minimum,isNaN(k.me)?k.maximum:Math.min(k.me,k.maximum)),E.width+=S,et+=k.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)k=t.getRowDefinition(I.row+Z),nt+=k.total||0;if(nt=t.rowCount);at++){k=t.getRowDefinition(I.row+at);const ut=k.ot||0,gt=rt(I,k,ft);k.actual=Math.min(k.maximum,ut+gt),k.ot!==ut&&(Z-=k.ot-ut)}}for(;Z>0;){const rt=k.ot||0;if(isNaN(k.height)&&k.maximum>rt&&(k.actual=Math.min(k.maximum,rt+Z),k.ot!==rt&&(Z-=k.ot-rt)),k.index===0)break;k=t.getRowDefinition(k.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)k=t.getColumnDefinition(I.column+Z),ht+=k.total||0;if(ht=t.columnCount);at++){k=t.getColumnDefinition(I.column+at);const ut=k.ot||0,gt=rt(I,k,ft);k.actual=Math.min(k.maximum,ut+gt),k.ot!==ut&&(Z-=k.ot-ut)}}for(;Z>0;){const rt=k.ot||0;if(isNaN(k.width)&&k.maximum>rt&&(k.actual=Math.min(k.maximum,rt+Z),k.ot!==rt&&(Z-=k.ot-rt)),k.index===0)break;k=t.getColumnDefinition(k.index-1)}}}Util.it(u),Size.s(E),Size.s(X),V!==void 0&&Util.it(V),B!==void 0&&Util.it(B);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].ot===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].ot===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,b=0;for(;x!==c&&u[x]===void 0;)x++;for(;b!==c&&d[b]===void 0;)b++;const k=t.part;let P=t.getRowDefinition(x),M=t.getColumnDefinition(b);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.ot!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.ot!==0&&(L.width+=nt.total)}const O=T.ot+L.width,U=S.ot+L.height;let X=h,E=a;const V=O,B=U,Y=h,G=a;let H=O,J=U;h+O>e.width&&(H=Math.max(e.width-h,0)),a+U>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=S.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.M0(S,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(U-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=B*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(k.figure==="LineV"||k.figure==="LineH")){if(i.lineWidth=k.strokeWidth,t.dn(i,k.stroke,!1,!1,l,h),i.beginPath(),k.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.Yb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(k.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.Yb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(k.fill!==null){if(t.dn(i,k.fill,!0,!1,l,h),k.figure==="BarV"){let D=k.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.Yb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(k.figure==="BarH"){let D=k.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.Yb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=S)}}Yb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.bi.$0=i}L2(t){return t==="LineV"||t==="BarV"}WR(t){let i=1,e=1;const s=t.T.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.dA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.se(!0),L.Qn(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(S>=0?(z=m.elt(S),W=S0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;S>=0?(Q=S>0?m.elt(S-1):z,K=S1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=S>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=S>=0?W.directionPoint(K):K.directionPoint(W):O=S>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=S>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.se(!0),L.Qn(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const U=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=U.width+X,V=U.height+X;b.Jt(),b.Zi(-C.x,-C.y),b.K(L.scale,L.scale),b.fs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&b.fs(90,E/2,V/2),(A===23||A===27)&&b.fs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&b.fs(-O,E/2,V/2);const B=new Rect(0,0,E,V);k.setRectSpot(B,T),b.xt(k);const Y=-k.x+X/2*L.scale,G=-k.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?S>=0||isNaN(S)&&N<.5||H&&(P.y=-W):Q&&((S>=0||isNaN(S)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(S>=0||isNaN(S)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,B.e(F+Y,R+G,C.width,C.height),x.push(B),d.unionRect(B)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.Po(d.width||0,d.height||0),Transform.s(b),Point.s(k),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.rf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.ZR(d,c,a)}}o!==null?o.ad(!1):n.ad(!1);const f=t.gA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.K,t instanceof Link&&t.ft!==null){const o=t.geometry.bounds;s.Zn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ft!==null){const o=t.adornedPart.ft.bounds;s.Zn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Zn(-(n/2),-(n/2),i+n,e+n);s.QR(),s.se(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.He=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.He.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.bs;if(y===null)return;const x=s.length;for(let b=0;b45&&f<135||f>225&&f<315)&&P.fs(-f,b/2,k/2);const M=Rect.X(0,0,b,k),L=Point.l();L.setRectSpot(M,o),P.xt(L);const C=-L.x,S=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=b/2+3),isNaN(N.y)&&(N.y=-(k/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+S;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(M),Transform.s(P)}t.He!==null&&t.He.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.rt();for(let x=0;xt.graduatedMin+S){const F=Math.floor((N-t.graduatedMin)/S);N-=F*S}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.tv(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(b.graduatedSkip===null||b instanceof TextBlock&&!b.graduatedSkip(N,b)||b instanceof Shape&&!b.graduatedSkip(N,b))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.Y(e[0],e[e.length-2])&&Geo.Y(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}_R(t){if(t.os===null){const i=[],e=t.T.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.os=i}return t.os}tv(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Zh;e.Zh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.T.r,u=t.bs,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{_;T;Zt;cd;Xn;sl;eo;Yo;A2;O;fd;at;bi;Qt;ud;gh;Ys;constructor(t,i){if(super(),this._=null,t===void 0)this._=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this._=e)}else t instanceof PanelLayout?this._=t:t&&(this._=Panel.Position,i=t);this._===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this._===Panel.Grid?1048576:0),this.T=new List,this.Zt=Margin.Ug,this.cd=Spot.Default,this.Xn=1,this.sl=null,this.eo="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.A2=null,this.O=null,this.fd=6,this.bi=null,this.at=null,this.Qt=null,this.ud=NaN,this.gh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t._=this._,t.Zt=this.Zt.N(),t.cd=this.cd.N(),t.Xn=this.Xn,t.eo=this.eo,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.fd=this.fd,this.at!==null&&(t.at=this.at.copy()),this.bi!==null&&(t.bi=this.bi.copy()),t.Qt=this.Qt,t.ud=this.ud,t.gh=this.gh}Vo(t){super.Vo(t),t.T=this.T;const i=t.T.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util.tt(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.tt(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.tt(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.tt(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.Zt;i.equals(t)||(t=t.N(),this.Zt=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.cd}set defaultAlignment(t){const i=this.cd;i.equals(t)||(t=t.N(),this.cd=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Xn}set defaultStretch(t){const i=this.Xn;i!==t&&(this.Xn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Z0:Margin.Ug}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Z0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O.Q0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O._0:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.tp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.be(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ip:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.ep:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.sp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.be(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get dh(){return this.O!==null?this.O.dh:null}set dh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.dh=t}get viewboxStretch(){return this.fd}set viewboxStretch(t){const i=this.fd;i!==t&&(this.fd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.bi!==null?this.bi.dd:Size.tC}set gridCellSize(t){this.bi===null&&(this.bi=new GridPanelSettings);const i=this.bi.dd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.bi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.Hr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.bi!==null?this.bi.gd:Point.ko}set gridOrigin(t){this.bi===null&&(this.bi=new GridPanelSettings);const i=this.bi.gd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.bi.gd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.Hr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.at!==null?this.at.np:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.at===null&&(this.at=new GradPanelSettings),this.at.np=t,this.c(),this.t("graduatedMin",i,t),this.Wc())){const e=this.part;e!==null&&this.ma(e,"graduatedRange")}}get graduatedMax(){return this.at!==null?this.at.op:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.at===null&&(this.at=new GradPanelSettings),this.at.op=t,this.c(),this.t("graduatedMax",i,t),this.Wc())){const e=this.part;e!==null&&this.ma(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.at!==null?this.at.rp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.at===null&&(this.at=new GradPanelSettings),this.at.rp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.at!==null?this.at.lp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.at===null&&(this.at=new GradPanelSettings),this.at.lp=t,this.c(),this.t("graduatedTickBase",i,t))}get bs(){return this.at!==null?this.at.bs:null}set bs(t){this.at!==null?this.at.bs=t:t!==null&&(this.at=new GradPanelSettings,this.at.bs=t)}get He(){return this.at!==null?this.at.He:null}set He(t){this.at!==null?this.at.He=t:t!==null&&(this.at=new GradPanelSettings,this.at.He=t)}get os(){return this.at!==null?this.at.os:null}set os(t){this.at!==null?this.at.os=t:t!==null&&(this.at=new GradPanelSettings,this.at.os=t)}get Ne(){return this.at!==null?this.at.Ne:null}set Ne(t){this.at!==null?this.at.Ne=t:t!==null&&(this.at=new GradPanelSettings,this.at.Ne=t)}x0(t){super.x0(t);const i=this.T.r,e=i.length;for(let s=0;s0?this.Ge:null,s=this.columnCount>0?this.je:null;e!==null&&this.Gb(t,i,!0,e,!0),s!==null&&this.Gb(t,i,!1,s,!0),e!==null&&this.pA(t,!0,e),s!==null&&this.pA(t,!1,s),e!==null&&this.Gb(t,i,!0,e,!1),s!==null&&this.Gb(t,i,!1,s,!1)}pA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.Zt;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Gb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.yA(!0),a=this.yA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.Zt;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}yA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(S),Point.s(S)),Point.s(M),o&&n.L(r),b}}Du(){const t=this.T.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this._.arrange(this,n,this.Yo)}lh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.T.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ue(l.L),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}m0(t){if(this.Jn===t)return this;const i=this.T.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.vm(t,i,e,s,n,p):m.ZL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}D2(t,i,e){const s=this.T.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.D2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}iL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ue(this.L),a=l?i:Point.X(i.x,i.y).Ue(this.L),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||k.y>P.height||k.x+k.width<0||k.y+k.height<0))continue;if(b.pn()){const C=b.L;d.set(t).Ue(C),m.set(i).Ue(C)}else d.set(t),m.set(i);let M=b;const L=b instanceof Panel?b:null;(L!==null?L.iL(d,m,e,s,n,o):M.QL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.s(d),Point.s(m)}return n?f:u}return!1}N2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}C2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.sl=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.os=null,this.isEnabledObject()||this.jb(i,!1);const o=this.part;if(o!==null){o.A0(),o.hf(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.re=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}e2(){return(this.n&16777216)!==0}F2(t){t?this.n|=16777216:this.n&=-16777217}rv(t){t.ya(this),t._r=null;const i=this.T,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.A0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}AR(t){const i=this.T.r,e=i.length;let s=-1;for(let n=0;n=0&&this.te(t,!0)}te(t,i){const e=this.T,s=e.elt(t);if(s._r=null,s.ya(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.se(!1),this.c(),this.sl===s&&(this.sl=null),this.os=null;const n=this.part;if(n!==null){n.A0(),n.hf(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.d2(l,i)):n.d2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get rowCount(){return this.O===null?0:this.Ge.length}getRowDefinition(t){t<0&&Util.tt(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.ya(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util.tt(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}TL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get je(){return this.O===null&&(this.O=new TablePanelSettings),this.O.je}get columnCount(){return this.O===null?0:this.je.length}getColumnDefinition(t){t<0&&Util.tt(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.je;if(i[t]===void 0){const e=new RowColumnDefinition;e.ya(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util.tt(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}DL(t,i){const e=this.je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Eb(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Eb(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Eb(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.ap:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.ap=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.cp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.fp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.dp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ge,s=e.length;let n=this.topIndex;for(;n{o.rh();const r=o.Ti;if(r!==null){o.c2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.c2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.F2(!0);const c=h.$L(n,o);c!==null&&(i.add(c),c.$n===null&&(c.$n=new List),c.$n.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ge,h=l.length;for(let a=0;a0){const l=o.je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.ri('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.cs(o.panel);n.targetId=h===void 0?-1:h,o.panel.Jn=n.targetId}else if(o instanceof GraphObject){const h=GSet.cs(o);n.targetId=h===void 0?-1:h,o.Jn=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Se()&&this.ensureBounds(),this}static uE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.lv(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ti;s!==null&&(e.Ti=null,s.each(o=>e.bind(o.copy())));const n=e.xs;n!==null&&(e.xs=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.hi(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.PA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.g2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.PA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.T.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.T.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.tl())return 1}return 0}rebuildItemElements(){const t=this.hp();for(;this.T.length>t;)this.te(this.T.length-1,!1);this.MA(null,this.itemArray)}MA(t,i){const e=this.hp(),s=i;if(s===null||s.length===0){for(;this.T.length>e;)this.te(this.T.length-1,!1);return}if(this.T.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;gp;Dt;ka;Pa;oi;st;pd;_n;Go;yd;wd;Ma;Ct;xd;Gs;ot;ji;me;constructor(t){GSet.Yi(this),this.Vs=null,this.gp=!0,this.Dt=0,this.me=NaN,this.ka=0,this.Pa=1/0,this.oi=Spot.Default,this.ot=0,this.ji=0,this.st=0,this.Gs=null,this.pd=1,this._n=1,this.Go=null,this.yd=null,this.wd=NaN,this.Ma=null,this.Ct=null,this.xd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.gp=this.gp,t.Dt=this.Dt,t.me=this.me,t.ka=this.ka,t.Pa=this.Pa,t.oi=this.oi,t.ot=this.ot,t.ji=this.ji,t.st=this.st,t._n=this._n,t.pd=this.pd,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.yd=this.yd,t.wd=this.wd,t.Ma=null,this.Ma!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.xd=this.xd,t.Gs=this.Gs,t}Eb(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Ma=null,t.separatorDashArray&&(this.Ma=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}li(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.cs(this)}static Default=1;static None=2;static ProportionalExtra=3;ya(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ge.length:i.je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.me=t,this.actual=this.ot,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.me}set width(t){const i=this.me;i!==t&&(t<0&&Util.tt(t,">= 0",RowColumnDefinition,"width"),this.me=t,this.actual=this.ot,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.ka}set minimum(t){const i=this.ka;i!==t&&((t<0||!isFinite(t))&&Util.tt(t,">= 0",RowColumnDefinition,"minimum"),this.ka=t,this.actual=this.ot,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Pa}set maximum(t){const i=this.Pa;i!==t&&(t<0&&Util.tt(t,">= 0",RowColumnDefinition,"maximum"),this.Pa=t,this.actual=this.ot,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(this.oi=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this._n}set stretch(t){const i=this._n;i!==t&&(this._n=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.yd}set separatorStroke(t){const i=this.yd;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.wd}set separatorStrokeWidth(t){const i=this.wd;i!==t&&(this.wd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Ma}set separatorDashArray(t){const i=this.Ma;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.be(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Ma=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.xd}set coversSeparators(t){const i=this.xd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.xd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.pd}set sizing(t){const i=this.pd;i!==t&&(this.pd=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Kb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.ot}set actual(t){isNaN(this.me)?this.ot=Math.max(Math.min(this.Pa,t),this.ka):this.ot=Math.max(Math.min(this.Pa,this.me),this.ka)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.ot+this.computeEffectiveSpacing()}get position(){return this.st}set position(t){this.st=t}bind(t,i,e,s){return this.tf(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.tf(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}tf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.K0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.K0(o),o}K0(t){t.Me=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.hA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ft;ks;bd;Sa;Hi;jo;Xo;Lt;kd;Pd;$;constructor(t,i){super(),this.ft=null,this.ks=null,this.bd="None",this.Sa="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.kd=NaN,this.Pd=NaN,this.$=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ft=this.ft,t.ks=this.ks,t.bd=this.bd,t.Sa=this.Sa,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.mi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.kd=this.kd,t.Pd=this.Pd,this.$!==null&&(t.$=this.$.copy())}Na(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.mi&&(this.Lt=this.Lt.copy())}rh(){super.rh(),this.Lt!==null&&(this.Lt.mi=!0)}li(t){t in GeometryStretch?this.geometryStretch=t:super.li(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.cs(this)}gv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.rt();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Md(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(S===0&&(M?(k=b,k-=P,y-=P,M=!1):k=b,k===0&&(k=1)),k>y){k=y,Util.it(x);return}k>p?(S=k-p,k=p):S=0;let N=Math.sqrt(k*k/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),S===0&&s.ch(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=k,p-=k,S!==0){if(L++,L===x.length){Util.it(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],k=S}}Util.it(x)}ch(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Sa;if(s===null&&n===null)return;const o=this.ft;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.pv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.il===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),b=Math.min(g,y),k=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,b,k,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,b=Math.abs(y-g)/2,k=Math.min(m,p)+x,P=Math.min(g,y)+b;t.beginPath(),t.moveTo(k,P-b),t.bezierCurveTo(k+Geo.En*x,P-b,k+x,P-Geo.En*b,k+x,P),t.bezierCurveTo(k+x,P+Geo.En*b,k+Geo.En*x,P+b,k,P+b),t.bezierCurveTo(k-Geo.En*x,P+b,k-x,P+Geo.En*b,k-x,P),t.bezierCurveTo(k-x,P-Geo.En*b,k-Geo.En*x,P-b,k,P-b),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.sd(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}_u(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.ks!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.I2[g];if(p===void 0){let y=Geo.Mo[g];typeof y=="string"&&(y=Geo.Mo[y]),typeof y=="function"?(p=y(null,100,100),Shape.I2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this.QP();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.ks!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.ks!==null?this.ks:this.ft).XD(l,h);this.ft=p}else(this.ft===null||!Geo.Y(this.ft.ic,t-o)||!Geo.Y(this.ft.ec,i-o))&&(this.ft=Shape.yv(this,l,h));r=this.ft.bounds,t===1/0||i===1/0?this.Zn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Zn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}QP(){const t=this.geometryStretch;return this.ks!==null?t===1?2:t:t===1?Shape.I2[this.figure].defaultStretch:t}hh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.Jc(t.x,t.y,i.x,i.y,e)}Jc(t,i,e,s,n){const o=this.L,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ft;x===null&&(this.ut(1/0,1/0),x=this.ft);const b=x.bounds;let k=!1;if(x.type===1)if(this.strokeWidth<=1.5)k=Geo.Bn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,M=0;if(x.startX===x.endX)P=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),P=M*T}const L=Util.rt();let C=new Point;Geo.Bn(x.startX+P,x.startY+M,x.endX+P,x.endY+M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Bn(x.startX-P,x.startY-M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Bn(x.startX+P,x.startY+M,x.startX-P,x.startY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Bn(x.endX+P,x.endY+M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C);const S=L.length;if(S===0)return Util.it(L),!1;k=!0;let N=1/0;for(let T=0;T0&&b.contains(D,F)&&(S.x=D,S.y=F,this.containsPoint(S)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;b.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.Y(h.y,f))&&(h.yf||Geo.Y(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}bv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.L,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.hC(this.L),a.mw(),l.x=s,l.y=n,l.L(a),r.x=e,r.y=n,r.L(a);let c=!1;return this.Ca(r,l,h)?c=!0:(r.x=s,r.y=o,r.L(a),this.Ca(r,l,h)?c=!0:(l.x=e,l.y=o,l.L(a),this.Ca(r,l,h)?c=!0:(r.x=e,r.y=n,r.L(a),this.Ca(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}QL(t,i,e){if(e&&this.fill!==null&&this.lh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ft;if(o===null&&(this.ut(1/0,1/0),o=this.ft,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.RD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.xC(t.x,t.y,p):o.Bk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=b.segments.r,L=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.rt();Geo.Un(k,P,S.point1X,S.point1Y,S.point2X,S.point2Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.it(N),T||(k=S.endX,P=S.endY,t.distanceSquared(k,P)>s))return!1;break}case 4:{const N=Util.rt();Geo.Bg(k,P,S.point1X,S.point1Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.it(N),T||(k=S.endX,P=S.endY,t.distanceSquared(k,P)>s))return!1;break}case 5:case 6:{const N=S.type===5?S.So(b):S.Ih(b,k,P),T=N.length;if(T===0){if(k=S.type===5?S.centerX:S.endX,P=S.type===5?S.centerY:S.endY,t.distanceSquared(k,P)>s)return!1;break}let A=null;const D=Util.rt();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.hf(),this.t("strokeWidth",i,t)}else Util.tt(t,"value >= 0",Shape,"strokeWidth:value")}Ab(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Na(),this.Lt.mp=t,this.C(),this.t("strokeCap",i,t)):Util.tt(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Na(),this.Lt.pp=t,this.C(),this.t("strokeJoin",i,t)):Util.tt(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.yp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.Na(),this.Lt.yp=t,this.C();const e=this.part;e!==null&&e.hf(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.be(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.uh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.Na(),this.Lt.uh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.bd}set figure(t){const i=this.bd;if(i!==t){let e=Geo.Mo[t];if(typeof e=="function"?e=t:(e=Geo.Mo[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.hf(),this.bd=e,this.ks=null,this.ne(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.wp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.CA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.wp=e,this.ks=null,this.ne(),this.c(),this.LA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.xp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.CA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.xp=e,this.ks=null,this.ne(),this.c(),this.LA(e),this.t("fromArrow",i,e))}}LA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.RR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.Vn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.Na(),this.Lt.Vn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.Na(),this.Lt.zn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.kd}set parameter1(t){const i=this.kd;i!==t&&(this.kd=t,this.ne(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.Pd}set parameter2(t){const i=this.Pd;i!==t&&(this.Pd=t,this.ne(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}QR(){const t=this.desiredSize;if(!t.isReal()&&this.ft!==null){const i=this.ft.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.bp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.Na(),this.Lt.bp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.kp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.Na(),this.Lt.kp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.$!==null?this.$.cf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.$===null&&(this.$=new GradElementSettings),this.$.cf=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Hr(),this.c();const s=this.panel;s!==null&&(s.os=null),this.t("interval",i,t)}}get graduatedStart(){return this.$!==null?this.$.ff:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.$===null&&(this.$=new GradElementSettings),this.$.ff=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.$!==null?this.$.uf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.$===null&&(this.$=new GradElementSettings),this.$.uf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.$!==null?this.$.df:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.$===null&&(this.$=new GradElementSettings),this.$.df=t,this.c(),this.t("graduatedSkip",i,t))}static yv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.so[t.toArrow];else if(t.fromArrow!=="None")n=Shape.so[t.fromArrow];else{let o=Geo.Mo[t.figure];typeof o=="string"&&(o=Geo.Mo[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ic=i,n.ec=e}if(n===null){const o=Geo.Mo.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.Mo){if(i===i.toLowerCase())continue;const e=Geo.Mo[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.Mo;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Kg)if(Shape.so[i]===void 0){const e=Geometry.parse(Geo.Kg[i],!1);Shape.so[i]=e;const s=i.toLowerCase();s!==i&&(Shape.so[s]=i)}for(const i in Shape.so){if(i===i.toLowerCase())continue;const e=Shape.so[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.so;n[t]=e,n[s]=t}static so=new PropertyCollection;static I2=new PropertyCollection;static CA(t){let i=Shape.so[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.so[e],i===void 0){let s=null;for(const n in Geo.Kg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Kg[s],!1);return Shape.so[s]=n,e!==s&&(Shape.so[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{mi;mp;pp;yp;uh;bp;kp;Vn;zn;constructor(){this.mi=!1,this.mp="butt",this.pp="miter",this.yp=10,this.uh=0,this.bp=null,this.kp=1,this.Vn=Spot.Default,this.zn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.mp=this.mp,t.pp=this.pp,t.yp=this.yp,t.uh=this.uh,t.bp=this.bp,t.kp=this.kp,t.Vn=this.Vn.N(),t.zn=this.zn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ai;Hi;kn;Ae;pi;w0;Sd;$;J;Fl;no;Pn;Te;Fi;Mn;constructor(t,i){return super(),this.n|=2097152,this.ai="",this.Hi="black",this.kn="13px sans-serif",this.Ae=0,this.pi=0,this.w0=0,this.Sd=null,this.$=null,this.J=null,this.Fl=0,this.no=null,this.Pn=0,this.Te=null,this.Fi=null,this.Mn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ai=this.ai,t.Hi=this.Hi,t.kn=this.kn,t.Ae=this.Ae,t.pi=this.pi,t.w0=this.w0,t.Sd=this.Sd,this.$!==null&&(t.$=this.$.copy()),this.J!==null&&(this.J.mi?t.J=this.J:t.J=this.J.copy()),t.Fl=this.Fl,t.no=this.no,t.Pn=this.Pn,t.Te=this.Te,t.Fi=this.Fi,t.Mn=this.Mn}Sn(){this.J===null?this.J=new TextBlockTemplateSettings:this.J.mi&&(this.J=this.J.copy())}rh(){super.rh(),this.J!==null&&(this.J.mi=!0)}ov(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.Xe=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.ki!==null?this.ki=t.ki.copy():this.ki=null,this.K=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Qr=t.margin.N(),this.oi=t.alignment.N(),this.Hc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.si!==null&&(this.si=t.si.copy()),this.shadowVisible=t.shadowVisible,this.ai=t.ai,this.Hi=t.Hi,this.kn=t.kn,this.$!==null&&(this.$=t.$.copy()),t.J!==null&&(t.J.mi?this.J=t.J:this.J=t.J.copy()),this.Fl=t.Fl}sv(t){if(this.ai=t.text||"",this.Xt=t.labelAngle||0,this.Ae=t.lineCount||0,this.kv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}li(t){t in Wrap?this.wrap=t:super.li(t)}toString(){return this.ai.length>22?'TextBlock("'+this.ai.substring(0,20)+'"...)':'TextBlock("'+this.ai+'")'}static getEllipsis(){return TextBlock.Pp}static setEllipsis(t){TextBlock.Pp=t,TextBlock.Jb=new PropertyCollection,TextBlock.E2=0}static getBaseline(){return TextBlock.$b}static setBaseline(t){TextBlock.$b=t}static $b=null;static getUnderline(){return TextBlock.Zb}static setUnderline(t){TextBlock.Zb=t}static Zb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.no=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ai}set text(t){const i=this.ai;t!=null?t=t.toString():t="",i!==t&&(this.ai=t,this.c(),this.t("text",i,t),this.ns(!0))}get textAlign(){return this.J!==null?this.J.Mp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Sn(),this.J.Mp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.J!==null?this.J.oo:0}set flip(t){const i=this.flip;i!==t&&(this.Sn(),this.J.oo=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.J!==null?this.J.nl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Sn(),this.J.nl=t,this._c(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.U2(this.ai,999999,t);let i=t.width;Size.s(t);let e=this.AA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.Po(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ns(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ns(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.J!==null?this.J.Sp:2}set wrap(t){const i=this.wrap;i!==t&&(this.Sn(),this.J.Sp=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.J!==null?this.J.Np:0}set overflow(t){const i=this.overflow;i!==t&&(this.Sn(),this.J.Np=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}B2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.od(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ae}get lineHeight(){return this.Cp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get textEditor(){return this.J!==null?this.J.Lp:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Sn(),this.J.Lp=t,this.t("textEditor",i,t))}get errorFunction(){return this.J!==null?this.J.rs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Sn(),this.J.rs=t,this.t("errorFunction",i,t))}get interval(){return this.$!==null?this.$.cf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.$===null&&(this.$=new GradElementSettings),this.$.cf=t,this.c();const e=this.panel;e!==null&&(e.os=null),this.t("interval",i,t)}}get graduatedStart(){return this.$!==null?this.$.ff:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.$===null&&(this.$=new GradElementSettings),this.$.ff=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.$!==null?this.$.uf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.$===null&&(this.$=new GradElementSettings),this.$.uf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.$!==null?this.$.Ap:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.$===null&&(this.$=new GradElementSettings),this.$.Ap=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.$!==null?this.$.df:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.$===null&&(this.$=new GradElementSettings),this.$.df=t,this.c(),this.t("graduatedSkip",i,t))}ch(t,i){if(this.Hi===null||this.ai.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Cp();let l=t.textAlign=this.textAlign;const h=i.Xu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;const g=this.ys,p=g.dx-(r*g.m21+g.dx),y=g.dy-(r*g.m22+g.dy);let x=p*p+y*y;const b=i.scale;x=x*b*b,x<8&&(m=!0),i.ni!==t&&(m=!1),i.ni instanceof SVGContext&&(m=!1),i.getRenderingHint("textGreeking")===!1&&(m=!1);const k=this.spacingAbove,P=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const M=this.Ae,C=(k+r+P)*M;if(o>C){const S=this.verticalAlignment;u=S.y*o-S.y*C+S.offsetY}if(M===1&&this.Mn!==null){let S=this.pi;S>d&&(S=d),u+=k,this.TA(this.Mn,t,f,u,d,r,S,m,l,a,c)}else if(this.Te!==null&&this.Fi!==null)for(let S=0;Sd&&(N=d),u+=k,this.TA(this.Fi[S],t,f,u,d,r,N,m,l,a,c),u+=r+P}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}TA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2),i.fillRect(e+f,s+o*.25,r,1);return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.$b!==null?TextBlock.$b(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock.Zb!==null?TextBlock.Zb(this,o):o*.8;this.DA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.DA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}DA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}$c(t,i,e){if(!super.$c(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.sd(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}U2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Cp()+h),c=this.overflow===1?this.RA(l):0;if(this.Ae>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.pi=Math.max(this.pi,o),this.Nn(t,this.pi),e!==null&&e.e(o,a);return}let d=this.Nd(f);f=f.substring(d.length);let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.B2(!0),d+=TextBlock.Pp,r=this.getStringWidth(d),this.pi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Nd(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ae+u>this.maxLines)break}let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ae+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.pi=Math.max(this.pi,n),e!==null&&e.e(this.pi,a*this.Pn)}Nv(t,i){if(this.pi===0||this.Te===null||this.Fi===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.RA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Cp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Fi.length)return;this.B2(!0);let l=this.Fi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Pp;const a=this.getStringWidth(l);this.Fi[r]=l,this.Fi=this.Fi.slice(0,r+1),this.Te[r]=a,this.Te=this.Te.slice(0,r+1),this.Pn=this.Fi.length,this.pi=Math.max(this.pi,a),this.Ae=this.Pn,this.Ae===1&&(this.Mn=this.Fi[0])}Nd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Cv;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.el===null?t.length*8:TextBlock.el.measureText(t).width}Cp(){if(this.no!==null)return this.no;const t=this.kn;let i=0;return TextBlock.el===null?(i=16,this.no=i,i):(TextBlock.V2[t]!==void 0&&TextBlock.vA<5e3?i=TextBlock.V2[t]:(i=TextBlock.el.measureText("M").width*1.3,TextBlock.V2[t]=i,TextBlock.vA++),this.no=i,i)}RA(t){if(TextBlock.el===null)return 6;let i=0;return TextBlock.Jb[t]!==void 0&&TextBlock.E2<5e3?i=TextBlock.Jb[t]:(i=TextBlock.el.measureText(TextBlock.Pp).width,TextBlock.Jb[t]=i,TextBlock.E2++),i}Qb(t,i){return t.indexOf(`
`,i)}AA(t){let i=this.ai.replace(/\r\n/g,`
`).replace(/\r/g,`
`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Cp()+e);if(i.length===0)return this.pi=0,this.Ae=1,s;if(!this.isMultiline){const h=this.Qb(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ae=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.Qb(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.U2(h,t,a),n+=a.height,Size.s(a),this.Ae+=this.Pn}else this.U2(h,t,null),n+=s,this.Ae++;this.Ae===this.maxLines&&(l=!0)}o=r+1}return this.w0=n,n}Sv(){let t=this.ai.replace(/\r\n/g,`
`).replace(/\r/g,`
`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.Qb(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.Qb(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.J!==null?this.J.Dl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Sn(),this.J.Dl=t,this.t("textValidation",i,t))}get textEdited(){return this.J!==null?this.J.Tp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Sn(),this.J.Tp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.J!==null?this.J.Dp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Sn(),this.J.Dp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.J!==null?this.J.Fp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Sn(),this.J.Fp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.J!==null?this.J.Rp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Sn(),this.J.Rp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.J!==null?this.J.vp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util.tt(t,"> 0",TextBlock,"maxLines"),this.Sn(),this.J.vp=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.pi,this.Fl,this.no,this.Pn,this.Te,this.Fi,this.Mn]}kv(t){t!==void 0&&(this.pi=t[0],this.Fl=t[1],this.no=t[2],this.Pn=t[3],this.Te=t[4],this.Fi=t[5],this.Mn=t[6])}get metrics(){return{arrSize:this.Te!==null?this.Te:[this.pi],arrText:this.Fi!==null?this.Fi:[this.Mn],maxLineWidth:this.pi,fontHeight:this.no}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Cv=new RegExp("[ \u200B\xAD]");static V2=new PropertyCollection;static vA=0;static Jb=new PropertyCollection;static E2=0;static Pp="...";static FA="";static el=Diagram.isUsingDOM()?new CanvasSurface(null).ci:null}class TextBlockTemplateSettings{mi;rs;oo;Rp;vp;Np;Dp;Fp;Mp;Tp;Lp;Dl;nl;Sp;constructor(){this.mi=!1,this.rs=null,this.oo=0,this.Rp=0,this.vp=1/0,this.Np=0,this.Dp=0,this.Fp=0,this.Mp="start",this.Tp=null,this.Lp=null,this.Dl=null,this.nl=Spot.Top,this.Sp=2}copy(){const t=new TextBlockTemplateSettings;return t.rs=this.rs,t.oo=this.oo,t.Rp=this.Rp,t.vp=this.vp,t.Np=this.Np,t.Dp=this.Dp,t.Fp=this.Fp,t.Mp=this.Mp,t.Tp=this.Tp,t.Lp=this.Lp,t.Dl=this.Dl,t.nl=this.nl,t.Sp=this.Sp,t}}class GradElementSettings{cf;ff;uf;Ap;df;constructor(){this.cf=1,this.ff=0,this.uf=1,this.Ap=null,this.df=null}copy(){const t=new GradElementSettings;return t.cf=this.cf,t.ff=this.ff,t.uf=this.uf,t.Ap=this.Ap,t.df=this.df,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{ol;yt;rl;gf;rs;ll;mf;oo;pf;yf;vb;constructor(t,i){super(),this.n|=2097152,this.ol=null,this.yt="",this.rl=Rect.LD,this.gf=2,this.rs=null,this.ll=null,this.mf=Spot.Center,this.oo=0,this.pf=null,this.yf=null,this.vb=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.ol,t.rl=this.rl.N(),t.gf=this.gf,t.oo=this.oo,t.rs=this.rs,t.ll=this.ll,t.mf=this.mf.N(),t.yf=this.yf}li(t){t in ImageStretch?this.imageStretch=t:super.li(t)}toString(){return"Picture("+this.source+")#"+GSet.cs(this)}get wf(){return(this.n&1048576)!==0}set wf(t){this.wf!==t&&(this.n=this.n^1048576)}get Op(){return(this.n&2097152)!==0}set Op(t){this.Op!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ip[t]&&(delete Picture.Ip[t],Picture._b--):(Picture.Ip=new PropertyCollection,Picture._b=0)}static vL(t,i){i.OA||(i.t1=e=>{Picture.Lv(i,e),t.desiredSize.isReal()||(t.se(!1),t.c())},i.i1=e=>Picture.Av(i,e),i.addEventListener("load",i.t1),i.addEventListener("error",i.i1),i.OA=!0)}static mR(t){t.t1&&t.removeEventListener("load",t.t1),t.i1&&t.removeEventListener("error",t.i1),delete t.t1,delete t.i1,delete t.OA}get element(){return this.ol}set element(t){const i=this.ol;if(this.ns(!0),i!==t){this.wf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.wf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.TS(this),this.ol=t,t!==null&&e&&t.ss===void 0&&(t.ss=new GSet),s!==null&&e&&s.AS(this),this.t("element",i,t),this.C()}}dR(){const t=this.ol;t!==null&&((this.wf||t.complete===!0)&&(t.c0&&(t.Ep instanceof Event&&this.rs!==null?this.rs(this,t.Ep):t.mn===!0&&!t.Ep&&this.ll!==null&&t.z2&&this.ll(this,t.z2)),t.mn=!0,this.desiredSize.isReal()||(this.se(!1),this.c())),t.mn===!0&&this.diagram!==null&&this.diagram.zu.add(this))}Tv(){if(this.ol===null){this.pf=!1;return}const t=new CanvasSurface(null).ci;try{t.drawImage(this.ol,0,0)}catch{this.Op=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.pf=!1),this.pf=!1}catch{this.pf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ns(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ip;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture._b>30&&(Picture.clearCache(),e=Picture.Ip),s=Util.en("img"),s.c0=!0,Picture.vL(this,s);const n=this.yf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture._b++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Lv(t,i){t.mn=!0,t.Ep=!1;let e;const s=t.ss.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.$l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,b=d*x,k=m*x,P=b*k,M=y/P,L=e.__goCache;let C=null;const S=Picture.Dv;if(!n){if(e.mn&&L!==void 0&&P>4&&M>S*S){L.Ot===null&&(L.IA(4,f,u,e),L.IA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Cd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Cd;constructor(t,i){this.yt=t,this.Cd=i}}class GeoStream{Mi;qg;constructor(){this.qg=new Geometry,this.Mi=null}Jt(t){t!==null?(t.lt(),this.qg=t,t.figures.clear()):this.qg=new Geometry,this.Mi=null}fu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Mi.segments.add(r)}else this.Mi=new PathFigure,this.Mi.startX=t,this.Mi.startY=i,this.Mi.isFilled=e,this.Mi.isEvenOdd=o||!1,this.qg.figures.add(this.Mi);n!==void 0&&(this.Mi.isShadowed=n)}UD(){const t=this.Mi.segments.length;t>0&&this.Mi.segments.elt(t-1).close()}BD(){this.Mi.segments.length>0&&(this.Mi.isFilled=!0)}VD(t){this.Mi.isShadowed=t}dE(t){this.Mi.isEvenOdd=t}OD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Mi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Mi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Mi.segments.add(l)}Pw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Mi.segments.add(o)}ID(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Mi.segments.add(l)}ED(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Mi.segments.add(h)}static X2=null;static mC(t){const i=GeoStream.X2;if(i!==null)return GeoStream.X2=null,i.Jt(t),i;{const e=new GeoStream;return e.Jt(t),e}}static pC(t){GeoStream.X2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.Mo;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.En;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.En;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.En;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.En;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Fk,h.spot2=Spot.Rk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Fk,h.spot2=Spot.Rk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Fk,l.spot2=Spot.Rk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Kg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;hl;al;qo;ai;Wo;mh;js;Jo;Ld;EM;EA;Up;Bp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.hl="",this.al=null,this.qo=null,this.ai="",this.Wo=null,this.mh=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Ld=NaN,this.EM=-1,this.EA=new Rect,this.Up=null,this.Bp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.mi?t.F=this.F:t.F=this.F.copy()),t.hl=this.hl,t.qo=null,t.ai=this.ai,t.js.a(this.js),t.Ld=this.Ld}Vo(t){super.Vo(t),t.ah(),t.al=null,t.Jo=null,t.Up=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.cs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.mi&&(this.F=this.F.copy())}rh(){super.rh(),this.F!==null&&(this.F.mi=!0)}qc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Wr(h=>{l.partManager.PS(h,l)}):n instanceof Picture&&l.AS(n):t===4&&i==="elements"&&(n instanceof Panel?n.Wr(h=>l.partManager.MS(h,l)):n instanceof Picture&&l.TS(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.T.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.g2()){const i=this.T.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.rt(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}OM(t){this.Wo=t,t===null&&this.TR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.hl}set layerName(t){const i=this.hl;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.hl=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.te(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Hh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.G;e.G=!0,r(this,s,n),e.G=l}get layerChanged(){return this.F!==null?this.F.Vp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.Vp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Ld}set zOrder(t){const i=this.Ld;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Ld=t;const e=this.layer;e!==null&&e.px(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}vv(){const t=this.layer;t!==null&&t.px(-1,this)}e1(){if(this.th()!==!1)return;this.K2(!0),this.td();const t=this.diagram;t!==null&&(t.o0(this),t.requestUpdate())}VA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.zA(t,i);const e=this.Ai,s=Rect.l().a(e);e.lt(),e.x=t.x,e.y=t.y,e.g(),this.ed(s,e),Rect.s(s),this.K2(!1)}Zn(t,i,e,s){const n=this.oe;n.e(t,i,e,s),this.ki===null&&(this.ki=new Transform);const o=this.ki;o.Jt(),this.p0(o,t,i,e,s),this.ki=o,o.vk()||o.yw(n)}p0(t,i,e,s,n){if(this.K!==1&&t.K(this.K),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.ki!==null&&l.ki.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.ki!==null&&a.ki.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.fs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.zp:Point.$N}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.zp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Xp:Point.ZN}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Kp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Kp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Yp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Yp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.sx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.o0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ah(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Up;if(i===null&&(this.Up=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}A0(){this.Up=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.L.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.L.xt(e),o=o.panel;return this.ki!==null&&this.ki.xt(e),e.offset(-this.oe.x,-this.oe.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}gA(t){const i=this.locationSpot,e=this.locationObject,s=e.naturalBounds,n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.L.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.L.xt(t),o=o.panel}return this.ki!==null&&this.ki.xt(t),t.offset(-this.oe.x,-this.oe.y),t}jh(t,i){const e=i===void 0?this.EA:i,s=this.Ov(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}pv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Ov(){return isNaN(this.Bp)&&(this.Bp=this.kA()),this.Bp}hf(){this.Bp=NaN}zt(){if(this.es()===!1){this.VA();return}this.Qn(!1);const t=this.Ai,i=Rect.l();i.a(t);const e=this.Cl();this.hh(0,0,this.oe.width,this.oe.height);const s=this.position;this.zA(s,this.location),t.lt(),t.x=s.x,t.y=s.y,t.g(),this.ed(i,t),i.equals(t)?this.Us(e):this.Se()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.EM>=0&&this.invalidateLayout(16),Rect.s(i),this.K2(!1)}ed(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.$h===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.lt(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.lt(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ns(!0),this.t("isShadowed",i,t),this.C())}UA(){return(this.P&16384)!==0}BA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}K2(t){t?this.P|=32768:this.P&=-32769}Iv(){return(this.P&65536)!==0}s2(t){t?this.P|=65536:this.P&=-65537}Cl(){return(this.P&131072)!==0}Us(t){t?this.P|=131072:this.P&=-131073}jA(){return(this.P&1048576)!==0}s1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.Gp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.Gp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.jp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.jp=t,this.al=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.Hp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.Hp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.al===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.al=i:this.al=this}else if(this instanceof Link){const i=this.path;i!==null?this.al=i:this.al=this}else this.al=this}return this.al}get selectionChanged(){return this.F!==null?this.F.qp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.qp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Wp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Wp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.Jp:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.$p:Size.dw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.$p=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Zp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Zp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F.Qp:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F._p:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F._p=t,this.t("rotationSpot",i,t))}get text(){return this.ai}set text(t){const i=this.ai;i!==t&&(this.ai=t,this.t("text",i,t))}get containingGroup(){return this.mh}set containingGroup(t){if(this.Se()){const i=this.mh;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.G2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.mh=t,t!==null?t.j2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.G){const n=this.data,o=e.model;if(n!==null&&o.Gc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.G,e.G=!0),s(this,i,t),e!==null&&(e.G=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ad()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ad();const o=this.labeledLink;o!==null&&o.Ad()}this.t("containingGroup",i,t),t!==null&&t.vv()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ah(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.es()&&!this.th()&&this.isVisible()&&this.Ai.isReal()&&t.C(this.jh(this.Ai))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.o0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink._c(),t.requestUpdate(!0))}_c(t){if(this.es())return;const i=this.diagram;i!==null&&(i.o0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.Qn(!0)}Em(t){if(!t){const i=this.mh;i!==null&&i.j2(this)}}Um(t){if(!t){const i=this.mh;i!==null&&i.G2(this)}}Vc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.ty:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.ty=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.H2(this)}H2(t){const i=t.containingGroup;if(i!==null)return 1+this.H2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.H2(e)}return 0}findTopLevelPart(){return this.q2(this)}q2(t){const i=t.containingGroup;if(i!==null)return this.q2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.q2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.W2(this,t):!1}W2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.W2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.W2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.s1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.jA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.s1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.iy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.iy=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Uv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Uv(t))return;const i=this.mh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}SL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.ey:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.ey=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.sy:Point.QN}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.sy=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.ny:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.ny=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{mi;Vp;ty;Hp;jp;qp;Gp;Wp;Jp;$p;Zp;Qp;_p;Kp;Yp;zp;Xp;ey;iy;sy;ny;xn;constructor(){this.mi=!1,this.Vp=null,this.ty=null,this.Hp=null,this.jp="",this.qp=null,this.Gp=null,this.Wp=null,this.Jp="",this.$p=Size.dw,this.Zp=null,this.Qp="",this._p=Spot.Default,this.Kp="",this.Yp=Spot.TopLeft,this.zp=Point.$N,this.Xp=Point.ZN,this.ey=null,this.iy=127,this.sy=Point.QN,this.ny="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.Vp=this.Vp,t.ty=this.ty,t.Hp=this.Hp,t.jp=this.jp,t.qp=this.qp,t.Gp=this.Gp,t.Wp=this.Wp,t.Jp=this.Jp,t.$p=this.$p.N(),t.Zp=this.Zp,t.Qp=this.Qp,t._p=this._p.N(),t.Kp=this.Kp,t.Yp=this.Yp.N(),t.zp=this.zp.N(),t.Xp=this.Xp.N(),t.ey=this.ey,t.iy=this.iy,t.sy=this.sy.N(),t.ny=this.ny,t.xn=this.xn,t}}class Adornment extends Part{ds;It;WP;JP;rf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.hl="Adornment",this.ds=null,this.WP=0,this.JP=!1,this.It=null,this.rf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}ad(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.ad(t),n=s.geometry;const o=this.T.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.qc(t,i,e,s,n,o,r)}updateAdornments(){}Vc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;xf;cl;ph;re;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.xf=null,this.cl=null,this.re=null,this.ph=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.mi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.cl=this.cl,t.re=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;fl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.mi&&(this.gt=this.gt.copy())}rh(){super.rh(),this.gt!==null&&(this.gt.mi=!0)}HA(t){t!==null&&(this.cl===null&&(this.cl=new GSet),this.cl.add(t))}qA(t){t!==null&&this.cl!==null&&this.cl.delete(t)}WA(t,i,e){if(t===null||this.cl===null)return null;const s=this.cl.iterator;for(;s.next();){const n=s.value;if(n.oy===this&&n.o1===t&&n.J2===i&&n.$2===e||n.oy===t&&n.o1===this&&n.J2===e&&n.$2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.WA(t,i,e);s!==null&&s.Td()}qc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.re=null:t===4&&i==="elements"&&(this.re=null),super.qc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.pe(e.fromPort),this.pe(e.toPort),e.invalidateRoute())}}_L(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.pe(e.fromPort),this.pe(e.toPort),e.invalidateRoute())}}pe(t){if(t===null)return;const i=t.$u;i!==null&&i.Td();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.pe(s.port)}qr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ry:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.fl(),this.gt.ry=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.IS(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.ly:Margin.oC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.fl(),this.gt.ly=t;const e=this.diagram;e!==null&&e.IS(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.sx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.JA(this,t,i),i.iterator}JA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.JA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.hy:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.fl(),this.gt.hy=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.ay:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.fl(),this.gt.ay=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Nl:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.fl(),this.gt.Nl=t,this.t("linkValidation",i,t))}l1(t,i){this.pe(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.G,o.G=!0),s(this,t,i),o!==null&&(o.G=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.ph||(l.ph=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}h1(t,i){this.pe(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.G,s.G=!0),n(this,t,i),s!==null&&(s.G=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.ph=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.ph=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.f0()}}f0(){if(this.ph=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Em(t){if(super.Em(t),!t){this.f0();const i=this.xf;i!==null&&i.$A(this)}}Um(t){if(super.Um(t),!t){const i=this.xf;i!==null&&i.ZA(this)}}Vc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Vc()}get isLinkLabel(){return this.xf!==null}get labeledLink(){return this.xf}set labeledLink(t){const i=this.xf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i.ZA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.La()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.xf=t,t!==null){if(t.$A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.La()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this._c(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.re===null){if(t===""&&this.wn===!1)return this;this.QA()}let i=this.re.get(t);return i!==null||t!==""&&(i=this.re.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.re===null&&this.QA(),this.re.iteratorValues}QA(){this.re===null?this.re=new GMap:this.re.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.lA(i)),this.re.count===0&&this.re.set("",this)}lA(t){const i=t.portId;i!==null&&this.re!==null&&this.re.set(i,t)}d2(t,i){const e=t.portId;if(e!==null){this.re!==null&&this.re.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.rt()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this._A(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}_A(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h._A(t,i,e-1,s,n,o))}}else this.tT(t,i,s,n,o)}tT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Sc(h,s),h.ah(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.tT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Ce||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ah();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Mc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.iT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.G,e.G=!0),s(this),e!==null&&(e.G=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.cy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.fl(),this.gt.cy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{mi;hy;ay;Nl;cy;ly;ry;fy;uy;eh;gy;constructor(){this.mi=!1,this.hy=null,this.ay=null,this.Nl=null,this.cy=null,this.ly=Margin.oC,this.ry=1,this.fy=null,this.uy=null,this.eh=null,this.gy=null}copy(){const t=new NodeTemplateSettings;return t.hy=this.hy,t.ay=this.ay,t.Nl=this.Nl,t.cy=this.cy,t.ly=this.ly.N(),t.ry=this.ry,t.fy=this.fy,t.uy=this.uy,t.eh=this.eh,t.gy=this.gy,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;ro;lo;Dd;ho;ao;Fd;bf;Rd;vd;Od;Aa;Id;Hs;Pi;ul;Mr;kf;$o;Z2;Q2;a1;_2;tN;my;c1;ft;Zo;static Ta=null;static Da=null;rf;iN;eN;constructor(t){super(Panel.Link),this.Nt=8,this.ro=null,this.lo="",this.Dd=null,this.ho=null,this.ao="",this.Fd=null,this.bf=0,this.Rd=0,this.vd=0,this.Od=NaN,this.Aa=1,this.Id=.5,this.Hs=null,this.Pi=new List().g(),this.ul=null,this.Mr=null,this.kf=new Rect,this.ft=new Geometry,this.$o=null,this.Zo=null,this.Z2=null,this.Q2=null,this.iN=0,this.eN=0,this.a1=new Point,this._2=null,this.tN=null,this.my=null,this.c1=NaN,this.W=null,this.rf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.lo=this.lo,t.Dd=this.Dd,t.ao=this.ao,t.Fd=this.Fd,t.bf=this.bf,t.Rd=this.Rd,t.vd=this.vd,t.Od=this.Od,t.Aa=this.Aa,t.Id=this.Id,this.W!==null&&(t.W=this.W.copy())}Vo(t){super.Vo(t),this.lo=t.lo,this.ao=t.ao,t.ul=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.pe(i);const e=t.toPort;e!==null&&t.toNode.pe(e)}li(t){t in Routing||t in Curve||t in LinkAdjusting?Link.sN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.li(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static Vv=8;static zv=16;static Xv=14;static Fa=8;Ke(){this.W===null&&(this.W=new LinkSettings)}ZR(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ft,S=Util.rt();C.getPointAndAngleAlongPath(n,S);const N=Point.X(S[0],S[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=S[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.it(S)}else if(s<-i||s>=i){const C=Point.l();this.dA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,S,N=0;if(s>=0?(C=e.r[s],S=s0?e.r[N-1]:C),C.equalsApprox(S)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:S);const D=T.distanceSquaredPoint(C),F=S.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?S.directionPoint(A):A.directionPoint(S):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(S):S.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(S.x-C.x)*n,a=C.y+(S.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Jt(),u.K(t.scale,t.scale),u.fs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,b=d.height,k=Point.l();k.a(l);const P=isNaN(l.x),M=isNaN(l.y);if(P||M){const C=x/2+3,S=b/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(k.x=M?C:l.y,k.y=P?S:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(k.y=-S):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(k.y=-S),M&&(k.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?k.x=C:k.x=-C),M&&(k.y=-S),k.rotate(f))}else k.rotate(f);h+=k.x,a+=k.y,u.yw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(k),Point.s(g),Rect.s(m),Transform.s(u)}qr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.es()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.es()||i.th())return!1}return!0}f2(t,i,e){return!1}u2(){}Se(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Xg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Xg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Xg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Xg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Xg(e)}get fromNode(){return this.ro}set fromNode(t){const i=this.ro;if(i!==t){const e=this.fromPort;i!==null&&(this.ho!==i&&i.h1(this,e),this.py(),this.invalidateLayout(2)),this.ro=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.G&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,e,n),s!==null&&(s.G=r)}t!==null&&(this.ho!==t&&t.l1(this,n),this.yy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ad()}}get fromPortId(){return this.lo}set fromPortId(t){const i=this.lo;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.pe(e),this.py(),this.lo=t;const s=this.fromPort;s!==null&&this.fromNode.pe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.La()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,e,s),n!==null&&(n.G=r)}}this.yy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.ro;if(t===null)return null;const i=this.lo;return t.findPort(i)}get fromPortChanged(){return this.Dd}set fromPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Dd=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ho}set toNode(t){const i=this.ho;if(i!==t){const e=this.toPort;i!==null&&(this.ro!==i&&i.h1(this,e),this.py(),this.invalidateLayout(2)),this.ho=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.G&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,e,n),s!==null&&(s.G=r)}t!==null&&(this.ro!==t&&t.l1(this,n),this.yy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ad()}}get toPortId(){return this.ao}set toPortId(t){const i=this.ao;if(i!==t){const e=this.toPort;e!==null&&this.toNode.pe(e),this.py(),this.ao=t;const s=this.toPort;s!==null&&this.toNode.pe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.La()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,e,s),n!==null&&(n.G=r)}}this.yy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ho;if(t===null)return null;const i=this.ao;return t.findPort(i)}get toPortChanged(){return this.Fd}set toPortChanged(t){const i=this.Fd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Fd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.W!==null?this.W.aa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Ke(),this.W.aa=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.pe(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.W!==null?this.W.fa:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util.tt(t,">= 0",Link,"fromEndSegmentLength"),this.Ke(),this.W.fa=t,this.t("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.W!==null?this.W.da:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Ke(),this.W.da=t,this.ne(),this.t("fromShortLength",i,t))}get toSpot(){return this.W!==null?this.W.ca:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Ke(),this.W.ca=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.pe(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.W!==null?this.W.ua:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util.tt(t,">= 0",Link,"toEndSegmentLength"),this.Ke(),this.W.ua=t,this.t("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.W!==null?this.W.ga:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Ke(),this.W.ga=t,this.ne(),this.t("toShortLength",i,t))}Ad(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Kv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Kv(t){const i=this.mh;if(i!==t){i!==null&&i.G2(this),this.mh=t,t!==null&&t.j2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.G,n.G=!0),e(this,i,t),n!==null&&(n.G=s)}this.Ce&&(this._2===i||this.tN===i)&&this.invalidateRoute()}}ah(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ah()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}$A(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}ZA(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Em(t){if(super.Em(t),this.Ra()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.ro;let e=null;i!==null&&(e=this.fromPort,i.l1(this,e));const s=this.ho;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.l1(this,n)),this.yy()}}Um(t){if(super.Um(t),this.Ra()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.ro;let e=null;i!==null&&(e=this.fromPort,i.h1(this,e));const s=this.ho;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.h1(this,n)),this.py()}}Vc(){if(this.Ce=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.nN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.f0(),this.toNode!==null&&this.toNode.f0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.Yv(this.kf)}Yv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.hu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.hu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ft.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ft.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.fC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.fC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ft.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.DD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}Gv(){if(this.my===null){this.Ce||this.f1();const t=this.my=[];this.jv(t)}}get flattenedLengths(){return this.Gv(),this.my}get flattenedTotalLength(){let t=this.c1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.Hv(i,e,r,s,n,l):this.qv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,b=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(b=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(b-=f?90:30,g<0&&(b-=180)),b<0?b+=360:b>=360&&(b-=360),c&&(N+=Math.abs(g)*(f?1:2)),b===0?y=N:b===90?x=N:b===180?y=-N:b===270?x=-N:(y=N*Math.cos(b*Math.PI/180),x=N*Math.sin(b*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const k=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,M=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,k,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?M=N:L===180?P=-N:L===270?M=-N:(P=N*Math.cos(L*Math.PI/180),M=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,k),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let S=k;(f||!a||c)&&(S=new Point(k.x+P,k.y+M)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,S)?this.setPoint(o-1,k):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,k)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,S)?(this.setPoint(0,p),this.setPoint(o-1,k)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,b,S,L,i,s),(f||!a||c)&&this.addPoint(S),this.addPoint(k))}return t.addInvalidRoute(this),!0}rN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.ys;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.Jc(r,l,h,a,o),c!==null&&o.L(c),o}Wv(t,i){const e=t.$u;return e!==null?e.eT(i):null}d1(t){let i=t.$u;return i===null&&(i=new Knot,i.Qo=t,i.ge=t.part,t.$u=i),i.eT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ed(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.d1(i);if(c!==null){const f=c.Ud;if(l.a(f),n&&this.routing===7){const u=this.d1(r);if(u!==null&&c.Pf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.g1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.rN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.g1(c,!s),f),n&&(a=this.rN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.Jv(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ed(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}Jv(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.d1(i);if(f!==null)switch(f.ye){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.rN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.d1(i);if(o!==null)return o.m1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.$v(i||this.fromPort):this.Zv(i||this.toPort)}$v(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}Zv(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ed(t){return t===Spot.None||t.x===.5&&t.y===.5}g1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.Wv(i,this);return e!==null?e.Ud:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}vm(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Jt()),r._a(this.L),this.containedInRect(t,r))return this.D2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.lf){const h=this.T.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.vm(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.xv(t,s,g)):l=m.ZL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Aa&2)===2}static sN(t){return(t&2)===2}get isAvoiding(){return(this.Aa&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.T.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.g1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.g1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}Hv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.Qv(t,i,e,s);case 19:return this._v(t,i,e,s);case 17:return this.tO(t,i,e,s);default:return!1}}Qv(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.Y(u,0))return!0;let d=0;Geo.Y(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,b=y-g,k=Math.sqrt(x*x+b*b);let P=0;Geo.Y(x,0)?b<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(b/Math.abs(x)),x<0&&(P=Math.PI-P));const M=k/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const S=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=S+C/p,A=N-(T-S)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,S,N+C)}return this.setPoint(e,s),!0}tO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.LL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Fa,Link.Fa),m.inflate(Link.Fa,Link.Fa),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.x