@d3-polytree/editor 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- "use strict";var d3PolytreeEditor=(()=>{var Al=Object.create;var Ke=Object.defineProperty;var Cl=Object.getOwnPropertyDescriptor;var Pl=Object.getOwnPropertyNames;var Tl=Object.getPrototypeOf,Bl=Object.prototype.hasOwnProperty;var Ll=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$l=(t,e)=>{for(var r in e)Ke(t,r,{get:e[r],enumerable:!0})},Si=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Pl(e))!Bl.call(t,i)&&i!==r&&Ke(t,i,{get:()=>e[i],enumerable:!(n=Cl(e,i))||n.enumerable});return t};var zl=(t,e,r)=>(r=t!=null?Al(Tl(t)):{},Si(e||!t||!t.__esModule?Ke(r,"default",{value:t,enumerable:!0}):r,t)),Ol=t=>Si(Ke({},"__esModule",{value:!0}),t);var yo=Ll((Bm,nn)=>{"use strict";var zu=Object.prototype.hasOwnProperty,ot="~";function we(){}Object.create&&(we.prototype=Object.create(null),new we().__proto__||(ot=!1));function Ou(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function _o(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new Ou(r,n||t,i),s=ot?ot+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],o]:t._events[s].push(o):(t._events[s]=o,t._eventsCount++),t}function nr(t,e){--t._eventsCount===0?t._events=new we:delete t._events[e]}function nt(){this._events=new we,this._eventsCount=0}nt.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)zu.call(r,n)&&e.push(ot?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};nt.prototype.listeners=function(e){var r=ot?ot+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};nt.prototype.listenerCount=function(e){var r=ot?ot+e:e,n=this._events[r];return n?n.fn?1:n.length:0};nt.prototype.emit=function(e,r,n,i,o,s){var a=ot?ot+e:e;if(!this._events[a])return!1;var l=this._events[a],u=arguments.length,c,f;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,r),!0;case 3:return l.fn.call(l.context,r,n),!0;case 4:return l.fn.call(l.context,r,n,i),!0;case 5:return l.fn.call(l.context,r,n,i,o),!0;case 6:return l.fn.call(l.context,r,n,i,o,s),!0}for(f=1,c=new Array(u-1);f<u;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var d=l.length,m;for(f=0;f<d;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),u){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,r);break;case 3:l[f].fn.call(l[f].context,r,n);break;case 4:l[f].fn.call(l[f].context,r,n,i);break;default:if(!c)for(m=1,c=new Array(u-1);m<u;m++)c[m-1]=arguments[m];l[f].fn.apply(l[f].context,c)}}return!0};nt.prototype.on=function(e,r,n){return _o(this,e,r,n,!1)};nt.prototype.once=function(e,r,n){return _o(this,e,r,n,!0)};nt.prototype.removeListener=function(e,r,n,i){var o=ot?ot+e:e;if(!this._events[o])return this;if(!r)return nr(this,o),this;var s=this._events[o];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&nr(this,o);else{for(var a=0,l=[],u=s.length;a<u;a++)(s[a].fn!==r||i&&!s[a].once||n&&s[a].context!==n)&&l.push(s[a]);l.length?this._events[o]=l.length===1?l[0]:l:nr(this,o)}return this};nt.prototype.removeAllListeners=function(e){var r;return e?(r=ot?ot+e:e,this._events[r]&&nr(this,r)):(this._events=new we,this._eventsCount=0),this};nt.prototype.off=nt.prototype.removeListener;nt.prototype.addListener=nt.prototype.on;nt.prefixed=ot;nt.EventEmitter=nt;typeof nn<"u"&&(nn.exports=nt)});var _p={};$l(_p,{Editor:()=>Kr,default:()=>gp});var Qe="http://www.w3.org/1999/xhtml",Jr={svg:"http://www.w3.org/2000/svg",xhtml:Qe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function kt(t){var e=t+="",r=e.indexOf(":");return r>=0&&(e=t.slice(0,r))!=="xmlns"&&(t=t.slice(r+1)),Jr.hasOwnProperty(e)?{space:Jr[e],local:t}:t}function Rl(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===Qe&&e.documentElement.namespaceURI===Qe?e.createElement(t):e.createElementNS(r,t)}}function Il(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Je(t){var e=kt(t);return(e.local?Il:Rl)(e)}function Dl(){}function Vt(t){return t==null?Dl:function(){return this.querySelector(t)}}function ki(t){typeof t!="function"&&(t=Vt(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=new Array(s),l,u,c=0;c<s;++c)(l=o[c])&&(u=t.call(l,l.__data__,c,o))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new U(n,this._parents)}function tn(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function jl(){return[]}function ye(t){return t==null?jl:function(){return this.querySelectorAll(t)}}function Fl(t){return function(){return tn(t.apply(this,arguments))}}function Ai(t){typeof t=="function"?t=Fl(t):t=ye(t);for(var e=this._groups,r=e.length,n=[],i=[],o=0;o<r;++o)for(var s=e[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&(n.push(t.call(l,l.__data__,u,s)),i.push(l));return new U(n,i)}function xe(t){return function(){return this.matches(t)}}function tr(t){return function(e){return e.matches(t)}}var Hl=Array.prototype.find;function ql(t){return function(){return Hl.call(this.children,t)}}function Vl(){return this.firstElementChild}function Ci(t){return this.select(t==null?Vl:ql(typeof t=="function"?t:tr(t)))}var Ul=Array.prototype.filter;function Xl(){return Array.from(this.children)}function Gl(t){return function(){return Ul.call(this.children,t)}}function Pi(t){return this.selectAll(t==null?Xl:Gl(typeof t=="function"?t:tr(t)))}function Ti(t){typeof t!="function"&&(t=xe(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&a.push(l);return new U(n,this._parents)}function er(t){return new Array(t.length)}function Bi(){return new U(this._enter||this._groups.map(er),this._parents)}function ve(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}ve.prototype={constructor:ve,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Li(t){return function(){return t}}function Zl(t,e,r,n,i,o){for(var s=0,a,l=e.length,u=o.length;s<u;++s)(a=e[s])?(a.__data__=o[s],n[s]=a):r[s]=new ve(t,o[s]);for(;s<l;++s)(a=e[s])&&(i[s]=a)}function Wl(t,e,r,n,i,o,s){var a,l,u=new Map,c=e.length,f=o.length,d=new Array(c),m;for(a=0;a<c;++a)(l=e[a])&&(d[a]=m=s.call(l,l.__data__,a,e)+"",u.has(m)?i[a]=l:u.set(m,l));for(a=0;a<f;++a)m=s.call(t,o[a],a,o)+"",(l=u.get(m))?(n[a]=l,l.__data__=o[a],u.delete(m)):r[a]=new ve(t,o[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(d[a])===l&&(i[a]=l)}function Yl(t){return t.__data__}function $i(t,e){if(!arguments.length)return Array.from(this,Yl);var r=e?Wl:Zl,n=this._parents,i=this._groups;typeof t!="function"&&(t=Li(t));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),u=0;u<o;++u){var c=n[u],f=i[u],d=f.length,m=Kl(t.call(c,c&&c.__data__,u,n)),P=m.length,A=a[u]=new Array(P),R=s[u]=new Array(P),E=l[u]=new Array(d);r(c,f,A,R,E,m,e);for(var y=0,M=0,p,_;y<P;++y)if(p=A[y]){for(y>=M&&(M=y+1);!(_=R[M])&&++M<P;);p._next=_||null}}return s=new U(s,n),s._enter=a,s._exit=l,s}function Kl(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function zi(){return new U(this._exit||this._groups.map(er),this._parents)}function Oi(t,e,r){var n=this.enter(),i=this,o=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),r==null?o.remove():r(o),n&&i?n.merge(i).order():i}function Ri(t){for(var e=t.selection?t.selection():t,r=this._groups,n=e._groups,i=r.length,o=n.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var u=r[l],c=n[l],f=u.length,d=a[l]=new Array(f),m,P=0;P<f;++P)(m=u[P]||c[P])&&(d[P]=m);for(;l<i;++l)a[l]=r[l];return new U(a,this._parents)}function Ii(){for(var t=this._groups,e=-1,r=t.length;++e<r;)for(var n=t[e],i=n.length-1,o=n[i],s;--i>=0;)(s=n[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Di(t){t||(t=Ql);function e(f,d){return f&&d?t(f.__data__,d.__data__):!f-!d}for(var r=this._groups,n=r.length,i=new Array(n),o=0;o<n;++o){for(var s=r[o],a=s.length,l=i[o]=new Array(a),u,c=0;c<a;++c)(u=s[c])&&(l[c]=u);l.sort(e)}return new U(i,this._parents).order()}function Ql(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function ji(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Fi(){return Array.from(this)}function Hi(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],i=0,o=n.length;i<o;++i){var s=n[i];if(s)return s}return null}function qi(){let t=0;for(let e of this)++t;return t}function Vi(){return!this.node()}function Ui(t){for(var e=this._groups,r=0,n=e.length;r<n;++r)for(var i=e[r],o=0,s=i.length,a;o<s;++o)(a=i[o])&&t.call(a,a.__data__,o,i);return this}function Jl(t){return function(){this.removeAttribute(t)}}function tu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function eu(t,e){return function(){this.setAttribute(t,e)}}function ru(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function nu(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttribute(t):this.setAttribute(t,r)}}function iu(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,r)}}function Xi(t,e){var r=kt(t);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((e==null?r.local?tu:Jl:typeof e=="function"?r.local?iu:nu:r.local?ru:eu)(r,e))}function rr(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ou(t){return function(){this.style.removeProperty(t)}}function su(t,e,r){return function(){this.style.setProperty(t,e,r)}}function au(t,e,r){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,r)}}function Gi(t,e,r){return arguments.length>1?this.each((e==null?ou:typeof e=="function"?au:su)(t,e,r??"")):$t(this.node(),t)}function $t(t,e){return t.style.getPropertyValue(e)||rr(t).getComputedStyle(t,null).getPropertyValue(e)}function lu(t){return function(){delete this[t]}}function uu(t,e){return function(){this[t]=e}}function cu(t,e){return function(){var r=e.apply(this,arguments);r==null?delete this[t]:this[t]=r}}function Zi(t,e){return arguments.length>1?this.each((e==null?lu:typeof e=="function"?cu:uu)(t,e)):this.node()[t]}function Wi(t){return t.trim().split(/^|\s+/)}function en(t){return t.classList||new Yi(t)}function Yi(t){this._node=t,this._names=Wi(t.getAttribute("class")||"")}Yi.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ki(t,e){for(var r=en(t),n=-1,i=e.length;++n<i;)r.add(e[n])}function Qi(t,e){for(var r=en(t),n=-1,i=e.length;++n<i;)r.remove(e[n])}function fu(t){return function(){Ki(this,t)}}function du(t){return function(){Qi(this,t)}}function pu(t,e){return function(){(e.apply(this,arguments)?Ki:Qi)(this,t)}}function Ji(t,e){var r=Wi(t+"");if(arguments.length<2){for(var n=en(this.node()),i=-1,o=r.length;++i<o;)if(!n.contains(r[i]))return!1;return!0}return this.each((typeof e=="function"?pu:e?fu:du)(r,e))}function hu(){this.textContent=""}function mu(t){return function(){this.textContent=t}}function gu(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function to(t){return arguments.length?this.each(t==null?hu:(typeof t=="function"?gu:mu)(t)):this.node().textContent}function _u(){this.innerHTML=""}function yu(t){return function(){this.innerHTML=t}}function xu(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function eo(t){return arguments.length?this.each(t==null?_u:(typeof t=="function"?xu:yu)(t)):this.node().innerHTML}function vu(){this.nextSibling&&this.parentNode.appendChild(this)}function ro(){return this.each(vu)}function wu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function no(){return this.each(wu)}function io(t){var e=typeof t=="function"?t:Je(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function bu(){return null}function oo(t,e){var r=typeof t=="function"?t:Je(t),n=e==null?bu:typeof e=="function"?e:Vt(e);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function Nu(){var t=this.parentNode;t&&t.removeChild(this)}function so(){return this.each(Nu)}function Eu(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Mu(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ao(t){return this.select(t?Mu:Eu)}function lo(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Su(t){return function(e){t.call(this,e,this.__data__)}}function ku(t){return t.trim().split(/^|\s+/).map(function(e){var r="",n=e.indexOf(".");return n>=0&&(r=e.slice(n+1),e=e.slice(0,n)),{type:e,name:r}})}function Au(t){return function(){var e=this.__on;if(e){for(var r=0,n=-1,i=e.length,o;r<i;++r)o=e[r],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++n]=o;++n?e.length=n:delete this.__on}}}function Cu(t,e,r){return function(){var n=this.__on,i,o=Su(e);if(n){for(var s=0,a=n.length;s<a;++s)if((i=n[s]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=r),i.value=e;return}}this.addEventListener(t.type,o,r),i={type:t.type,name:t.name,value:e,listener:o,options:r},n?n.push(i):this.__on=[i]}}function uo(t,e,r){var n=ku(t+""),i,o=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(i=0,c=a[l];i<o;++i)if((s=n[i]).type===c.type&&s.name===c.name)return c.value}return}for(a=e?Cu:Au,i=0;i<o;++i)this.each(a(n[i],e,r));return this}function co(t,e,r){var n=rr(t),i=n.CustomEvent;typeof i=="function"?i=new i(e,r):(i=n.document.createEvent("Event"),r?(i.initEvent(e,r.bubbles,r.cancelable),i.detail=r.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Pu(t,e){return function(){return co(this,t,e)}}function Tu(t,e){return function(){return co(this,t,e.apply(this,arguments))}}function fo(t,e){return this.each((typeof e=="function"?Tu:Pu)(t,e))}function*po(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],i=0,o=n.length,s;i<o;++i)(s=n[i])&&(yield s)}var rn=[null];function U(t,e){this._groups=t,this._parents=e}function ho(){return new U([[document.documentElement]],rn)}function Bu(){return this}U.prototype=ho.prototype={constructor:U,select:ki,selectAll:Ai,selectChild:Ci,selectChildren:Pi,filter:Ti,data:$i,enter:Bi,exit:zi,join:Oi,merge:Ri,selection:Bu,order:Ii,sort:Di,call:ji,nodes:Fi,node:Hi,size:qi,empty:Vi,each:Ui,attr:Xi,style:Gi,property:Zi,classed:Ji,text:to,html:eo,raise:ro,lower:no,append:io,insert:oo,remove:so,clone:ao,datum:lo,on:uo,dispatch:fo,[Symbol.iterator]:po};var At=ho;function X(t){return typeof t=="string"?new U([[document.querySelector(t)]],[document.documentElement]):new U([[t]],rn)}function mo(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Q(t,e){if(t=mo(t),e===void 0&&(e=t.currentTarget),e){var r=e.ownerSVGElement||e;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}function Lu(t,e){return e={exports:{}},t(e,e.exports),e.exports}var $u=Lu(function(t){var e=t.exports=function(r,n){if(n||(n=16),r===void 0&&(r=128),r<=0)return"0";for(var i=Math.log(Math.pow(2,r))/Math.log(n),o=2;i===1/0;o*=2)i=Math.log(Math.pow(2,r/o))/Math.log(n)*o;for(var s=i-Math.floor(i),a="",o=0;o<Math.floor(i);o++){var l=Math.floor(Math.random()*n).toString(n);a=l+a}if(s){var u=Math.pow(n,s),l=Math.floor(Math.random()*u).toString(n);a=l+a}var c=parseInt(a,n);return c!==1/0&&c>=Math.pow(2,r)?e(r,n):a};e.rack=function(r,n,i){var o=function(a){var l=0;do{if(l++>10)if(i)r+=i;else throw new Error("too many ID collisions, use more bits");var u=e(r,n)}while(Object.hasOwnProperty.call(s,u));return s[u]=a,u},s=o.hats={};return o.get=function(a){return o.hats[a]},o.set=function(a,l){return o.hats[a]=l,o},o.bits=r||128,o.base=n||16,o}});function Ct(t){if(!(this instanceof Ct))return new Ct(t);t=t||[128,36,1],this._seed=t.length?$u.rack(t[0],t[1],t[2]):t}Ct.prototype.next=function(t){return this._seed(t||!0)};Ct.prototype.nextPrefixed=function(t,e){var r;do r=t+this.next(!0);while(this.assigned(r));return this.claim(r,e),r};Ct.prototype.claim=function(t,e){this._seed.set(t,e||!0)};Ct.prototype.assigned=function(t){return this._seed.get(t)||!1};Ct.prototype.unclaim=function(t){delete this._seed.hats[t]};Ct.prototype.clear=function(){var t=this._seed.hats,e;for(e in t)this.unclaim(e)};var go=Ct;var xo=zl(yo(),1);var vo=xo.default;function Ru(t){t.setAttribute("xlink","http://www.w3.org/1999/xlink"),ju(Du(t),t);let r=new XMLSerializer().serializeToString(t);return r=r.replace(/(\w+)?:?xlink=/g,"xmlns:xlink="),r=r.replace(/NS\d+:href/g,"xlink:href"),r}function Iu(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function wo(t,e){return e.some(r=>t.match(r)!==null)}function Du(t){let e="[\\.,#\\s\\*>+~\\[=:]",r=a=>new RegExp(`.*${e}${Iu(a)}${e}.*`,"gi"),n=[],i=a=>{wo(a,n)||n.push(r(a))};i(`#${t.id}`),t.classList.forEach(a=>i(`.${a}`));let o=t.getElementsByTagName("*");for(let a=0;a<o.length;a++){let l=o[a];l.id&&i(`#${l.id}`),l.classList.forEach(u=>i(`.${u}`))}let s="";for(let a=0;a<document.styleSheets.length;a++){let l=document.styleSheets[a],u=null;try{u=l.cssRules}catch(c){if(c.name!=="SecurityError")throw c;continue}if(u)for(let c=0;c<u.length;c++){let f=u[c];f.selectorText&&wo(`${f.selectorText} `,n)&&(s+=f.cssText)}}return s}function ju(t,e){let r=document.createElement("style");r.setAttribute("type","text/css"),r.textContent=t;let n=e.hasChildNodes()?e.children[0]:null;e.insertBefore(r,n)}function bo(t){return typeof t=="number"?`${t}px`:t}function Fu(t){let e=t.container??document.body,r=document.createElement("div");return r.setAttribute("class","pfdjs-container"),Object.assign(r.style,{position:"absolute",overflow:"hidden",width:bo(t.width??"100%"),height:bo(t.height??"100%")}),e.appendChild(r),r}var No=class{constructor(t,e){this._eventBus=e,this._init(t??{})}_init(t){let e=this._eventBus;this._container=Fu(t),this._svg=X(this._container).append("svg").attr("width","100%").attr("height","100%").attr("pointer-events","all"),this._rootLayer=this._drawingLayer=this._svg.append("g").attr("class","full-group"),e.on("d3canvas.init",()=>{e.emit("canvas.init",{svg:this._svg}),this.resized()}),e.on("d3canvas.destroy",()=>this._destroy())}_destroy(){this._eventBus.emit("canvas.destroy",{svg:this._svg});let t=this._container?.parentNode;t&&t.removeChild(this._container)}getContainer(){return this._container}getSVG(){return this._svg}getSVGStr(){return Ru(this._svg.node())}getRootLayer(){return this._rootLayer}getDrawingLayer(){return this._drawingLayer}setDrawingLayer(t){this._drawingLayer=t}getTransform(t){let r=(t??this._drawingLayer).attr("transform"),n={a:1,d:1,e:0,f:0};if(!r)return n;let i=document.createElementNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"transform",r);let s=i.transform?.baseVal?.consolidate?.()?.matrix;return s?{a:s.a,d:s.d,e:s.e,f:s.f}:n}getSize(){return{width:this._container.clientWidth,height:this._container.clientHeight}}resized(){this._eventBus.emit("canvas.resized")}};No.$inject=["config","eventBus"];var Hu=class{constructor(){this._ids=new go([8,24,86]),this._elements=new Map}claim(t,e){this._ids.claim(t,e),this._elements.set(t,e)}claimId(t,e){t.id=t.id||this._ids.nextPrefixed(`${e}_`,t),this._ids.claim(t.id,t),this._elements.set(t.id,t)}unClaim(t){t.id&&(this._ids.unclaim(t.id),this._elements.delete(t.id))}removeElement(t){this.unClaim(t)}removeElementById(t){this._ids.unclaim(t),this._elements.delete(t)}get(t){return this._elements.get(t)??!1}getAll(){return Object.fromEntries(this._elements)}},Eo=class{constructor(t){this._elementRegistry=t}create(t,e,r,n){e!==""&&(this._elementRegistry.claimId(t,e),r.call(n,t))}};Eo.$inject=["elementRegistry"];var Mo={__init__:["canvas"],canvas:["type",No],elementRegistry:["type",Hu],elementBuilder:["type",Eo],eventBus:["type",vo]};var ir=Object.prototype.toString,qu=Object.prototype.hasOwnProperty;function on(t){return t===void 0}function Vu(t){return t!==void 0}function So(t){return t==null}function ko(t){return ir.call(t)==="[object Array]"}function Ao(t){return ir.call(t)==="[object Object]"}function Uu(t){let e=ir.call(t);return e==="[object Function]"||e==="[object AsyncFunction]"||e==="[object GeneratorFunction]"||e==="[object AsyncGeneratorFunction]"||e==="[object Proxy]"}function zt(t){return ir.call(t)==="[object String]"}function sn(t,e){return!So(t)&&qu.call(t,e)}function an(t,e){let r=ln(e),n;return j(t,function(i,o){if(r(i,o))return n=i,!1}),n}function Co(t,e){let r=ln(e),n=ko(t)?-1:void 0;return j(t,function(i,o){if(r(i,o))return n=o,!1}),n}function or(t,e){let r=ln(e),n=[];return j(t,function(i,o){r(i,o)&&n.push(i)}),n}function j(t,e){let r,n;if(on(t))return;let i=ko(t)?Gu:Xu;for(let o in t)if(sn(t,o)&&(r=t[o],n=e(r,i(o)),n===!1))return r}function ln(t){return Uu(t)?t:e=>e===t}function Xu(t){return t}function Gu(t){return Number(t)}function Ut(t,e){return t.bind(e)}function Z(t,...e){return Object.assign(t,...e)}function Po(t,e,r){let n=t;return j(e,function(i,o){if(typeof i!="number"&&typeof i!="string")throw new Error("illegal key type: "+typeof i+". Key should be of type number or string.");if(i==="constructor")throw new Error("illegal key: constructor");if(i==="__proto__")throw new Error("illegal key: __proto__");let s=e[o+1],a=n[i];Vu(s)&&So(a)&&(a=n[i]=isNaN(+s)?{}:[]),on(s)?on(r)?delete n[i]:n[i]=r:n=a}),t}function To(t,e){let r={},n=Object(t);return j(e,function(i){i in n&&(r[i]=t[i])}),r}function fn(){}fn.prototype.get=function(t){return this.$model.properties.get(this,t)};fn.prototype.set=function(t,e){this.$model.properties.set(this,t,e)};function Lo(t,e){this.model=t,this.properties=e}Lo.prototype.createType=function(t){var e=this.model,r=this.properties,n=Object.create(fn.prototype);j(t.properties,function(s){!s.isMany&&s.default!==void 0&&(n[s.name]=s.default)}),r.defineModel(n,e),r.defineDescriptor(n,t);var i=t.ns.name;function o(s){r.define(this,"$type",{value:i,enumerable:!0}),r.define(this,"$attrs",{value:{}}),r.define(this,"$parent",{writable:!0}),j(s,Ut(function(a,l){this.set(l,a)},this))}return o.prototype=n,o.hasType=n.$instanceOf=this.model.hasType,r.defineModel(o,e),r.defineDescriptor(o,t),o};var Zu={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},$o={String:function(t){return t},Boolean:function(t){return t==="true"},Integer:function(t){return parseInt(t,10)},Real:function(t){return parseFloat(t)}};function sr(t,e){var r=$o[t];return r?r(e):e}function un(t){return!!Zu[t]}function dn(t){return!!$o[t]}function J(t,e){var r=t.split(/:/),n,i;if(r.length===1)n=t,i=e;else if(r.length===2)n=r[1],i=r[0];else throw new Error("expected <prefix:localName> or <localName>, got "+t);return t=(i?i+":":"")+n,{name:t,prefix:i,localName:n}}function ft(t){this.ns=t,this.name=t.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}ft.prototype.build=function(){return To(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};ft.prototype.addProperty=function(t,e,r){typeof e=="boolean"&&(r=e,e=void 0),this.addNamedProperty(t,r!==!1);var n=this.properties;e!==void 0?n.splice(e,0,t):n.push(t)};ft.prototype.replaceProperty=function(t,e,r){var n=t.ns,i=this.properties,o=this.propertiesByName,s=t.name!==e.name;if(t.isId){if(!e.isId)throw new Error("property <"+e.ns.name+"> must be id property to refine <"+t.ns.name+">");this.setIdProperty(e,!1)}if(t.isBody){if(!e.isBody)throw new Error("property <"+e.ns.name+"> must be body property to refine <"+t.ns.name+">");this.setBodyProperty(e,!1)}var a=i.indexOf(t);if(a===-1)throw new Error("property <"+n.name+"> not found in property list");i.splice(a,1),this.addProperty(e,r?void 0:a,s),o[n.name]=o[n.localName]=e};ft.prototype.redefineProperty=function(t,e,r){var n=t.ns.prefix,i=e.split("#"),o=J(i[0],n),s=J(i[1],o.prefix).name,a=this.propertiesByName[s];if(a)this.replaceProperty(a,t,r);else throw new Error("refined property <"+s+"> not found");delete t.redefines};ft.prototype.addNamedProperty=function(t,e){var r=t.ns,n=this.propertiesByName;e&&(this.assertNotDefined(t,r.name),this.assertNotDefined(t,r.localName)),n[r.name]=n[r.localName]=t};ft.prototype.removeNamedProperty=function(t){var e=t.ns,r=this.propertiesByName;delete r[e.name],delete r[e.localName]};ft.prototype.setBodyProperty=function(t,e){if(e&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+t.ns.name+">)");this.bodyProperty=t};ft.prototype.setIdProperty=function(t,e){if(e&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+t.ns.name+">)");this.idProperty=t};ft.prototype.assertNotTrait=function(t){if((t.extends||[]).length)throw new Error(`cannot create <${t.name}> extending <${t.extends}>`)};ft.prototype.assertNotDefined=function(t,e){var r=t.name,n=this.propertiesByName[r];if(n)throw new Error("property <"+r+"> already defined; override of <"+n.definedBy.ns.name+"#"+n.ns.name+"> by <"+t.definedBy.ns.name+"#"+t.ns.name+"> not allowed without redefines")};ft.prototype.hasProperty=function(t){return this.propertiesByName[t]};ft.prototype.addTrait=function(t,e){e&&this.assertNotTrait(t);var r=this.allTypesByName,n=this.allTypes,i=t.name;i in r||(j(t.properties,Ut(function(o){o=Z({},o,{name:o.ns.localName,inherited:e}),Object.defineProperty(o,"definedBy",{value:t});var s=o.replaces,a=o.redefines;s||a?this.redefineProperty(o,s||a,s):(o.isBody&&this.setBodyProperty(o),o.isId&&this.setIdProperty(o),this.addProperty(o))},this)),n.push(t),r[i]=t)};function Ot(t,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,j(t,Ut(this.registerPackage,this))}Ot.prototype.getPackage=function(t){return this.packageMap[t]};Ot.prototype.getPackages=function(){return this.packages};Ot.prototype.registerPackage=function(t){t=Z({},t);var e=this.packageMap;Bo(e,t,"prefix"),Bo(e,t,"uri"),j(t.types,Ut(function(r){this.registerType(r,t)},this)),e[t.uri]=e[t.prefix]=t,this.packages.push(t)};Ot.prototype.registerType=function(t,e){t=Z({},t,{superClass:(t.superClass||[]).slice(),extends:(t.extends||[]).slice(),properties:(t.properties||[]).slice(),meta:Z(t.meta||{})});var r=J(t.name,e.prefix),n=r.name,i={};j(t.properties,Ut(function(o){var s=J(o.name,r.prefix),a=s.name;un(o.type)||(o.type=J(o.type,s.prefix).name),Z(o,{ns:s,name:a}),i[a]=o},this)),Z(t,{ns:r,name:n,propertiesByName:i}),j(t.extends,Ut(function(o){var s=J(o,r.prefix),a=this.typeMap[s.name];a.traits=a.traits||[],a.traits.push(n)},this)),this.definePackage(t,e),this.typeMap[n]=t};Ot.prototype.mapTypes=function(t,e,r){var n=un(t.name)?{name:t.name}:this.typeMap[t.name],i=this;function o(l,u){var c=J(l,un(l)?"":t.prefix);i.mapTypes(c,e,u)}function s(l){return o(l,!0)}function a(l){return o(l,!1)}if(!n)throw new Error("unknown type <"+t.name+">");j(n.superClass,r?s:a),e(n,!r),j(n.traits,s)};Ot.prototype.getEffectiveDescriptor=function(t){var e=J(t),r=new ft(e);this.mapTypes(e,function(i,o){r.addTrait(i,o)});var n=r.build();return this.definePackage(n,n.allTypes[n.allTypes.length-1].$pkg),n};Ot.prototype.definePackage=function(t,e){this.properties.define(t,"$pkg",{value:e})};function Bo(t,e,r){var n=e[r];if(n in t)throw new Error("package with "+r+" <"+n+"> already defined")}function Xt(t){this.model=t}Xt.prototype.set=function(t,e,r){if(!zt(e)||!e.length)throw new TypeError("property name must be a non-empty string");var n=this.getProperty(t,e),i=n&&n.name;Wu(r)?n?delete t[i]:delete t.$attrs[cn(e)]:n?i in t?t[i]=r:zo(t,n,r):t.$attrs[cn(e)]=r};Xt.prototype.get=function(t,e){var r=this.getProperty(t,e);if(!r)return t.$attrs[cn(e)];var n=r.name;return!t[n]&&r.isMany&&zo(t,r,[]),t[n]};Xt.prototype.define=function(t,e,r){if(!r.writable){var n=r.value;r=Z({},r,{get:function(){return n}}),delete r.value}Object.defineProperty(t,e,r)};Xt.prototype.defineDescriptor=function(t,e){this.define(t,"$descriptor",{value:e})};Xt.prototype.defineModel=function(t,e){this.define(t,"$model",{value:e})};Xt.prototype.getProperty=function(t,e){var r=this.model,n=r.getPropertyDescriptor(t,e);if(n)return n;if(e.includes(":"))return null;let i=r.config.strict;if(typeof i<"u"){let o=new TypeError(`unknown property <${e}> on <${t.$type}>`);if(i)throw o;typeof console<"u"&&console.warn(o)}return null};function Wu(t){return typeof t>"u"}function zo(t,e,r){Object.defineProperty(t,e.name,{enumerable:!e.isReference,writable:!0,value:r,configurable:!0})}function cn(t){return t.replace(/^:/,"")}function dt(t,e={}){this.properties=new Xt(this),this.factory=new Lo(this,this.properties),this.registry=new Ot(t,this.properties),this.typeCache={},this.config=e}dt.prototype.create=function(t,e){var r=this.getType(t);if(!r)throw new Error("unknown type <"+t+">");return new r(e)};dt.prototype.getType=function(t){var e=this.typeCache,r=zt(t)?t:t.ns.name,n=e[r];return n||(t=this.registry.getEffectiveDescriptor(r),n=e[r]=this.factory.createType(t)),n};dt.prototype.createAny=function(t,e,r){var n=J(t),i={$type:t,$instanceOf:function(s){return s===this.$type},get:function(s){return this[s]},set:function(s,a){Po(this,[s],a)}},o={name:t,isGeneric:!0,ns:{prefix:n.prefix,localName:n.localName,uri:e}};return this.properties.defineDescriptor(i,o),this.properties.defineModel(i,this),this.properties.define(i,"get",{enumerable:!1,writable:!0}),this.properties.define(i,"set",{enumerable:!1,writable:!0}),this.properties.define(i,"$parent",{enumerable:!1,writable:!0}),this.properties.define(i,"$instanceOf",{enumerable:!1,writable:!0}),j(r,function(s,a){Ao(s)&&s.value!==void 0?i[s.name]=s.value:i[a]=s}),i};dt.prototype.getPackage=function(t){return this.registry.getPackage(t)};dt.prototype.getPackages=function(){return this.registry.getPackages()};dt.prototype.getElementDescriptor=function(t){return t.$descriptor};dt.prototype.hasType=function(t,e){e===void 0&&(e=t,t=this);var r=t.$model.getElementDescriptor(t);return e in r.allTypesByName};dt.prototype.getPropertyDescriptor=function(t,e){return this.getElementDescriptor(t).propertiesByName[e]};dt.prototype.getTypeDescriptor=function(t){return this.registry.typeMap[t]};var Oo=String.fromCharCode,Yu=Object.prototype.hasOwnProperty,Ku=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,be={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(be).forEach(function(t){be[t.toUpperCase()]=be[t]});function Qu(t,e,r,n){return n?Yu.call(be,n)?be[n]:"&"+n+";":Oo(e||parseInt(r,16))}function Gt(t){return t.length>3&&t.indexOf("&")!==-1?t.replace(Ku,Qu):t}var Ro="non-whitespace outside of root node";function ae(t){return new Error(t)}function Io(t){return"missing namespace for prefix <"+t+">"}function ar(t){return{get:t,enumerable:!0}}function Ju(t){var e={},r;for(r in t)e[r]=t[r];return e}function pn(t){return t+"$uri"}function tc(t){var e={},r,n;for(r in t)n=t[r],e[n]=n,e[pn(n)]=r;return e}function Do(){return{line:0,column:0}}function ec(t){throw t}function hn(t){if(!this)return new hn(t);var e=t&&t.proxy,r,n,i,o,s=ec,a,l,u,c,f=Do,d=!1,m=!1,P=null,A=!1,R;function E(p){p instanceof Error||(p=ae(p)),P=p,s(p,f)}function y(p){a&&(p instanceof Error||(p=ae(p)),a(p,f))}this.on=function(p,_){if(typeof _!="function")throw ae("required args <name, cb>");switch(p){case"openTag":n=_;break;case"text":r=_;break;case"closeTag":i=_;break;case"error":s=_;break;case"warn":a=_;break;case"cdata":o=_;break;case"attention":c=_;break;case"question":u=_;break;case"comment":l=_;break;default:throw ae("unsupported event: "+p)}return this},this.ns=function(p){if(typeof p>"u"&&(p={}),typeof p!="object")throw ae("required args <nsMap={}>");var _={},x;for(x in p)_[x]=p[x];return m=!0,R=_,this},this.parse=function(p){if(typeof p!="string")throw ae("required args <xml=string>");return P=null,M(p),f=Do,A=!1,P},this.stop=function(){A=!0};function M(p){var _=m?[]:null,x=m?tc(R):null,N,T=[],L=0,$=!1,C=!1,v=0,b=0,h,S,g,w,B,z,k,D,q,at="",G=0,Y;function ut(){if(Y!==null)return Y;var K,mt,vt,Ht=m&&x.xmlns,Mt=m&&d?[]:null,V=G,tt=at,qt=tt.length,Ei,Lt,St,wt,F,se={},Mi={},gt,O,I;t:for(;V<qt;V++)if(gt=!1,O=tt.charCodeAt(V),!(O===32||O<14&&O>8)){for((O<65||O>122||O>90&&O<97)&&O!==95&&O!==58&&(y("illegal first char attribute name"),gt=!0),I=V+1;I<qt;I++)if(O=tt.charCodeAt(I),!(O>96&&O<123||O>64&&O<91||O>47&&O<59||O===46||O===45||O===95)){if(O===32||O<14&&O>8){y("missing attribute value"),V=I;continue t}if(O===61)break;y("illegal attribute name char"),gt=!0}if(F=tt.substring(V,I),F==="xmlns:xmlns"&&(y("illegal declaration of xmlns"),gt=!0),O=tt.charCodeAt(I+1),O===34)I=tt.indexOf('"',V=I+2),I===-1&&(I=tt.indexOf("'",V),I!==-1&&(y("attribute value quote missmatch"),gt=!0));else if(O===39)I=tt.indexOf("'",V=I+2),I===-1&&(I=tt.indexOf('"',V),I!==-1&&(y("attribute value quote missmatch"),gt=!0));else for(y("missing attribute value quotes"),gt=!0,I=I+1;I<qt&&(O=tt.charCodeAt(I+1),!(O===32||O<14&&O>8));I++);for(I===-1&&(y("missing closing quotes"),I=qt,gt=!0),gt||(St=tt.substring(V,I)),V=I;I+1<qt&&(O=tt.charCodeAt(I+1),!(O===32||O<14&&O>8));I++)V===I&&(y("illegal character after attribute end"),gt=!0);if(V=I+1,gt)continue t;if(F in Mi){y("attribute <"+F+"> already defined");continue}if(Mi[F]=!0,!m){se[F]=St;continue}if(d){if(Lt=F==="xmlns"?"xmlns":F.charCodeAt(0)===120&&F.substr(0,6)==="xmlns:"?F.substr(6):null,Lt!==null){if(K=Gt(St),mt=pn(Lt),wt=R[K],!wt){if(Lt==="xmlns"||mt in x&&x[mt]!==K)do wt="ns"+L++;while(typeof x[wt]<"u");else wt=Lt;R[K]=wt}x[Lt]!==wt&&(Ei||(x=Ju(x),Ei=!0),x[Lt]=wt,Lt==="xmlns"&&(x[pn(wt)]=K,Ht=wt),x[mt]=K),se[F]=St;continue}Mt.push(F,St);continue}if(O=F.indexOf(":"),O===-1){se[F]=St;continue}if(!(vt=x[F.substring(0,O)])){y(Io(F.substring(0,O)));continue}F=Ht===vt?F.substr(O+1):vt+F.substr(O),se[F]=St}if(d)for(V=0,qt=Mt.length;V<qt;V++){if(F=Mt[V++],St=Mt[V],O=F.indexOf(":"),O!==-1){if(!(vt=x[F.substring(0,O)])){y(Io(F.substring(0,O)));continue}F=Ht===vt?F.substr(O+1):vt+F.substr(O)}se[F]=St}return Y=se}function ct(){for(var K=/(\r\n|\r|\n)/g,mt=0,vt=0,Ht=0,Mt=b,V,tt;v>=Ht&&(V=K.exec(p),!(!V||(Mt=V[0].length+V.index,Mt>v)));)mt+=1,Ht=Mt;return v==-1?(vt=Mt,tt=p.substring(b)):b===0?tt=p.substring(b,v):(vt=v-Ht,tt=b==-1?p.substring(v):p.substring(v,b+1)),{data:tt,line:mt,column:vt}}for(f=ct,e&&(q=Object.create({},{name:ar(function(){return k}),originalName:ar(function(){return D}),attrs:ar(ut),ns:ar(function(){return x})}));b!==-1;){if(p.charCodeAt(b)===60?v=b:v=p.indexOf("<",b),v===-1){if(T.length)return E("unexpected end of file");if(b===0)return E("missing start tag");b<p.length&&p.substring(b).trim()&&y(Ro);return}if(b!==v){if(T.length){if(r&&(r(p.substring(b,v),Gt,f),A))return}else if(p.substring(b,v).trim()&&(y(Ro),A))return}if(w=p.charCodeAt(v+1),w===33){if(g=p.charCodeAt(v+2),g===91&&p.substr(v+3,6)==="CDATA["){if(b=p.indexOf("]]>",v),b===-1)return E("unclosed cdata");if(o&&(o(p.substring(v+9,b),f),A))return;b+=3;continue}if(g===45&&p.charCodeAt(v+3)===45){if(b=p.indexOf("-->",v),b===-1)return E("unclosed comment");if(l&&(l(p.substring(v+4,b),Gt,f),A))return;b+=3;continue}}if(w===63){if(b=p.indexOf("?>",v),b===-1)return E("unclosed question");if(u&&(u(p.substring(v,b+2),f),A))return;b+=2;continue}for(h=v+1;;h++){if(B=p.charCodeAt(h),isNaN(B))return b=-1,E("unclosed tag");if(B===34)g=p.indexOf('"',h+1),h=g!==-1?g:h;else if(B===39)g=p.indexOf("'",h+1),h=g!==-1?g:h;else if(B===62){b=h;break}}if(w===33){if(c&&(c(p.substring(v,b+1),Gt,f),A))return;b+=1;continue}if(Y={},w===47){if($=!1,C=!0,!T.length)return E("missing open tag");if(h=k=T.pop(),g=v+2+h.length,p.substring(v+2,g)!==h)return E("closing tag mismatch");for(;g<b;g++)if(w=p.charCodeAt(g),!(w===32||w>8&&w<14))return E("close tag")}else{if(p.charCodeAt(b-1)===47?(h=k=p.substring(v+1,b-1),$=!0,C=!0):(h=k=p.substring(v+1,b),$=!0,C=!1),!(w>96&&w<123||w>64&&w<91||w===95||w===58))return E("illegal first char nodeName");for(g=1,S=h.length;g<S;g++)if(w=h.charCodeAt(g),!(w>96&&w<123||w>64&&w<91||w>47&&w<59||w===45||w===95||w==46)){if(w===32||w<14&&w>8){k=h.substring(0,g),Y=null;break}return E("invalid nodeName")}C||T.push(k)}if(m){if(N=x,$&&(C||_.push(N),Y===null&&(d=h.indexOf("xmlns",g)!==-1)&&(G=g,at=h,ut(),d=!1)),D=k,w=k.indexOf(":"),w!==-1){if(z=x[k.substring(0,w)],!z)return E("missing namespace on <"+D+">");k=k.substr(w+1)}else z=x.xmlns;z&&(k=z+":"+k)}if($&&(G=g,at=h,n&&(e?n(q,Gt,C,f):n(k,ut,Gt,C,f),A)))return;if(C){if(i&&(i(e?q:k,Gt,$,f),A))return;m&&($?x=N:x=_.pop())}b+=1}}}function jo(t){return t.xml&&t.xml.tagAlias==="lowerCase"}var mn={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},Fo="property";function Ho(t){return t.xml&&t.xml.serialize}function rc(t){let e=Ho(t);return e!==Fo&&(e||null)}function nc(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qo(t,e){return jo(e)?t.prefix+":"+nc(t.localName):t.name}function ic(t,e){var r=t.name,n=t.localName,i=e&&e.xml&&e.xml.typePrefix;return i&&n.indexOf(i)===0?t.prefix+":"+n.slice(i.length):r}function oc(t,e,r){let n=J(t,e.xmlns),i=`${e[n.prefix]||n.prefix}:${n.localName}`,o=J(i);var s=r.getPackage(o.prefix);return ic(o,s)}function Rt(t){return new Error(t)}function Pt(t){return t.$descriptor}function sc(t){Z(this,t),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw Rt("expected element");var r=this.elementsById,n=Pt(e),i=n.idProperty,o;if(i&&(o=e.get(i.name),o)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(o))throw new Error("illegal ID <"+o+">");if(r[o])throw Rt("duplicate ID <"+o+">");r[o]=e}},this.addWarning=function(e){this.warnings.push(e)}}function Ne(){}Ne.prototype.handleEnd=function(){};Ne.prototype.handleText=function(){};Ne.prototype.handleNode=function(){};function gn(){}gn.prototype=Object.create(Ne.prototype);gn.prototype.handleNode=function(){return this};function ue(){}ue.prototype=Object.create(Ne.prototype);ue.prototype.handleText=function(t){this.body=(this.body||"")+t};function Ee(t,e){this.property=t,this.context=e}Ee.prototype=Object.create(ue.prototype);Ee.prototype.handleNode=function(t){if(this.element)throw Rt("expected no sub nodes");return this.element=this.createReference(t),this};Ee.prototype.handleEnd=function(){this.element.id=this.body};Ee.prototype.createReference=function(t){return{property:this.property.ns.name,id:""}};function _n(t,e){this.element=e,this.propertyDesc=t}_n.prototype=Object.create(ue.prototype);_n.prototype.handleEnd=function(){var t=this.body||"",e=this.element,r=this.propertyDesc;t=sr(r.type,t),r.isMany?e.get(r.name).push(t):e.set(r.name,t)};function lr(){}lr.prototype=Object.create(ue.prototype);lr.prototype.handleNode=function(t){var e=this,r=this.element;return r?e=this.handleChild(t):(r=this.element=this.createElement(t),this.context.addElement(r)),e};function it(t,e,r){this.model=t,this.type=t.getType(e),this.context=r}it.prototype=Object.create(lr.prototype);it.prototype.addReference=function(t){this.context.addReference(t)};it.prototype.handleText=function(t){var e=this.element,r=Pt(e),n=r.bodyProperty;if(!n)throw Rt("unexpected body text <"+t+">");ue.prototype.handleText.call(this,t)};it.prototype.handleEnd=function(){var t=this.body,e=this.element,r=Pt(e),n=r.bodyProperty;n&&t!==void 0&&(t=sr(n.type,t),e.set(n.name,t))};it.prototype.createElement=function(t){var e=t.attributes,r=this.type,n=Pt(r),i=this.context,o=new r({}),s=this.model,a;return j(e,function(l,u){var c=n.propertiesByName[u],f;c&&c.isReference?c.isMany?(f=l.split(" "),j(f,function(d){i.addReference({element:o,property:c.ns.name,id:d})})):i.addReference({element:o,property:c.ns.name,id:l}):(c?l=sr(c.type,l):u==="xmlns"?u=":"+u:(a=J(u,n.ns.prefix),s.getPackage(a.prefix)&&i.addWarning({message:"unknown attribute <"+u+">",element:o,property:u,value:l})),o.set(u,l))}),o};it.prototype.getPropertyForNode=function(t){var e=t.name,r=J(e),n=this.type,i=this.model,o=Pt(n),s=r.name,a=o.propertiesByName[s];if(a&&!a.isAttr){let u=rc(a);if(u){let c=t.attributes[u];if(c){let f=oc(c,t.ns,i),d=i.getType(f);return Z({},a,{effectiveType:Pt(d).name})}}return a}var l=i.getPackage(r.prefix);if(l){let u=qo(r,l),c=i.getType(u);if(a=an(o.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&c.hasType(f.type)}),a)return Z({},a,{effectiveType:Pt(c).name})}else if(a=an(o.properties,function(u){return!u.isReference&&!u.isAttribute&&u.type==="Element"}),a)return a;throw Rt("unrecognized element <"+r.name+">")};it.prototype.toString=function(){return"ElementDescriptor["+Pt(this.type).name+"]"};it.prototype.valueHandler=function(t,e){return new _n(t,e)};it.prototype.referenceHandler=function(t){return new Ee(t,this.context)};it.prototype.handler=function(t){return t==="Element"?new le(this.model,t,this.context):new it(this.model,t,this.context)};it.prototype.handleChild=function(t){var e,r,n,i;if(e=this.getPropertyForNode(t),n=this.element,r=e.effectiveType||e.type,dn(r))return this.valueHandler(e,n);e.isReference?i=this.referenceHandler(e).handleNode(t):i=this.handler(r).handleNode(t);var o=i.element;return o!==void 0&&(e.isMany?n.get(e.name).push(o):n.set(e.name,o),e.isReference?(Z(o,{element:n}),this.context.addReference(o)):o.$parent=n),i};function yn(t,e,r){it.call(this,t,e,r)}yn.prototype=Object.create(it.prototype);yn.prototype.createElement=function(t){var e=t.name,r=J(e),n=this.model,i=this.type,o=n.getPackage(r.prefix),s=o&&qo(r,o)||e;if(!i.hasType(s))throw Rt("unexpected element <"+t.originalName+">");return it.prototype.createElement.call(this,t)};function le(t,e,r){this.model=t,this.context=r}le.prototype=Object.create(lr.prototype);le.prototype.createElement=function(t){var e=t.name,r=J(e),n=r.prefix,i=t.ns[n+"$uri"],o=t.attributes;return this.model.createAny(e,i,o)};le.prototype.handleChild=function(t){var e=new le(this.model,"Element",this.context).handleNode(t),r=this.element,n=e.element,i;return n!==void 0&&(i=r.$children=r.$children||[],i.push(n),n.$parent=r),e};le.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function ur(t){t instanceof dt&&(t={model:t}),Z(this,{lax:!1},t)}ur.prototype.fromXML=function(t,e,r){var n=e.rootHandler;e instanceof it?(n=e,e={}):typeof e=="string"?(n=this.handler(e),e={}):typeof n=="string"&&(n=this.handler(n));var i=this.model,o=this.lax,s=new sc(Z({},e,{rootHandler:n})),a=new hn({proxy:!0}),l=ac();n.context=s,l.push(n);function u(_,x,N){var T=x(),L=T.line,$=T.column,C=T.data;C.charAt(0)==="<"&&C.indexOf(" ")!==-1&&(C=C.slice(0,C.indexOf(" "))+">");var v="unparsable content "+(C?C+" ":"")+`detected
2
- line: `+L+`
3
- column: `+$+`
4
- nested error: `+_.message;if(N)return s.addWarning({message:v,error:_}),!0;throw Rt(v)}function c(_,x){return u(_,x,!0)}function f(){var _=s.elementsById,x=s.references,N,T;for(N=0;T=x[N];N++){var L=T.element,$=_[T.id],C=Pt(L).propertiesByName[T.property];if($||s.addWarning({message:"unresolved reference <"+T.id+">",element:T.element,property:T.property,value:T.id}),C.isMany){var v=L.get(C.name),b=v.indexOf(T);b===-1&&(b=v.length),$?v[b]=$:v.splice(b,1)}else L.set(C.name,$)}}function d(){l.pop().handleEnd()}var m=/^<\?xml /i,P=/ encoding="([^"]+)"/i,A=/^utf-8$/i;function R(_){if(m.test(_)){var x=P.exec(_),N=x&&x[1];!N||A.test(N)||s.addWarning({message:"unsupported document encoding <"+N+">, falling back to UTF-8"})}}function E(_,x){var N=l.peek();try{l.push(N.handleNode(_))}catch(T){u(T,x,o)&&l.push(new gn)}}function y(_,x){try{l.peek().handleText(_)}catch(N){c(N,x)}}function M(_,x){_.trim()&&y(_,x)}var p=i.getPackages().reduce(function(_,x){return _[x.uri]=x.prefix,_},Object.entries(mn).reduce(function(_,[x,N]){return _[N]=x,_},i.config&&i.config.nsMap||{}));return a.ns(p).on("openTag",function(_,x,N,T){var L=_.attrs||{},$=Object.keys(L).reduce(function(v,b){var h=x(L[b]);return v[b]=h,v},{}),C={name:_.name,originalName:_.originalName,attributes:$,ns:_.ns};E(C,T)}).on("question",R).on("closeTag",d).on("cdata",y).on("text",function(_,x,N){M(x(_),N)}).on("error",u).on("warn",c),new Promise(function(_,x){var N;try{a.parse(t),f()}catch(v){N=v}var T=n.element;!N&&!T&&(N=Rt("failed to parse document as <"+n.type.$descriptor.name+">"));var L=s.warnings,$=s.references,C=s.elementsById;return N?(N.warnings=L,x(N)):_({rootElement:T,elementsById:C,references:$,warnings:L})})};ur.prototype.handler=function(t){return new yn(this.model,t)};function ac(){var t=[];return Object.defineProperty(t,"peek",{value:function(){return this[this.length-1]}}),t}var lc=`<?xml version="1.0" encoding="UTF-8"?>
5
- `,uc=/<|>|'|"|&|\n\r|\n/g,Vo=/<|>|&/g;function bt(t){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=t,this.defaultPrefixMap=t&&t.defaultPrefixMap||{}}bt.prototype.mapDefaultPrefixes=function(t){this.defaultPrefixMap=t};bt.prototype.defaultUriByPrefix=function(t){return this.defaultPrefixMap[t]};bt.prototype.byUri=function(t){return this.uriMap[t]||this.parent&&this.parent.byUri(t)};bt.prototype.add=function(t,e){this.uriMap[t.uri]=t,e?this.wellknown.push(t):this.custom.push(t),this.mapPrefix(t.prefix,t.uri)};bt.prototype.uriByPrefix=function(t){return this.prefixMap[t||"xmlns"]||this.parent&&this.parent.uriByPrefix(t)};bt.prototype.mapPrefix=function(t,e){this.prefixMap[t||"xmlns"]=e};bt.prototype.getNSKey=function(t){return t.prefix!==void 0?t.uri+"|"+t.prefix:t.uri};bt.prototype.logUsed=function(t){var e=t.uri,r=this.getNSKey(t);this.used[r]=this.byUri(e),this.parent&&this.parent.logUsed(t)};bt.prototype.getUsed=function(t){var e=[].concat(this.wellknown,this.custom);return e.filter(r=>{var n=this.getNSKey(r);return this.used[n]})};function cc(t){return t.charAt(0).toLowerCase()+t.slice(1)}function fc(t,e){return jo(e)?cc(t):t}function Uo(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}function Xo(t){return zt(t)?t:(t.prefix?t.prefix+":":"")+t.localName}function dc(t){return t.getUsed().filter(function(e){return e.prefix!=="xml"}).map(function(e){var r="xmlns"+(e.prefix?":"+e.prefix:"");return{name:r,value:e.uri}})}function pc(t,e){return e.isGeneric?Z({localName:e.ns.localName},t):Z({localName:fc(e.ns.localName,e.$pkg)},t)}function hc(t,e){return Z({localName:e.ns.localName},t)}function mc(t){var e=t.$descriptor;return or(e.properties,function(r){var n=r.name;if(r.isVirtual||!sn(t,n))return!1;var i=t[n];return i===r.default||i===null?!1:r.isMany?i.length:!0})}var gc={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},_c={"<":"lt",">":"gt","&":"amp"};function Go(t,e,r){return t=zt(t)?t:""+t,t.replace(e,function(n){return"&"+r[n]+";"})}function yc(t){return Go(t,uc,gc)}function xc(t){return Go(t,Vo,_c)}function vc(t){return or(t,function(e){return e.isAttr})}function wc(t){return or(t,function(e){return!e.isAttr})}function xn(t){this.tagName=t}xn.prototype.build=function(t){return this.element=t,this};xn.prototype.serializeTo=function(t){t.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function Zt(){}Zt.prototype.serializeValue=Zt.prototype.serializeTo=function(t){t.append(this.escape?xc(this.value):this.value)};Zt.prototype.build=function(t,e){return this.value=e,t.type==="String"&&e.search(Vo)!==-1&&(this.escape=!0),this};function vn(t){this.tagName=t}Uo(vn,Zt);vn.prototype.serializeTo=function(t){t.appendIndent().append("<"+this.tagName+">"),this.serializeValue(t),t.append("</"+this.tagName+">").appendNewLine()};function H(t,e){this.body=[],this.attrs=[],this.parent=t,this.propertyDescriptor=e}H.prototype.build=function(t){this.element=t;var e=t.$descriptor,r=this.propertyDescriptor,n,i,o=e.isGeneric;return o?n=this.parseGenericNsAttributes(t):n=this.parseNsAttributes(t),r?this.ns=this.nsPropertyTagName(r):this.ns=this.nsTagName(e),this.tagName=this.addTagName(this.ns),o?this.parseGenericContainments(t):(i=mc(t),this.parseAttributes(vc(i)),this.parseContainments(wc(i))),this.parseGenericAttributes(t,n),this};H.prototype.nsTagName=function(t){var e=this.logNamespaceUsed(t.ns);return pc(e,t)};H.prototype.nsPropertyTagName=function(t){var e=this.logNamespaceUsed(t.ns);return hc(e,t)};H.prototype.isLocalNs=function(t){return t.uri===this.ns.uri};H.prototype.nsAttributeName=function(t){var e;if(zt(t)?e=J(t):e=t.ns,t.inherited)return{localName:e.localName};var r=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(r),this.isLocalNs(r)?{localName:e.localName}:Z({localName:e.localName},r)};H.prototype.parseGenericNsAttributes=function(t){return Object.entries(t).filter(([e,r])=>!e.startsWith("$")&&this.parseNsAttribute(t,e,r)).map(([e,r])=>({name:e,value:r}))};H.prototype.parseGenericContainments=function(t){var e=t.$body;e&&this.body.push(new Zt().build({type:"String"},e));var r=t.$children;r&&j(r,n=>{this.body.push(new H(this).build(n))})};H.prototype.parseNsAttribute=function(t,e,r){var n=t.$model,i=J(e),o;if(i.prefix==="xmlns"&&(o={prefix:i.localName,uri:r}),!i.prefix&&i.localName==="xmlns"&&(o={uri:r}),!o)return{name:e,value:r};if(n&&n.getPackage(r))this.logNamespace(o,!0,!0);else{var s=this.logNamespaceUsed(o,!0);this.getNamespaces().logUsed(s)}};H.prototype.parseNsAttributes=function(t){var e=this,r=t.$attrs,n=[];return j(r,function(i,o){var s=e.parseNsAttribute(t,o,i);s&&n.push(s)}),n};H.prototype.parseGenericAttributes=function(t,e){var r=this;j(e,function(n){try{r.addAttribute(r.nsAttributeName(n.name),n.value)}catch(i){typeof console<"u"&&console.warn(`missing namespace information for <${n.name}=${n.value}> on`,t,i)}})};H.prototype.parseContainments=function(t){var e=this,r=this.body,n=this.element;j(t,function(i){var o=n.get(i.name),s=i.isReference,a=i.isMany;if(a||(o=[o]),i.isBody)r.push(new Zt().build(i,o[0]));else if(dn(i.type))j(o,function(u){r.push(new vn(e.addTagName(e.nsPropertyTagName(i))).build(i,u))});else if(s)j(o,function(u){r.push(new xn(e.addTagName(e.nsPropertyTagName(i))).build(u))});else{var l=Ho(i);j(o,function(u){var c;l?l===Fo?c=new H(e,i):c=new cr(e,i,l):c=new H(e),r.push(c.build(u))})}})};H.prototype.getNamespaces=function(t){var e=this.namespaces,r=this.parent,n;return e||(n=r&&r.getNamespaces(),t||!n?this.namespaces=e=new bt(n):e=n),e};H.prototype.logNamespace=function(t,e,r){var n=this.getNamespaces(r),i=t.uri,o=t.prefix,s=n.byUri(i);return(!s||r)&&n.add(t,e),n.mapPrefix(o,i),t};H.prototype.logNamespaceUsed=function(t,e){var r=this.getNamespaces(e),n=t.prefix,i=t.uri,o,s,a;if(!n&&!i)return{localName:t.localName};if(a=r.defaultUriByPrefix(n),i=i||a||r.uriByPrefix(n),!i)throw new Error("no namespace uri given for prefix <"+n+">");if(t=r.byUri(i),!t&&!n&&(t=this.logNamespace({uri:i},a===i,!0)),!t){for(o=n,s=1;r.uriByPrefix(o);)o=n+"_"+s++;t=this.logNamespace({prefix:o,uri:i},a===i)}return n&&r.mapPrefix(n,i),t};H.prototype.parseAttributes=function(t){var e=this,r=this.element;j(t,function(n){var i=r.get(n.name);if(n.isReference)if(!n.isMany)i=i.id;else{var o=[];j(i,function(s){o.push(s.id)}),i=o.join(" ")}e.addAttribute(e.nsAttributeName(n),i)})};H.prototype.addTagName=function(t){var e=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(e),Xo(t)};H.prototype.addAttribute=function(t,e){var r=this.attrs;zt(e)&&(e=yc(e));var n=Co(r,function(o){return o.name.localName===t.localName&&o.name.uri===t.uri&&o.name.prefix===t.prefix}),i={name:t,value:e};n!==-1?r.splice(n,1,i):r.push(i)};H.prototype.serializeAttributes=function(t){var e=this.attrs,r=this.namespaces;r&&(e=dc(r).concat(e)),j(e,function(n){t.append(" ").append(Xo(n.name)).append('="').append(n.value).append('"')})};H.prototype.serializeTo=function(t){var e=this.body[0],r=e&&e.constructor!==Zt;t.appendIndent().append("<"+this.tagName),this.serializeAttributes(t),t.append(e?">":" />"),e&&(r&&t.appendNewLine().indent(),j(this.body,function(n){n.serializeTo(t)}),r&&t.unindent().appendIndent(),t.append("</"+this.tagName+">")),t.appendNewLine()};function cr(t,e,r){H.call(this,t,e),this.serialization=r}Uo(cr,H);cr.prototype.parseNsAttributes=function(t){var e=H.prototype.parseNsAttributes.call(this,t).filter(s=>s.name!==this.serialization),r=t.$descriptor;if(r.name===this.propertyDescriptor.type)return e;var n=this.typeNs=this.nsTagName(r);this.getNamespaces().logUsed(this.typeNs);var i=t.$model.getPackage(n.uri),o=i.xml&&i.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(n.prefix?n.prefix+":":"")+o+r.ns.localName),e};cr.prototype.isLocalNs=function(t){return t.uri===(this.typeNs||this.ns).uri};function bc(){this.value="",this.write=function(t){this.value+=t}}function Nc(t,e){var r=[""];this.append=function(n){return t.write(n),this},this.appendNewLine=function(){return e&&t.write(`
6
- `),this},this.appendIndent=function(){return e&&t.write(r.join(" ")),this},this.indent=function(){return r.push(""),this},this.unindent=function(){return r.pop(),this}}function Zo(t){t=Z({format:!1,preamble:!0},t||{});function e(r,n){var i=n||new bc,o=new Nc(i,t.format);t.preamble&&o.append(lc);var s=new H,a=r.$model;if(s.getNamespaces().mapDefaultPrefixes(Ec(a)),s.build(r).serializeTo(o),!n)return i.value}return{toXML:e}}function Ec(t){let e=t.config&&t.config.nsMap||{},r={};for(let n in mn)r[n]=mn[n];for(let n in e){let i=e[n];r[i]=n}for(let n of t.getPackages())r[n.prefix]=n.uri;return r}var Mc={name:"Process Flow Diagram Definition",uri:"http://pfdn",associations:[],types:[{name:"Statusable",isAbstract:!0,properties:[{name:"status",type:"Real",isAttr:!0,default:0}]},{name:"Base",isAbstract:!0,superClass:["Statusable"],properties:[{name:"id",type:"String",isAttr:!0,isId:!0},{name:"name",type:"String",isAttr:!0}]},{name:"Property",superClass:["Statusable"],properties:[{name:"name",type:"String",isAttr:!0},{name:"type",type:"String",isAttr:!0,default:"string"},{name:"value",type:"String",isAttr:!0,default:""}]},{name:"PropertiesSet",superClass:["Statusable"],properties:[{name:"id",type:"String",isAttr:!0,isId:!0},{name:"property",type:"Property",isMany:!0,xml:{serialize:"xsi:type"}}]},{name:"Coordinates",properties:[{name:"x",type:"Real",isAttr:!0,default:0},{name:"y",type:"Real",isAttr:!0,default:0}]},{name:"Zoom",superClass:["Statusable"],properties:[{name:"offset",type:"Coordinates",default:{x:0,y:0,scale:2},xml:{serialize:"xsi:type"}},{name:"scale",type:"Real",default:1}]},{name:"Grid",properties:[{name:"show",type:"Boolean",isAttr:!0,default:!0},{name:"lineColor",type:"String",isAttr:!0,default:"#dddddd"},{name:"size",type:"Real",isAttr:!0,default:25},{name:"lineWidth",type:"Real",isAttr:!0,default:1}]},{name:"Settings",superClass:["Base"],properties:[{name:"author",type:"String",default:"No Author",isAttr:!0},{name:"backgroundColor",type:"String",default:"#ffffff",isAttr:!0},{name:"zoom",type:"Zoom",xml:{serialize:"xsi:type"}},{name:"grid",type:"Grid",xml:{serialize:"xsi:type"}}]},{name:"Label",superClass:["Base"],properties:[{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"isReadOnly",type:"Boolean",isAttr:!0,default:!1},{name:"text",type:"String"},{name:"color",type:"String",isAttr:!0,default:"#303030"},{name:"fontSize",type:"Real",isAttr:!0,default:13}]},{name:"Node",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"type",type:"String",isAttr:!0,default:"default"},{name:"tag",isAttr:!0,type:"String"},{name:"propertiesSet",type:"PropertiesSet",isAttr:!0,isReference:!0},{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"size",type:"Real",isAttr:!0,default:25}]},{name:"Border",properties:[{name:"lineWidth",type:"Real",isAttr:!0,default:1},{name:"lineColor",type:"String",isAttr:!0,default:"#dddddd"}]},{name:"Zone",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"width",type:"Real",isAttr:!0,default:25},{name:"height",type:"Real",isAttr:!0,default:25},{name:"fillColor",type:"String",isAttr:!0,default:"#dddddd"},{name:"opacity",type:"Real",isAttr:!0,default:.6},{name:"border",type:"Border",xml:{serialize:"xsi:type"}}]},{name:"Link",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"source",type:"String",isAttr:!0,isReference:!0},{name:"target",type:"String",isAttr:!0,isReference:!0},{name:"lineColor",type:"String",isAttr:!0,default:"#000000"},{name:"lineWidth",type:"Real",isAttr:!0,default:4},{name:"fillColor",type:"String",isAttr:!0,default:"#ffffff"},{name:"waypoint",type:"Coordinates",isMany:!0,xml:{serialize:"xsi:type"}},{name:"tag",isAttr:!0,type:"String"},{name:"propertiesSet",type:"PropertiesSet",isAttr:!0,isReference:!0}]},{name:"Diagram",superClass:["Base"],properties:[{name:"settings",type:"Settings",xml:{serialize:"xsi:type"}},{name:"node",type:"Node",isMany:!0,xml:{serialize:"xsi:type"}},{name:"link",type:"Link",isMany:!0,xml:{serialize:"xsi:type"}},{name:"label",type:"Label",isMany:!0,xml:{serialize:"xsi:type"}},{name:"zone",type:"Zone",isMany:!0,xml:{serialize:"xsi:type"}},{name:"propertiesSet",type:"PropertiesSet",isMany:!0,xml:{serialize:"xsi:type"}}]}],prefix:"pfdn",xml:{tagAlias:"lowerCase"}},Sc=class extends dt{async fromXML(t,e="pfdn:Diagram",r={}){return new ur({model:this,lax:!0,...r}).fromXML(t,e)}toXML(t,e={}){return new Zo(e).toXML(t)}},kc={pfdn:Mc};function wn(t={},e){return new Sc({...kc,...t},e)}var Ac={value:()=>{}};function Yo(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new fr(r)}function fr(t){this._=t}function Cc(t,e){return t.trim().split(/^|\s+/).map(function(r){var n="",i=r.indexOf(".");if(i>=0&&(n=r.slice(i+1),r=r.slice(0,i)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}fr.prototype=Yo.prototype={constructor:fr,on:function(t,e){var r=this._,n=Cc(t+"",r),i,o=-1,s=n.length;if(arguments.length<2){for(;++o<s;)if((i=(t=n[o]).type)&&(i=Pc(r[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<s;)if(i=(t=n[o]).type)r[i]=Wo(r[i],t.name,e);else if(e==null)for(i in r)r[i]=Wo(r[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new fr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var r=new Array(i),n=0,i,o;n<i;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],n=0,i=o.length;n<i;++n)o[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],i=0,o=n.length;i<o;++i)n[i].value.apply(e,r)}};function Pc(t,e){for(var r=0,n=t.length,i;r<n;++r)if((i=t[r]).name===e)return i.value}function Wo(t,e,r){for(var n=0,i=t.length;n<i;++n)if(t[n].name===e){t[n]=Ac,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var Wt=Yo;var Ko={passive:!1},Yt={capture:!0,passive:!1};function dr(t){t.stopImmediatePropagation()}function It(t){t.preventDefault(),t.stopImmediatePropagation()}function Me(t){var e=t.document.documentElement,r=X(t).on("dragstart.drag",It,Yt);"onselectstart"in e?r.on("selectstart.drag",It,Yt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Se(t,e){var r=t.document.documentElement,n=X(t).on("dragstart.drag",null);e&&(n.on("click.drag",It,Yt),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in r?n.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}var ke=t=>()=>t;function Ae(t,{sourceEvent:e,subject:r,target:n,identifier:i,active:o,x:s,y:a,dx:l,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Ae.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Tc(t){return!t.ctrlKey&&!t.button}function Bc(){return this.parentNode}function Lc(t,e){return e??{x:t.x,y:t.y}}function $c(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ce(){var t=Tc,e=Bc,r=Lc,n=$c,i={},o=Wt("start","drag","end"),s=0,a,l,u,c,f=0;function d(p){p.on("mousedown.drag",m).filter(n).on("touchstart.drag",R).on("touchmove.drag",E,Ko).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(p,_){if(!(c||!t.call(this,p,_))){var x=M(this,e.call(this,p,_),p,_,"mouse");x&&(X(p.view).on("mousemove.drag",P,Yt).on("mouseup.drag",A,Yt),Me(p.view),dr(p),u=!1,a=p.clientX,l=p.clientY,x("start",p))}}function P(p){if(It(p),!u){var _=p.clientX-a,x=p.clientY-l;u=_*_+x*x>f}i.mouse("drag",p)}function A(p){X(p.view).on("mousemove.drag mouseup.drag",null),Se(p.view,u),It(p),i.mouse("end",p)}function R(p,_){if(t.call(this,p,_)){var x=p.changedTouches,N=e.call(this,p,_),T=x.length,L,$;for(L=0;L<T;++L)($=M(this,N,p,_,x[L].identifier,x[L]))&&(dr(p),$("start",p,x[L]))}}function E(p){var _=p.changedTouches,x=_.length,N,T;for(N=0;N<x;++N)(T=i[_[N].identifier])&&(It(p),T("drag",p,_[N]))}function y(p){var _=p.changedTouches,x=_.length,N,T;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),N=0;N<x;++N)(T=i[_[N].identifier])&&(dr(p),T("end",p,_[N]))}function M(p,_,x,N,T,L){var $=o.copy(),C=Q(L||x,_),v,b,h;if((h=r.call(p,new Ae("beforestart",{sourceEvent:x,target:d,identifier:T,active:s,x:C[0],y:C[1],dx:0,dy:0,dispatch:$}),N))!=null)return v=h.x-C[0]||0,b=h.y-C[1]||0,function S(g,w,B){var z=C,k;switch(g){case"start":i[T]=S,k=s++;break;case"end":delete i[T],--s;case"drag":C=Q(B||w,_),k=s;break}$.call(g,p,new Ae(g,{sourceEvent:w,subject:h,target:d,identifier:T,active:k,x:C[0]+v,y:C[1]+b,dx:C[0]-z[0],dy:C[1]-z[1],dispatch:$}),N)}}return d.filter=function(p){return arguments.length?(t=typeof p=="function"?p:ke(!!p),d):t},d.container=function(p){return arguments.length?(e=typeof p=="function"?p:ke(p),d):e},d.subject=function(p){return arguments.length?(r=typeof p=="function"?p:ke(p),d):r},d.touchable=function(p){return arguments.length?(n=typeof p=="function"?p:ke(!!p),d):n},d.on=function(){var p=o.on.apply(o,arguments);return p===o?d:p},d.clickDistance=function(p){return arguments.length?(f=(p=+p)*p,d):Math.sqrt(f)},d}function pr(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function bn(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function Be(){}var Pe=.7,gr=1/Pe,ce="\\s*([+-]?\\d+)\\s*",Te="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zc=/^#([0-9a-f]{3,8})$/,Oc=new RegExp(`^rgb\\(${ce},${ce},${ce}\\)$`),Rc=new RegExp(`^rgb\\(${Nt},${Nt},${Nt}\\)$`),Ic=new RegExp(`^rgba\\(${ce},${ce},${ce},${Te}\\)$`),Dc=new RegExp(`^rgba\\(${Nt},${Nt},${Nt},${Te}\\)$`),jc=new RegExp(`^hsl\\(${Te},${Nt},${Nt}\\)$`),Fc=new RegExp(`^hsla\\(${Te},${Nt},${Nt},${Te}\\)$`),Qo={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};pr(Be,yt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Jo,formatHex:Jo,formatHex8:Hc,formatHsl:qc,formatRgb:ts,toString:ts});function Jo(){return this.rgb().formatHex()}function Hc(){return this.rgb().formatHex8()}function qc(){return ss(this).formatHsl()}function ts(){return this.rgb().formatRgb()}function yt(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=zc.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?es(e):r===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?hr(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?hr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Oc.exec(t))?new lt(e[1],e[2],e[3],1):(e=Rc.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Ic.exec(t))?hr(e[1],e[2],e[3],e[4]):(e=Dc.exec(t))?hr(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=jc.exec(t))?is(e[1],e[2]/100,e[3]/100,1):(e=Fc.exec(t))?is(e[1],e[2]/100,e[3]/100,e[4]):Qo.hasOwnProperty(t)?es(Qo[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function es(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function hr(t,e,r,n){return n<=0&&(t=e=r=NaN),new lt(t,e,r,n)}function Vc(t){return t instanceof Be||(t=yt(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function fe(t,e,r,n){return arguments.length===1?Vc(t):new lt(t,e,r,n??1)}function lt(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}pr(lt,fe,bn(Be,{brighter(t){return t=t==null?gr:Math.pow(gr,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Pe:Math.pow(Pe,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(Qt(this.r),Qt(this.g),Qt(this.b),_r(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rs,formatHex:rs,formatHex8:Uc,formatRgb:ns,toString:ns}));function rs(){return`#${Kt(this.r)}${Kt(this.g)}${Kt(this.b)}`}function Uc(){return`#${Kt(this.r)}${Kt(this.g)}${Kt(this.b)}${Kt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ns(){let t=_r(this.opacity);return`${t===1?"rgb(":"rgba("}${Qt(this.r)}, ${Qt(this.g)}, ${Qt(this.b)}${t===1?")":`, ${t})`}`}function _r(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Qt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Kt(t){return t=Qt(t),(t<16?"0":"")+t.toString(16)}function is(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new _t(t,e,r,n)}function ss(t){if(t instanceof _t)return new _t(t.h,t.s,t.l,t.opacity);if(t instanceof Be||(t=yt(t)),!t)return new _t;if(t instanceof _t)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),o=Math.max(e,r,n),s=NaN,a=o-i,l=(o+i)/2;return a?(e===o?s=(r-n)/a+(r<n)*6:r===o?s=(n-e)/a+2:s=(e-r)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new _t(s,a,l,t.opacity)}function as(t,e,r,n){return arguments.length===1?ss(t):new _t(t,e,r,n??1)}function _t(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}pr(_t,as,bn(Be,{brighter(t){return t=t==null?gr:Math.pow(gr,t),new _t(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Pe:Math.pow(Pe,t),new _t(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new lt(Nn(t>=240?t-240:t+120,i,n),Nn(t,i,n),Nn(t<120?t+240:t-120,i,n),this.opacity)},clamp(){return new _t(os(this.h),mr(this.s),mr(this.l),_r(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=_r(this.opacity);return`${t===1?"hsl(":"hsla("}${os(this.h)}, ${mr(this.s)*100}%, ${mr(this.l)*100}%${t===1?")":`, ${t})`}`}}));function os(t){return t=(t||0)%360,t<0?t+360:t}function mr(t){return Math.max(0,Math.min(1,t||0))}function Nn(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}function En(t,e,r,n,i){var o=t*t,s=o*t;return((1-3*t+3*o-s)*e+(4-6*o+3*s)*r+(1+3*t+3*o-3*s)*n+s*i)/6}function ls(t){var e=t.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,e-1):Math.floor(r*e),i=t[n],o=t[n+1],s=n>0?t[n-1]:2*i-o,a=n<e-1?t[n+2]:2*o-i;return En((r-n/e)*e,s,i,o,a)}}function us(t){var e=t.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*e),i=t[(n+e-1)%e],o=t[n%e],s=t[(n+1)%e],a=t[(n+2)%e];return En((r-n/e)*e,i,o,s,a)}}var Le=t=>()=>t;function Xc(t,e){return function(r){return t+r*e}}function Gc(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function cs(t){return(t=+t)==1?yr:function(e,r){return r-e?Gc(e,r,t):Le(isNaN(e)?r:e)}}function yr(t,e){var r=e-t;return r?Xc(t,r):Le(isNaN(t)?e:t)}var Jt=(function t(e){var r=cs(e);function n(i,o){var s=r((i=fe(i)).r,(o=fe(o)).r),a=r(i.g,o.g),l=r(i.b,o.b),u=yr(i.opacity,o.opacity);return function(c){return i.r=s(c),i.g=a(c),i.b=l(c),i.opacity=u(c),i+""}}return n.gamma=t,n})(1);function fs(t){return function(e){var r=e.length,n=new Array(r),i=new Array(r),o=new Array(r),s,a;for(s=0;s<r;++s)a=fe(e[s]),n[s]=a.r||0,i[s]=a.g||0,o[s]=a.b||0;return n=t(n),i=t(i),o=t(o),a.opacity=1,function(l){return a.r=n(l),a.g=i(l),a.b=o(l),a+""}}}var Zc=fs(ls),Wc=fs(us);function ds(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),i;return function(o){for(i=0;i<r;++i)n[i]=t[i]*(1-o)+e[i]*o;return n}}function ps(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function hs(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,i=new Array(n),o=new Array(r),s;for(s=0;s<n;++s)i[s]=te(t[s],e[s]);for(;s<r;++s)o[s]=e[s];return function(a){for(s=0;s<n;++s)o[s]=i[s](a);return o}}function ms(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function et(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function gs(t,e){var r={},n={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?r[i]=te(t[i],e[i]):n[i]=e[i];return function(o){for(i in r)n[i]=r[i](o);return n}}var Sn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mn=new RegExp(Sn.source,"g");function Yc(t){return function(){return t}}function Kc(t){return function(e){return t(e)+""}}function $e(t,e){var r=Sn.lastIndex=Mn.lastIndex=0,n,i,o,s=-1,a=[],l=[];for(t=t+"",e=e+"";(n=Sn.exec(t))&&(i=Mn.exec(e));)(o=i.index)>r&&(o=e.slice(r,o),a[s]?a[s]+=o:a[++s]=o),(n=n[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:et(n,i)})),r=Mn.lastIndex;return r<e.length&&(o=e.slice(r),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?Kc(l[0].x):Yc(e):(e=l.length,function(u){for(var c=0,f;c<e;++c)a[(f=l[c]).i]=f.x(u);return a.join("")})}function te(t,e){var r=typeof e,n;return e==null||r==="boolean"?Le(e):(r==="number"?et:r==="string"?(n=yt(e))?(e=n,Jt):$e:e instanceof yt?Jt:e instanceof Date?ms:ps(e)?ds:Array.isArray(e)?hs:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?gs:et)(t,e)}function kn(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}var _s=180/Math.PI,xr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function An(t,e,r,n,i,o){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*r+e*n)&&(r-=t*l,n-=e*l),(a=Math.sqrt(r*r+n*n))&&(r/=a,n/=a,l/=a),t*n<e*r&&(t=-t,e=-e,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*_s,skewX:Math.atan(l)*_s,scaleX:s,scaleY:a}}var vr;function ys(t){let e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?xr:An(e.a,e.b,e.c,e.d,e.e,e.f)}function xs(t){return t==null?xr:(vr||(vr=document.createElementNS("http://www.w3.org/2000/svg","g")),vr.setAttribute("transform",t),(t=vr.transform.baseVal.consolidate())?(t=t.matrix,An(t.a,t.b,t.c,t.d,t.e,t.f)):xr)}function vs(t,e,r,n){function i(u){return u.length?u.pop()+" ":""}function o(u,c,f,d,m,P){if(u!==f||c!==d){var A=m.push("translate(",null,e,null,r);P.push({i:A-4,x:et(u,f)},{i:A-2,x:et(c,d)})}else(f||d)&&m.push("translate("+f+e+d+r)}function s(u,c,f,d){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),d.push({i:f.push(i(f)+"rotate(",null,n)-2,x:et(u,c)})):c&&f.push(i(f)+"rotate("+c+n)}function a(u,c,f,d){u!==c?d.push({i:f.push(i(f)+"skewX(",null,n)-2,x:et(u,c)}):c&&f.push(i(f)+"skewX("+c+n)}function l(u,c,f,d,m,P){if(u!==f||c!==d){var A=m.push(i(m)+"scale(",null,",",null,")");P.push({i:A-4,x:et(u,f)},{i:A-2,x:et(c,d)})}else(f!==1||d!==1)&&m.push(i(m)+"scale("+f+","+d+")")}return function(u,c){var f=[],d=[];return u=t(u),c=t(c),o(u.translateX,u.translateY,c.translateX,c.translateY,f,d),s(u.rotate,c.rotate,f,d),a(u.skewX,c.skewX,f,d),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,f,d),u=c=null,function(m){for(var P=-1,A=d.length,R;++P<A;)f[(R=d[P]).i]=R.x(m);return f.join("")}}}var Cn=vs(ys,"px, ","px)","deg)"),Pn=vs(xs,", ",")",")");var Qc=1e-12;function ws(t){return((t=Math.exp(t))+1/t)/2}function Jc(t){return((t=Math.exp(t))-1/t)/2}function tf(t){return((t=Math.exp(2*t))-1)/(t+1)}var Tn=(function t(e,r,n){function i(o,s){var a=o[0],l=o[1],u=o[2],c=s[0],f=s[1],d=s[2],m=c-a,P=f-l,A=m*m+P*P,R,E;if(A<Qc)E=Math.log(d/u)/e,R=function(N){return[a+N*m,l+N*P,u*Math.exp(e*N*E)]};else{var y=Math.sqrt(A),M=(d*d-u*u+n*A)/(2*u*r*y),p=(d*d-u*u-n*A)/(2*d*r*y),_=Math.log(Math.sqrt(M*M+1)-M),x=Math.log(Math.sqrt(p*p+1)-p);E=(x-_)/e,R=function(N){var T=N*E,L=ws(_),$=u/(r*y)*(L*tf(e*T+_)-Jc(_));return[a+$*m,l+$*P,u*L/ws(e*T+_)]}}return R.duration=E*1e3*e/Math.SQRT2,R}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return t(s,a,l)},i})(Math.SQRT2,2,4);var de=0,Oe=0,ze=0,Ns=1e3,wr,Re,br=0,ee=0,Nr=0,Ie=typeof performance=="object"&&performance.now?performance:Date,Es=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function je(){return ee||(Es(ef),ee=Ie.now()+Nr)}function ef(){ee=0}function De(){this._call=this._time=this._next=null}De.prototype=Er.prototype={constructor:De,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?je():+r)+(e==null?0:+e),!this._next&&Re!==this&&(Re?Re._next=this:wr=this,Re=this),this._call=t,this._time=r,Bn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bn())}};function Er(t,e,r){var n=new De;return n.restart(t,e,r),n}function Ms(){je(),++de;for(var t=wr,e;t;)(e=ee-t._time)>=0&&t._call.call(void 0,e),t=t._next;--de}function bs(){ee=(br=Ie.now())+Nr,de=Oe=0;try{Ms()}finally{de=0,nf(),ee=0}}function rf(){var t=Ie.now(),e=t-br;e>Ns&&(Nr-=e,br=t)}function nf(){for(var t,e=wr,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:wr=r);Re=t,Bn(n)}function Bn(t){if(!de){Oe&&(Oe=clearTimeout(Oe));var e=t-ee;e>24?(t<1/0&&(Oe=setTimeout(bs,t-Ie.now()-Nr)),ze&&(ze=clearInterval(ze))):(ze||(br=Ie.now(),ze=setInterval(rf,Ns)),de=1,Es(bs))}}function Mr(t,e,r){var n=new De;return e=e==null?0:+e,n.restart(i=>{n.stop(),t(i+e)},e,r),n}var of=Wt("start","end","cancel","interrupt"),sf=[],As=0,Ss=1,kr=2,Sr=3,ks=4,Ar=5,Fe=6;function Dt(t,e,r,n,i,o){var s=t.__transition;if(!s)t.__transition={};else if(r in s)return;af(t,r,{name:e,index:n,group:i,on:of,tween:sf,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:As})}function He(t,e){var r=W(t,e);if(r.state>As)throw new Error("too late; already scheduled");return r}function rt(t,e){var r=W(t,e);if(r.state>Sr)throw new Error("too late; already running");return r}function W(t,e){var r=t.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function af(t,e,r){var n=t.__transition,i;n[e]=r,r.timer=Er(o,0,r.time);function o(u){r.state=Ss,r.timer.restart(s,r.delay,r.time),r.delay<=u&&s(u-r.delay)}function s(u){var c,f,d,m;if(r.state!==Ss)return l();for(c in n)if(m=n[c],m.name===r.name){if(m.state===Sr)return Mr(s);m.state===ks?(m.state=Fe,m.timer.stop(),m.on.call("interrupt",t,t.__data__,m.index,m.group),delete n[c]):+c<e&&(m.state=Fe,m.timer.stop(),m.on.call("cancel",t,t.__data__,m.index,m.group),delete n[c])}if(Mr(function(){r.state===Sr&&(r.state=ks,r.timer.restart(a,r.delay,r.time),a(u))}),r.state=kr,r.on.call("start",t,t.__data__,r.index,r.group),r.state===kr){for(r.state=Sr,i=new Array(d=r.tween.length),c=0,f=-1;c<d;++c)(m=r.tween[c].value.call(t,t.__data__,r.index,r.group))&&(i[++f]=m);i.length=f+1}}function a(u){for(var c=u<r.duration?r.ease.call(null,u/r.duration):(r.timer.restart(l),r.state=Ar,1),f=-1,d=i.length;++f<d;)i[f].call(t,c);r.state===Ar&&(r.on.call("end",t,t.__data__,r.index,r.group),l())}function l(){r.state=Fe,r.timer.stop(),delete n[e];for(var u in n)return;delete t.__transition}}function re(t,e){var r=t.__transition,n,i,o=!0,s;if(r){e=e==null?null:e+"";for(s in r){if((n=r[s]).name!==e){o=!1;continue}i=n.state>kr&&n.state<Ar,n.state=Fe,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete r[s]}o&&delete t.__transition}}function Cs(t){return this.each(function(){re(this,t)})}function lf(t,e){var r,n;return function(){var i=rt(this,t),o=i.tween;if(o!==r){n=r=o;for(var s=0,a=n.length;s<a;++s)if(n[s].name===e){n=n.slice(),n.splice(s,1);break}}i.tween=n}}function uf(t,e,r){var n,i;if(typeof r!="function")throw new Error;return function(){var o=rt(this,t),s=o.tween;if(s!==n){i=(n=s).slice();for(var a={name:e,value:r},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=a;break}l===u&&i.push(a)}o.tween=i}}function Ps(t,e){var r=this._id;if(t+="",arguments.length<2){for(var n=W(this.node(),r).tween,i=0,o=n.length,s;i<o;++i)if((s=n[i]).name===t)return s.value;return null}return this.each((e==null?lf:uf)(r,t,e))}function pe(t,e,r){var n=t._id;return t.each(function(){var i=rt(this,n);(i.value||(i.value={}))[e]=r.apply(this,arguments)}),function(i){return W(i,n).value[e]}}function Cr(t,e){var r;return(typeof e=="number"?et:e instanceof yt?Jt:(r=yt(e))?(e=r,Jt):$e)(t,e)}function cf(t){return function(){this.removeAttribute(t)}}function ff(t){return function(){this.removeAttributeNS(t.space,t.local)}}function df(t,e,r){var n,i=r+"",o;return function(){var s=this.getAttribute(t);return s===i?null:s===n?o:o=e(n=s,r)}}function pf(t,e,r){var n,i=r+"",o;return function(){var s=this.getAttributeNS(t.space,t.local);return s===i?null:s===n?o:o=e(n=s,r)}}function hf(t,e,r){var n,i,o;return function(){var s,a=r(this),l;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=a+"",s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a)))}}function mf(t,e,r){var n,i,o;return function(){var s,a=r(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=a+"",s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a)))}}function Ts(t,e){var r=kt(t),n=r==="transform"?Pn:Cr;return this.attrTween(t,typeof e=="function"?(r.local?mf:hf)(r,n,pe(this,"attr."+t,e)):e==null?(r.local?ff:cf)(r):(r.local?pf:df)(r,n,e))}function gf(t,e){return function(r){this.setAttribute(t,e.call(this,r))}}function _f(t,e){return function(r){this.setAttributeNS(t.space,t.local,e.call(this,r))}}function yf(t,e){var r,n;function i(){var o=e.apply(this,arguments);return o!==n&&(r=(n=o)&&_f(t,o)),r}return i._value=e,i}function xf(t,e){var r,n;function i(){var o=e.apply(this,arguments);return o!==n&&(r=(n=o)&&gf(t,o)),r}return i._value=e,i}function Bs(t,e){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;var n=kt(t);return this.tween(r,(n.local?yf:xf)(n,e))}function vf(t,e){return function(){He(this,t).delay=+e.apply(this,arguments)}}function wf(t,e){return e=+e,function(){He(this,t).delay=e}}function Ls(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?vf:wf)(e,t)):W(this.node(),e).delay}function bf(t,e){return function(){rt(this,t).duration=+e.apply(this,arguments)}}function Nf(t,e){return e=+e,function(){rt(this,t).duration=e}}function $s(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?bf:Nf)(e,t)):W(this.node(),e).duration}function Ef(t,e){if(typeof e!="function")throw new Error;return function(){rt(this,t).ease=e}}function zs(t){var e=this._id;return arguments.length?this.each(Ef(e,t)):W(this.node(),e).ease}function Mf(t,e){return function(){var r=e.apply(this,arguments);if(typeof r!="function")throw new Error;rt(this,t).ease=r}}function Os(t){if(typeof t!="function")throw new Error;return this.each(Mf(this._id,t))}function Rs(t){typeof t!="function"&&(t=xe(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&a.push(l);return new st(n,this._parents,this._name,this._id)}function Is(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,r=t._groups,n=e.length,i=r.length,o=Math.min(n,i),s=new Array(n),a=0;a<o;++a)for(var l=e[a],u=r[a],c=l.length,f=s[a]=new Array(c),d,m=0;m<c;++m)(d=l[m]||u[m])&&(f[m]=d);for(;a<n;++a)s[a]=e[a];return new st(s,this._parents,this._name,this._id)}function Sf(t){return(t+"").trim().split(/^|\s+/).every(function(e){var r=e.indexOf(".");return r>=0&&(e=e.slice(0,r)),!e||e==="start"})}function kf(t,e,r){var n,i,o=Sf(e)?He:rt;return function(){var s=o(this,t),a=s.on;a!==n&&(i=(n=a).copy()).on(e,r),s.on=i}}function Ds(t,e){var r=this._id;return arguments.length<2?W(this.node(),r).on.on(t):this.each(kf(r,t,e))}function Af(t){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==t)return;e&&e.removeChild(this)}}function js(){return this.on("end.remove",Af(this._id))}function Fs(t){var e=this._name,r=this._id;typeof t!="function"&&(t=Vt(t));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,u=o[s]=new Array(l),c,f,d=0;d<l;++d)(c=a[d])&&(f=t.call(c,c.__data__,d,a))&&("__data__"in c&&(f.__data__=c.__data__),u[d]=f,Dt(u[d],e,r,d,u,W(c,r)));return new st(o,this._parents,e,r)}function Hs(t){var e=this._name,r=this._id;typeof t!="function"&&(t=ye(t));for(var n=this._groups,i=n.length,o=[],s=[],a=0;a<i;++a)for(var l=n[a],u=l.length,c,f=0;f<u;++f)if(c=l[f]){for(var d=t.call(c,c.__data__,f,l),m,P=W(c,r),A=0,R=d.length;A<R;++A)(m=d[A])&&Dt(m,e,r,A,d,P);o.push(d),s.push(c)}return new st(o,s,e,r)}var Cf=At.prototype.constructor;function qs(){return new Cf(this._groups,this._parents)}function Pf(t,e){var r,n,i;return function(){var o=$t(this,t),s=(this.style.removeProperty(t),$t(this,t));return o===s?null:o===r&&s===n?i:i=e(r=o,n=s)}}function Vs(t){return function(){this.style.removeProperty(t)}}function Tf(t,e,r){var n,i=r+"",o;return function(){var s=$t(this,t);return s===i?null:s===n?o:o=e(n=s,r)}}function Bf(t,e,r){var n,i,o;return function(){var s=$t(this,t),a=r(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),$t(this,t))),s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a))}}function Lf(t,e){var r,n,i,o="style."+e,s="end."+o,a;return function(){var l=rt(this,t),u=l.on,c=l.value[o]==null?a||(a=Vs(e)):void 0;(u!==r||i!==c)&&(n=(r=u).copy()).on(s,i=c),l.on=n}}function Us(t,e,r){var n=(t+="")=="transform"?Cn:Cr;return e==null?this.styleTween(t,Pf(t,n)).on("end.style."+t,Vs(t)):typeof e=="function"?this.styleTween(t,Bf(t,n,pe(this,"style."+t,e))).each(Lf(this._id,t)):this.styleTween(t,Tf(t,n,e),r).on("end.style."+t,null)}function $f(t,e,r){return function(n){this.style.setProperty(t,e.call(this,n),r)}}function zf(t,e,r){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&$f(t,s,r)),n}return o._value=e,o}function Xs(t,e,r){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,zf(t,e,r??""))}function Of(t){return function(){this.textContent=t}}function Rf(t){return function(){var e=t(this);this.textContent=e??""}}function Gs(t){return this.tween("text",typeof t=="function"?Rf(pe(this,"text",t)):Of(t==null?"":t+""))}function If(t){return function(e){this.textContent=t.call(this,e)}}function Df(t){var e,r;function n(){var i=t.apply(this,arguments);return i!==r&&(e=(r=i)&&If(i)),e}return n._value=t,n}function Zs(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Df(t))}function Ws(){for(var t=this._name,e=this._id,r=Pr(),n=this._groups,i=n.length,o=0;o<i;++o)for(var s=n[o],a=s.length,l,u=0;u<a;++u)if(l=s[u]){var c=W(l,e);Dt(l,t,r,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new st(n,this._parents,t,r)}function Ys(){var t,e,r=this,n=r._id,i=r.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};r.each(function(){var u=rt(this,n),c=u.on;c!==t&&(e=(t=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),i===0&&o()})}var jf=0;function st(t,e,r,n){this._groups=t,this._parents=e,this._name=r,this._id=n}function Ks(t){return At().transition(t)}function Pr(){return++jf}var Tt=At.prototype;st.prototype=Ks.prototype={constructor:st,select:Fs,selectAll:Hs,selectChild:Tt.selectChild,selectChildren:Tt.selectChildren,filter:Rs,merge:Is,selection:qs,transition:Ws,call:Tt.call,nodes:Tt.nodes,node:Tt.node,size:Tt.size,empty:Tt.empty,each:Tt.each,on:Ds,attr:Ts,attrTween:Bs,style:Us,styleTween:Xs,text:Gs,textTween:Zs,remove:js,tween:Ps,delay:Ls,duration:$s,ease:zs,easeVarying:Os,end:Ys,[Symbol.iterator]:Tt[Symbol.iterator]};function Tr(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Ff={time:null,delay:0,duration:250,ease:Tr};function Hf(t,e){for(var r;!(r=t.__transition)||!(r=r[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return r}function Qs(t){var e,r;t instanceof st?(e=t._id,t=t._name):(e=Pr(),(r=Ff).time=je(),t=t==null?null:t+"");for(var n=this._groups,i=n.length,o=0;o<i;++o)for(var s=n[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&Dt(l,t,e,u,s,r||Hf(l,e));return new st(n,this._parents,t,e)}At.prototype.interrupt=Cs;At.prototype.transition=Qs;var qe=t=>()=>t;function Ln(t,{sourceEvent:e,target:r,transform:n,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:i}})}function xt(t,e,r){this.k=t,this.x=e,this.y=r}xt.prototype={constructor:xt,scale:function(t){return t===1?this:new xt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new xt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Bt=new xt(1,0,0);$n.prototype=xt.prototype;function $n(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Bt;return t.__zoom}function Br(t){t.stopImmediatePropagation()}function he(t){t.preventDefault(),t.stopImmediatePropagation()}function qf(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Vf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Js(){return this.__zoom||Bt}function Uf(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Xf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gf(t,e,r){var n=t.invertX(e[0][0])-r[0][0],i=t.invertX(e[1][0])-r[1][0],o=t.invertY(e[0][1])-r[0][1],s=t.invertY(e[1][1])-r[1][1];return t.translate(i>n?(n+i)/2:Math.min(0,n)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function zn(){var t=qf,e=Vf,r=Gf,n=Uf,i=Xf,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Tn,u=Wt("start","zoom","end"),c,f,d,m=500,P=150,A=0,R=10;function E(h){h.property("__zoom",Js).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",$).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",v).on("touchend.zoom touchcancel.zoom",b).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(h,S,g,w){var B=h.selection?h.selection():h;B.property("__zoom",Js),h!==B?_(h,S,g,w):B.interrupt().each(function(){x(this,arguments).event(w).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},E.scaleBy=function(h,S,g,w){E.scaleTo(h,function(){var B=this.__zoom.k,z=typeof S=="function"?S.apply(this,arguments):S;return B*z},g,w)},E.scaleTo=function(h,S,g,w){E.transform(h,function(){var B=e.apply(this,arguments),z=this.__zoom,k=g==null?p(B):typeof g=="function"?g.apply(this,arguments):g,D=z.invert(k),q=typeof S=="function"?S.apply(this,arguments):S;return r(M(y(z,q),k,D),B,s)},g,w)},E.translateBy=function(h,S,g,w){E.transform(h,function(){return r(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof g=="function"?g.apply(this,arguments):g),e.apply(this,arguments),s)},null,w)},E.translateTo=function(h,S,g,w,B){E.transform(h,function(){var z=e.apply(this,arguments),k=this.__zoom,D=w==null?p(z):typeof w=="function"?w.apply(this,arguments):w;return r(Bt.translate(D[0],D[1]).scale(k.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof g=="function"?-g.apply(this,arguments):-g),z,s)},w,B)};function y(h,S){return S=Math.max(o[0],Math.min(o[1],S)),S===h.k?h:new xt(S,h.x,h.y)}function M(h,S,g){var w=S[0]-g[0]*h.k,B=S[1]-g[1]*h.k;return w===h.x&&B===h.y?h:new xt(h.k,w,B)}function p(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function _(h,S,g,w){h.on("start.zoom",function(){x(this,arguments).event(w).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(w).end()}).tween("zoom",function(){var B=this,z=arguments,k=x(B,z).event(w),D=e.apply(B,z),q=g==null?p(D):typeof g=="function"?g.apply(B,z):g,at=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),G=B.__zoom,Y=typeof S=="function"?S.apply(B,z):S,ut=l(G.invert(q).concat(at/G.k),Y.invert(q).concat(at/Y.k));return function(ct){if(ct===1)ct=Y;else{var K=ut(ct),mt=at/K[2];ct=new xt(mt,q[0]-K[0]*mt,q[1]-K[1]*mt)}k.zoom(null,ct)}})}function x(h,S,g){return!g&&h.__zooming||new N(h,S)}function N(h,S){this.that=h,this.args=S,this.active=0,this.sourceEvent=null,this.extent=e.apply(h,S),this.taps=0}N.prototype={event:function(h){return h&&(this.sourceEvent=h),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(h,S){return this.mouse&&h!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&h!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&h!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(h){var S=X(this.that).datum();u.call(h,this.that,new Ln(h,{sourceEvent:this.sourceEvent,target:E,type:h,transform:this.that.__zoom,dispatch:u}),S)}};function T(h,...S){if(!t.apply(this,arguments))return;var g=x(this,S).event(h),w=this.__zoom,B=Math.max(o[0],Math.min(o[1],w.k*Math.pow(2,n.apply(this,arguments)))),z=Q(h);if(g.wheel)(g.mouse[0][0]!==z[0]||g.mouse[0][1]!==z[1])&&(g.mouse[1]=w.invert(g.mouse[0]=z)),clearTimeout(g.wheel);else{if(w.k===B)return;g.mouse=[z,w.invert(z)],re(this),g.start()}he(h),g.wheel=setTimeout(k,P),g.zoom("mouse",r(M(y(w,B),g.mouse[0],g.mouse[1]),g.extent,s));function k(){g.wheel=null,g.end()}}function L(h,...S){if(d||!t.apply(this,arguments))return;var g=h.currentTarget,w=x(this,S,!0).event(h),B=X(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",at,!0),z=Q(h,g),k=h.clientX,D=h.clientY;Me(h.view),Br(h),w.mouse=[z,this.__zoom.invert(z)],re(this),w.start();function q(G){if(he(G),!w.moved){var Y=G.clientX-k,ut=G.clientY-D;w.moved=Y*Y+ut*ut>A}w.event(G).zoom("mouse",r(M(w.that.__zoom,w.mouse[0]=Q(G,g),w.mouse[1]),w.extent,s))}function at(G){B.on("mousemove.zoom mouseup.zoom",null),Se(G.view,w.moved),he(G),w.event(G).end()}}function $(h,...S){if(t.apply(this,arguments)){var g=this.__zoom,w=Q(h.changedTouches?h.changedTouches[0]:h,this),B=g.invert(w),z=g.k*(h.shiftKey?.5:2),k=r(M(y(g,z),w,B),e.apply(this,S),s);he(h),a>0?X(this).transition().duration(a).call(_,k,w,h):X(this).call(E.transform,k,w,h)}}function C(h,...S){if(t.apply(this,arguments)){var g=h.touches,w=g.length,B=x(this,S,h.changedTouches.length===w).event(h),z,k,D,q;for(Br(h),k=0;k<w;++k)D=g[k],q=Q(D,this),q=[q,this.__zoom.invert(q),D.identifier],B.touch0?!B.touch1&&B.touch0[2]!==q[2]&&(B.touch1=q,B.taps=0):(B.touch0=q,z=!0,B.taps=1+!!c);c&&(c=clearTimeout(c)),z&&(B.taps<2&&(f=q[0],c=setTimeout(function(){c=null},m)),re(this),B.start())}}function v(h,...S){if(this.__zooming){var g=x(this,S).event(h),w=h.changedTouches,B=w.length,z,k,D,q;for(he(h),z=0;z<B;++z)k=w[z],D=Q(k,this),g.touch0&&g.touch0[2]===k.identifier?g.touch0[0]=D:g.touch1&&g.touch1[2]===k.identifier&&(g.touch1[0]=D);if(k=g.that.__zoom,g.touch1){var at=g.touch0[0],G=g.touch0[1],Y=g.touch1[0],ut=g.touch1[1],ct=(ct=Y[0]-at[0])*ct+(ct=Y[1]-at[1])*ct,K=(K=ut[0]-G[0])*K+(K=ut[1]-G[1])*K;k=y(k,Math.sqrt(ct/K)),D=[(at[0]+Y[0])/2,(at[1]+Y[1])/2],q=[(G[0]+ut[0])/2,(G[1]+ut[1])/2]}else if(g.touch0)D=g.touch0[0],q=g.touch0[1];else return;g.zoom("touch",r(M(k,D,q),g.extent,s))}}function b(h,...S){if(this.__zooming){var g=x(this,S).event(h),w=h.changedTouches,B=w.length,z,k;for(Br(h),d&&clearTimeout(d),d=setTimeout(function(){d=null},m),z=0;z<B;++z)k=w[z],g.touch0&&g.touch0[2]===k.identifier?delete g.touch0:g.touch1&&g.touch1[2]===k.identifier&&delete g.touch1;if(g.touch1&&!g.touch0&&(g.touch0=g.touch1,delete g.touch1),g.touch0)g.touch0[1]=this.__zoom.invert(g.touch0[0]);else if(g.end(),g.taps===2&&(k=Q(k,this),Math.hypot(f[0]-k[0],f[1]-k[1])<R)){var D=X(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return E.wheelDelta=function(h){return arguments.length?(n=typeof h=="function"?h:qe(+h),E):n},E.filter=function(h){return arguments.length?(t=typeof h=="function"?h:qe(!!h),E):t},E.touchable=function(h){return arguments.length?(i=typeof h=="function"?h:qe(!!h),E):i},E.extent=function(h){return arguments.length?(e=typeof h=="function"?h:qe([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),E):e},E.scaleExtent=function(h){return arguments.length?(o[0]=+h[0],o[1]=+h[1],E):[o[0],o[1]]},E.translateExtent=function(h){return arguments.length?(s[0][0]=+h[0][0],s[1][0]=+h[1][0],s[0][1]=+h[0][1],s[1][1]=+h[1][1],E):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},E.constrain=function(h){return arguments.length?(r=h,E):r},E.duration=function(h){return arguments.length?(a=+h,E):a},E.interpolate=function(h){return arguments.length?(l=h,E):l},E.on=function(){var h=u.on.apply(u,arguments);return h===u?E:h},E.clickDistance=function(h){return arguments.length?(A=(h=+h)*h,E):Math.sqrt(A)},E.tapDistance=function(h){return arguments.length?(R=+h,E):R},E}function ne(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function On(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Lr(t){let e,r,n;t.length!==2?(e=ne,r=(a,l)=>ne(t(a),l),n=(a,l)=>t(a)-l):(e=t===ne||t===On?t:Zf,r=t,n=t);function i(a,l,u=0,c=a.length){if(u<c){if(e(l,l)!==0)return c;do{let f=u+c>>>1;r(a[f],l)<0?u=f+1:c=f}while(u<c)}return u}function o(a,l,u=0,c=a.length){if(u<c){if(e(l,l)!==0)return c;do{let f=u+c>>>1;r(a[f],l)<=0?u=f+1:c=f}while(u<c)}return u}function s(a,l,u=0,c=a.length){let f=i(a,l,u,c-1);return f>u&&n(a[f-1],l)>-n(a[f],l)?f-1:f}return{left:i,center:s,right:o}}function Zf(){return 0}function Rn(t){return t===null?NaN:+t}var ta=Lr(ne),ea=ta.right,Wf=ta.left,Yf=Lr(Rn).center,In=ea;var Kf=Math.sqrt(50),Qf=Math.sqrt(10),Jf=Math.sqrt(2);function $r(t,e,r){let n=(e-t)/Math.max(0,r),i=Math.floor(Math.log10(n)),o=n/Math.pow(10,i),s=o>=Kf?10:o>=Qf?5:o>=Jf?2:1,a,l,u;return i<0?(u=Math.pow(10,-i)/s,a=Math.round(t*u),l=Math.round(e*u),a/u<t&&++a,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*s,a=Math.round(t/u),l=Math.round(e/u),a*u<t&&++a,l*u>e&&--l),l<a&&.5<=r&&r<2?$r(t,e,r*2):[a,l,u]}function zr(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];let n=e<t,[i,o,s]=n?$r(e,t,r):$r(t,e,r);if(!(o>=i))return[];let a=o-i+1,l=new Array(a);if(n)if(s<0)for(let u=0;u<a;++u)l[u]=(o-u)/-s;else for(let u=0;u<a;++u)l[u]=(o-u)*s;else if(s<0)for(let u=0;u<a;++u)l[u]=(i+u)/-s;else for(let u=0;u<a;++u)l[u]=(i+u)*s;return l}function Ve(t,e,r){return e=+e,t=+t,r=+r,$r(t,e,r)[2]}function Dn(t,e,r){e=+e,t=+t,r=+r;let n=e<t,i=n?Ve(e,t,r):Ve(t,e,r);return(n?-1:1)*(i<0?1/-i:i)}function ra(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function jn(t){return function(){return t}}function Fn(t){return+t}var na=[0,1];function me(t){return t}function Hn(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:jn(isNaN(e)?NaN:.5)}function td(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function ed(t,e,r){var n=t[0],i=t[1],o=e[0],s=e[1];return i<n?(n=Hn(i,n),o=r(s,o)):(n=Hn(n,i),o=r(o,s)),function(a){return o(n(a))}}function rd(t,e,r){var n=Math.min(t.length,e.length)-1,i=new Array(n),o=new Array(n),s=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<n;)i[s]=Hn(t[s],t[s+1]),o[s]=r(e[s],e[s+1]);return function(a){var l=In(t,a,1,n)-1;return o[l](i[l](a))}}function ia(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function nd(){var t=na,e=na,r=te,n,i,o,s=me,a,l,u;function c(){var d=Math.min(t.length,e.length);return s!==me&&(s=td(t[0],t[d-1])),a=d>2?rd:ed,l=u=null,f}function f(d){return d==null||isNaN(d=+d)?o:(l||(l=a(t.map(n),e,r)))(n(s(d)))}return f.invert=function(d){return s(i((u||(u=a(e,t.map(n),et)))(d)))},f.domain=function(d){return arguments.length?(t=Array.from(d,Fn),c()):t.slice()},f.range=function(d){return arguments.length?(e=Array.from(d),c()):e.slice()},f.rangeRound=function(d){return e=Array.from(d),r=kn,c()},f.clamp=function(d){return arguments.length?(s=d?!0:me,c()):s!==me},f.interpolate=function(d){return arguments.length?(r=d,c()):r},f.unknown=function(d){return arguments.length?(o=d,f):o},function(d,m){return n=d,i=m,c()}}function qn(){return nd()(me,me)}function oa(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function ie(t,e){if(!isFinite(t)||t===0)return null;var r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function Et(t){return t=ie(Math.abs(t)),t?t[1]:NaN}function sa(t,e){return function(r,n){for(var i=r.length,o=[],s=0,a=t[0],l=0;i>0&&a>0&&(l+a+1>n&&(a=Math.max(1,n-l)),o.push(r.substring(i-=a,i+a)),!((l+=a+1)>n));)a=t[s=(s+1)%t.length];return o.reverse().join(e)}}function aa(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var id=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function jt(t){if(!(e=id.exec(t)))throw new Error("invalid format: "+t);var e;return new Or({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}jt.prototype=Or.prototype;function Or(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Or.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function la(t){t:for(var e=t.length,r=1,n=-1,i;r<e;++r)switch(t[r]){case".":n=i=r;break;case"0":n===0&&(n=r),i=r;break;default:if(!+t[r])break t;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(i+1):t}var Ue;function ua(t,e){var r=ie(t,e);if(!r)return Ue=void 0,t.toPrecision(e);var n=r[0],i=r[1],o=i-(Ue=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=n.length;return o===s?n:o>s?n+new Array(o-s+1).join("0"):o>0?n.slice(0,o)+"."+n.slice(o):"0."+new Array(1-o).join("0")+ie(t,Math.max(0,e+o-1))[0]}function Vn(t,e){var r=ie(t,e);if(!r)return t+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}var Un={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:oa,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Vn(t*100,e),r:Vn,s:ua,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Xn(t){return t}var ca=Array.prototype.map,fa=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];function da(t){var e=t.grouping===void 0||t.thousands===void 0?Xn:sa(ca.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Xn:aa(ca.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"\u2212":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function u(f,d){f=jt(f);var m=f.fill,P=f.align,A=f.sign,R=f.symbol,E=f.zero,y=f.width,M=f.comma,p=f.precision,_=f.trim,x=f.type;x==="n"?(M=!0,x="g"):Un[x]||(p===void 0&&(p=12),_=!0,x="g"),(E||m==="0"&&P==="=")&&(E=!0,m="0",P="=");var N=(d&&d.prefix!==void 0?d.prefix:"")+(R==="$"?r:R==="#"&&/[boxX]/.test(x)?"0"+x.toLowerCase():""),T=(R==="$"?n:/[%p]/.test(x)?s:"")+(d&&d.suffix!==void 0?d.suffix:""),L=Un[x],$=/[defgprs%]/.test(x);p=p===void 0?6:/[gprs]/.test(x)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p));function C(v){var b=N,h=T,S,g,w;if(x==="c")h=L(v)+h,v="";else{v=+v;var B=v<0||1/v<0;if(v=isNaN(v)?l:L(Math.abs(v),p),_&&(v=la(v)),B&&+v==0&&A!=="+"&&(B=!1),b=(B?A==="("?A:a:A==="-"||A==="("?"":A)+b,h=(x==="s"&&!isNaN(v)&&Ue!==void 0?fa[8+Ue/3]:"")+h+(B&&A==="("?")":""),$){for(S=-1,g=v.length;++S<g;)if(w=v.charCodeAt(S),48>w||w>57){h=(w===46?i+v.slice(S+1):v.slice(S))+h,v=v.slice(0,S);break}}}M&&!E&&(v=e(v,1/0));var z=b.length+v.length+h.length,k=z<y?new Array(y-z+1).join(m):"";switch(M&&E&&(v=e(k+v,k.length?y-h.length:1/0),k=""),P){case"<":v=b+v+h+k;break;case"=":v=b+k+v+h;break;case"^":v=k.slice(0,z=k.length>>1)+b+v+h+k.slice(z);break;default:v=k+b+v+h;break}return o(v)}return C.toString=function(){return f+""},C}function c(f,d){var m=Math.max(-8,Math.min(8,Math.floor(Et(d)/3)))*3,P=Math.pow(10,-m),A=u((f=jt(f),f.type="f",f),{suffix:fa[8+m/3]});return function(R){return A(P*R)}}return{format:u,formatPrefix:c}}var Rr,Ir,Dr;Gn({thousands:",",grouping:[3],currency:["$",""]});function Gn(t){return Rr=da(t),Ir=Rr.format,Dr=Rr.formatPrefix,Rr}function Zn(t){return Math.max(0,-Et(Math.abs(t)))}function Wn(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Et(e)/3)))*3-Et(Math.abs(t)))}function Yn(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Et(e)-Et(t))+1}function Kn(t,e,r,n){var i=Dn(t,e,r),o;switch(n=jt(n??",f"),n.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(o=Wn(i,s))&&(n.precision=o),Dr(n,s)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Yn(i,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Zn(i))&&(n.precision=o-(n.type==="%")*2);break}}return Ir(n)}function od(t){var e=t.domain;return t.ticks=function(r){var n=e();return zr(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var i=e();return Kn(i[0],i[i.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),i=0,o=n.length-1,s=n[i],a=n[o],l,u,c=10;for(a<s&&(u=s,s=a,a=u,u=i,i=o,o=u);c-- >0;){if(u=Ve(s,a,r),u===l)return n[i]=s,n[o]=a,e(n);if(u>0)s=Math.floor(s/u)*u,a=Math.ceil(a/u)*u;else if(u<0)s=Math.ceil(s*u)/u,a=Math.floor(a*u)/u;else break;l=u}return t},t}function ge(){var t=qn();return t.copy=function(){return ia(t,ge())},ra.apply(t,arguments),od(t)}function pa(t){return t}var Qn=1,Fr=2,Jn=3,jr=4,ha=1e-6;function sd(t){return"translate("+t+",0)"}function ad(t){return"translate(0,"+t+")"}function ld(t){return e=>+t(e)}function ud(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),r=>+t(r)+e}function cd(){return!this.__axis}function ma(t,e){var r=[],n=null,i=null,o=6,s=6,a=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,u=t===Qn||t===jr?-1:1,c=t===jr||t===Fr?"x":"y",f=t===Qn||t===Jn?sd:ad;function d(m){var P=n??(e.ticks?e.ticks.apply(e,r):e.domain()),A=i??(e.tickFormat?e.tickFormat.apply(e,r):pa),R=Math.max(o,0)+a,E=e.range(),y=+E[0]+l,M=+E[E.length-1]+l,p=(e.bandwidth?ud:ld)(e.copy(),l),_=m.selection?m.selection():m,x=_.selectAll(".domain").data([null]),N=_.selectAll(".tick").data(P,e).order(),T=N.exit(),L=N.enter().append("g").attr("class","tick"),$=N.select("line"),C=N.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),N=N.merge(L),$=$.merge(L.append("line").attr("stroke","currentColor").attr(c+"2",u*o)),C=C.merge(L.append("text").attr("fill","currentColor").attr(c,u*R).attr("dy",t===Qn?"0em":t===Jn?"0.71em":"0.32em")),m!==_&&(x=x.transition(m),N=N.transition(m),$=$.transition(m),C=C.transition(m),T=T.transition(m).attr("opacity",ha).attr("transform",function(v){return isFinite(v=p(v))?f(v+l):this.getAttribute("transform")}),L.attr("opacity",ha).attr("transform",function(v){var b=this.parentNode.__axis;return f((b&&isFinite(b=b(v))?b:p(v))+l)})),T.remove(),x.attr("d",t===jr||t===Fr?s?"M"+u*s+","+y+"H"+l+"V"+M+"H"+u*s:"M"+l+","+y+"V"+M:s?"M"+y+","+u*s+"V"+l+"H"+M+"V"+u*s:"M"+y+","+l+"H"+M),N.attr("opacity",1).attr("transform",function(v){return f(p(v)+l)}),$.attr(c+"2",u*o),C.attr(c,u*R).text(A),_.filter(cd).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===Fr?"start":t===jr?"end":"middle"),_.each(function(){this.__axis=p})}return d.scale=function(m){return arguments.length?(e=m,d):e},d.ticks=function(){return r=Array.from(arguments),d},d.tickArguments=function(m){return arguments.length?(r=m==null?[]:Array.from(m),d):r.slice()},d.tickValues=function(m){return arguments.length?(n=m==null?null:Array.from(m),d):n&&n.slice()},d.tickFormat=function(m){return arguments.length?(i=m,d):i},d.tickSize=function(m){return arguments.length?(o=s=+m,d):o},d.tickSizeInner=function(m){return arguments.length?(o=+m,d):o},d.tickSizeOuter=function(m){return arguments.length?(s=+m,d):s},d.tickPadding=function(m){return arguments.length?(a=+m,d):a},d.offset=function(m){return arguments.length?(l=+m,d):l},d}function ti(t){return ma(Fr,t)}function ei(t){return ma(Jn,t)}var fd=/^class[ {]/;function dd(t){return fd.test(t.toString())}function ni(t){return Array.isArray(t)}function ri(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Hr(...t){t.length===1&&ni(t[0])&&(t=t[0]),t=[...t];let e=t.pop();return e.$inject=t,e}var pd=/constructor\s*[^(]*\(\s*([^)]*)\)/m,hd=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,md=/\/\*([^*]*)\*\//m;function gd(t){if(typeof t!="function")throw new Error(`Cannot annotate "${t}". Expected a function!`);let e=t.toString().match(dd(t)?pd:hd);if(!e)return[];let r=e[1]||e[2];return r&&r.split(",").map(n=>{let i=n.match(md);return(i&&i[1]||n).trim()})||[]}function ii(t,e){e=e||{get:function(y,M){if(r.push(y),M===!1)return null;throw s(`No provider for "${y}"!`)}};let r=[],n=this._providers=Object.create(e._providers||null),i=this._instances=Object.create(null),o=i.injector=this,s=function(y){let M=r.join(" -> ");return r.length=0,new Error(M?`${y} (Resolving: ${M})`:y)};function a(y,M){if(!n[y]&&y.indexOf(".")!==-1){let p=y.split("."),_=a(p.shift());for(;p.length;)_=_[p.shift()];return _}if(ri(i,y))return i[y];if(ri(n,y)){if(r.indexOf(y)!==-1)throw r.push(y),s("Cannot resolve circular dependency!");return r.push(y),i[y]=n[y][0](n[y][1]),r.pop(),i[y]}return e.get(y,M)}function l(y,M){if(typeof M>"u"&&(M={}),typeof y!="function")if(ni(y))y=Hr(y.slice());else throw s(`Cannot invoke "${y}". Expected a function!`);let _=(y.$inject||gd(y)).map(x=>ri(M,x)?M[x]:a(x));return{fn:y,dependencies:_}}function u(y){let{fn:M,dependencies:p}=l(y),_=Function.prototype.bind.apply(M,[null].concat(p));return new _}function c(y,M,p){let{fn:_,dependencies:x}=l(y,p);return _.apply(M,x)}function f(y){return Hr(M=>y.get(M))}function d(y,M){if(M&&M.length){let p=Object.create(null),_=Object.create(null),x=[],N=[],T=[],L,$,C,v;for(let b in n)L=n[b],M.indexOf(b)!==-1&&(L[2]==="private"?($=x.indexOf(L[3]),$===-1?(C=L[3].createChild([],M),v=f(C),x.push(L[3]),N.push(C),T.push(v),p[b]=[v,b,"private",C]):p[b]=[T[$],b,"private",N[$]]):p[b]=[L[2],L[1]],_[b]=!0),(L[2]==="factory"||L[2]==="type")&&L[1].$scope&&M.forEach(h=>{L[1].$scope.indexOf(h)!==-1&&(p[b]=[L[2],L[1]],_[h]=!0)});M.forEach(b=>{if(!_[b])throw new Error('No provider for "'+b+'". Cannot use provider from the parent!')}),y.unshift(p)}return new ii(y,o)}let m={factory:c,type:u,value:function(y){return y}};function P(y,M){let p=y.__init__||[];return function(){p.forEach(_=>{typeof _=="string"?M.get(_):M.invoke(_)})}}function A(y){let M=y.__exports__;if(M){let p=y.__modules__,_=Object.keys(y).reduce(($,C)=>(C!=="__exports__"&&C!=="__modules__"&&C!=="__init__"&&C!=="__depends__"&&($[C]=y[C]),$),Object.create(null)),x=(p||[]).concat(_),N=d(x),T=Hr(function($){return N.get($)});M.forEach(function($){n[$]=[T,$,"private",N]});let L=(y.__init__||[]).slice();return L.unshift(function(){N.init()}),y=Object.assign({},y,{__init__:L}),P(y,N)}return Object.keys(y).forEach(function(p){if(p==="__init__"||p==="__depends__")return;if(y[p][2]==="private"){n[p]=y[p];return}let _=y[p][0],x=y[p][1];n[p]=[m[_],_d(_,x),_]}),P(y,o)}function R(y,M){return y.indexOf(M)!==-1||(y=(M.__depends__||[]).reduce(R,y),y.indexOf(M)!==-1)?y:y.concat(M)}function E(y){let M=y.reduce(R,[]).map(A),p=!1;return function(){p||(p=!0,M.forEach(_=>_()))}}this.get=a,this.invoke=c,this.instantiate=u,this.createChild=d,this.init=E(t)}function _d(t,e){return t!=="value"&&ni(e)&&(e=Hr(e.slice())),e}var yd=Object.defineProperty,xd=(t,e)=>{for(var r in e)yd(t,r,{get:e[r],enumerable:!0})},vd=class{constructor(){this._drawings=new Map}set(t,e){this._drawings.set(t,e)}remove(t){this._drawings.delete(t)}get(t){return this._drawings.get(t)??!1}getAll(){return[...this._drawings.values()]}},Ur=class{constructor(t,e,r,n,i,o,s){this._elements=new Map,this._elementsContainer=null,this._className=t,this._canvas=r,this._eventBus=n,this._elementBuilder=i,this._elementRegistry=o,this._drawingRegistry=s,this._init(e)}reconcile(t,e){this._builder(t,e)}_builder(t,e){let r=this._elementRegistry.get(t);r&&e?(e.get("status")!==1&&e.set("status",2),this.updateElement(e)):r&&!e?this.removeElementById(r.id):!r&&e&&this.appendElement(e)}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().append("g").attr("class",`${this._className}-group`)}removeElement(t){let e=t.id;if(typeof e!="string")return;this._elements.delete(e);let r=this._drawingRegistry.get(e);r&&(this._drawingRegistry.remove(e),this._elementRegistry.removeElementById(e),this._eventBus.emit(`${this._className}.removed`,r,t),r.remove())}removeElementById(t){this.removeElement({id:t})}appendElement(t){this._elementRegistry.claimId(t,this._className);let e=this._elementsContainer.append("g").datum(t).attr("element-id",t.id).attr("class",`${this._className}Item element`);e.append("g").attr("class","innerElement").attr("transform","translate(3, 3)"),this._createElement(e,t),this._drawingRegistry.set(t.id,e),this._elements.set(t.id,t),this._eventBus.emit(`${this._className}.created`,e,t)}updateElement(t){let e=this._drawingRegistry.get(t.id);e&&(e.datum(t),this._updateElement(e,t),this._drawingRegistry.set(t.id,e),this._elements.set(t.id,t),this._eventBus.emit(`${this._className}.updated`,e,t))}getAll(){return[...this._elements.values()]}getContainer(){return this._elementsContainer}_init(t){this._drawContainer(),t&&t.forEach(e=>this._builder(e.id,e))}},wd='"HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif',wa=class extends Ur{constructor(t,e,r,n,i,o){super("label",t,e,r,n,i,o)}_createElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.select(".innerElement").attr("transform","translate(3.66,3.66)").append("text").style("font-family",wd).attr("dominant-baseline","hanging").attr("fill",r.color??null).style("font-size",`${r.fontSize}px`).text(r.text??"")}_updateElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.select(".innerElement").select("text").attr("fill",r.color??null).style("font-size",`${r.fontSize}px`).text(r.text??"")}};wa.$inject=["d3polytree.definitions.label","canvas","eventBus","elementBuilder","elementRegistry","drawingRegistry"];var ba=class extends Ur{constructor(t,e,r,n,i,o){super("zone",t,e,r,n,i,o)}_createElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.append("rect").attr("height",r.height??0).attr("width",r.width??0).style("stroke",r.border.lineColor??"").style("fill",r.fillColor??"").style("opacity",r.opacity??"").style("stroke-width",r.border.lineWidth??"")}_updateElement(t,e){let r=e;t.select("rect").attr("height",r.height??0).attr("width",r.width??0).style("stroke",r.border.lineColor??"").style("fill",r.fillColor??"").style("opacity",r.opacity??"").style("stroke-width",r.border.lineWidth??"")}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",":first-child").attr("class",`${this._className}-group`)}};ba.$inject=["d3polytree.definitions.zone","canvas","eventBus","elementBuilder","elementRegistry","drawingRegistry"];function ga(t){return`M ${t.map(e=>`${e.x} ${e.y}`).join(", L ")}`}var Na=class extends Ur{constructor(t,e,r,n,i,o,s){super("link",void 0,e,r,i,o,s),this._markers=n,this._init(t)}_createElement(t,e){let r=e,n=ga(r.waypoint),i=t.select(".innerElement");i.append("path").attr("class","line-path").attr("marker-end",`url(#${this._markers.getMarker(r.id,r.lineColor,r.fillColor)})`).attr("d",n).style("stroke",r.lineColor??"").style("fill","none").style("stroke-width",`${r.lineWidth??0}px`).attr("stroke-linejoin","round").style("stroke-linecap","round"),i.append("path").attr("class","line-subpath").attr("d",n).style("stroke",r.fillColor??"").style("fill","none").style("stroke-width",`${.375*(r.lineWidth??0)}px`).attr("stroke-linejoin","round").style("stroke-linecap","round")}_updateElement(t,e){let r=e,n=ga(r.waypoint),i=t.select(".innerElement");i.select(".line-path").attr("marker-end",`url(#${this._markers.getMarker(r.id,r.lineColor,r.fillColor)})`).attr("d",n).style("stroke",r.lineColor??"").style("stroke-width",`${r.lineWidth??0}px`),i.select(".line-subpath").attr("d",n).style("stroke",r.fillColor??"").style("stroke-width",`${.375*(r.lineWidth??0)}px`)}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",".node-group").attr("class",`${this._className}-group`)}};Na.$inject=["d3polytree.definitions.link","canvas","eventBus","markers","elementBuilder","elementRegistry","drawingRegistry"];var Ea=class{constructor(t){this._markers=new Map,this._defs=t}getMarker(t,e,r){return this._markers.has(t)?this._updateMarker(t,e,r):this._createMarker(t,e,r),`${t}_markerEnd`}_createMarker(t,e,r){let n=this._defs.append("marker").attr("stroke",e??"").attr("id",`${t}_markerEnd`).attr("fill",r??"").attr("viewBox","-4 -8 15 15").attr("refX",5).attr("refY",0).attr("markerWidth",4).attr("markerHeight",4).attr("orient","auto").style("stroke-width",1.5);n.append("path").attr("d","M0,-5L8.67,0L0,5Z"),this._markers.set(t,n)}_updateMarker(t,e,r){this._markers.get(t).attr("stroke",e??"").attr("fill",r??"").attr("markerWidth",4).attr("markerHeight",4)}};Ea.$inject=["defs"];var Ma=class extends Ur{constructor(t,e,r,n,i,o,s){super("node",void 0,e,r,i,o,s),this._iconLoader=n,this._init(t)}_createElement(t,e){let r=e,n=r.type??"default",{x:i,y:o}=r.position;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`),t.select(".innerElement").append("svg").attr("width",r.size??0).attr("height",r.size??0).attr("viewBox",this._iconLoader.getViewBox(n)).attr("preserveAspectRatio","xMaxYMax meet").append("use").attr("href",this._iconLoader.symbolHref(n))}_updateElement(t,e){let r=e,n=r.type??"default",{x:i,y:o}=r.position;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`),t.select(".innerElement").select("svg").attr("width",r.size??0).attr("height",r.size??0).attr("viewBox",this._iconLoader.getViewBox(n)).select("use").attr("href",this._iconLoader.symbolHref(n))}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",".label-group").attr("class",`${this._className}-group`)}};Ma.$inject=["d3polytree.definitions.node","canvas","eventBus","iconLoader","elementBuilder","elementRegistry","drawingRegistry"];var Sa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect rx="8" ry="8" width="100" height="100" fill="#888"/></svg>';function ka(){return{default:Sa}}ka.$inject=[];var bd="http://www.w3.org/2000/svg",_a="http://www.w3.org/1999/xlink",Nd=["clip-path","fill","stroke","mask","filter","marker-start","marker-mid","marker-end"];function Ed(t,e){let r=new Map;if(t.querySelectorAll("[id]").forEach(i=>{let o=i.getAttribute("id"),s=`${e}_${o}`;r.set(o,s),i.setAttribute("id",s)}),r.size===0)return;let n=i=>i.replace(/#([^\s)'"]+)/g,(o,s)=>r.has(s)?`#${r.get(s)}`:o);t.querySelectorAll("*").forEach(i=>{let o=i.getAttributeNS(_a,"href");o&&o.includes("#")&&i.setAttributeNS(_a,"href",n(o));let s=i.getAttribute("href");s&&s.includes("#")&&i.setAttribute("href",n(s)),Nd.forEach(a=>{let l=i.getAttribute(a);l&&l.includes("#")&&i.setAttribute(a,n(l))})})}var Aa=class{constructor(t,e){this._viewBoxes={},this._icons={...t},this._defs=e,this._init()}_init(){this._icons.default||(this._icons.default=Sa);let t=this._defs.node();t&&Object.entries(this._icons).forEach(([e,r])=>{let i=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;if(!i||i.nodeName.toLowerCase()!=="svg")return;let o=i.getAttribute("viewBox")??"",s=document.createElementNS(bd,"symbol");s.setAttribute("id",`${e}_icon_def`),o&&s.setAttribute("viewBox",o),Array.from(i.childNodes).forEach(a=>s.appendChild(document.importNode(a,!0))),Ed(s,e),t.appendChild(s),this._viewBoxes[e]=o})}hasIcon(t){return Object.prototype.hasOwnProperty.call(this._viewBoxes,t)}getViewBox(t){return this._viewBoxes[t]??this._viewBoxes.default??""}symbolHref(t){return`#${this.hasIcon(t)?t:"default"}_icon_def`}};Aa.$inject=["icons","defs"];function Ca(t){return t.getSVG().append("defs")}Ca.$inject=["canvas"];var oe={__init__:["drawingRegistry"],drawingRegistry:["type",vd]},Pa={__init__:["defs"],defs:["factory",Ca]},Md={icons:["factory",ka]},Sd={__init__:["iconLoader"],iconLoader:["type",Aa],__depends__:[Md,Pa]},Xe={__init__:["labels"],labels:["type",wa],__depends__:[oe]},Xr={__init__:["zones"],zones:["type",ba],__depends__:[oe,Xe]},kd={__init__:["markers"],markers:["type",Ea],__depends__:[Pa]},ci={__init__:["links"],links:["type",Na],__depends__:[oe,kd]},fi={__init__:["nodes"],nodes:["type",Ma],__depends__:[oe,Sd,Xe,Xr]},Ad={};xd(Ad,{add:()=>Ta,indexOf:()=>Pd,remove:()=>Cd});function Cd(t,e){if(!t||!e)return-1;let r=t.indexOf(e);return r!==-1&&t.splice(r,1),r}function Ta(t,e,r=-1){if(!t||!e)return;let n=t.indexOf(e);if(n!==-1){if(n===r)return;if(r!==-1)t.splice(n,1);else return}r!==-1?t.splice(r,0,e):t.push(e)}function Pd(t,e){return!t||!e?-1:t.indexOf(e)}function ht(t){return t.$descriptor.ns.localName.toLowerCase()}var Td=["mouseenter","mouseover","mousedown","mouseup","click","dblclick","mouseleave","mouseout","contextmenu"],Ba=class{constructor(t){this._eventBus=t,this._init()}_addListeners(t,e,r){let n=r??ht(e);Td.forEach(i=>{t.on(i,o=>{this._eventBus.emit(`${n}.${i}`,t,e,o)})})}_init(){["label","link","node","zone"].forEach(t=>{this._eventBus.on(`${t}.created`,this._addListeners,this)})}};Ba.$inject=["eventBus"];var La=class{constructor(t){this._currentSelection=new Map,this._eventBus=t,this._init()}_snapshot(){return[...this._currentSelection.values()]}_unSelectElement(t,e,r){let n=this._snapshot();this._currentSelection.delete(e.id),t.classed("selected",!1),r&&this._eventBus.emit("selection.changed",n,this._snapshot())}_selectElement(t,e,r){(!r||!r.ctrlKey)&&this._unSelectAllElements(!0),t.classed("selected",!0);let n=this._snapshot();this._currentSelection.set(e.id,{element:t,definition:e}),this._eventBus.emit("selection.changed",n,this._snapshot())}_unSelectAllElements(t){this._snapshot().forEach(e=>{this._unSelectElement(e.element,e.definition,!t)})}deleteSelected(){this._snapshot().forEach(t=>{this._unSelectElement(t.element,t.definition),this._eventBus.emit(`${ht(t.definition)}.deleted`,t.element,t.definition)})}getSelectedElements(){return this._snapshot()}select(t,e,r){this._selectElement(t,e,r)}_init(){["label","link","node","zone"].forEach(t=>{this._eventBus.on(`${t}.click`,this._selectElement,this)}),this._eventBus.on("background.click",this._unSelectAllElements,this)}};La.$inject=["eventBus"];var Bd=[.1,15],oi=1.2,Ld=1800,$a=class{constructor(t,e,r,n){this._isZoomable=!1,this._canvas=e,this._eventBus=r,this._options=t,this._calculateCenter=n;let i=t.get("offset"),o=i.get("x"),s=i.get("y"),a=t.get("scale");this._init(),this.setZoomable(!0),this.setInitialZoom(o,s,a),this.setZoomable(!1)}setZoom(t,e,r){if(this._eventBus.emit("zoom.preZoom",t,e,r),this._isZoomable){let i=t===void 0||e===void 0||r===void 0?this._canvas.getTransform():null,o=t??i.e,s=e??i.f,a=r??i.a;this._canvas.getDrawingLayer().attr("transform",`translate(${o}, ${s}) scale(${a})`),this._options.scale=a,this._options.offset&&(this._options.offset.x=o,this._options.offset.y=s),this._eventBus.emit("canvas.zoomed")}}setZoomable(t){this._isZoomable=t}isZoomable(){return this._isZoomable}setInitialZoom(t,e,r,n){let o=this._canvas.getDrawingLayer().node().parentNode,s=X(o),a=Bt.translate(t,e).scale(r);n?s.transition().duration(n).call(this._zoom.transform,a):s.call(this._zoom.transform,a)}_init(){let t=this._canvas.getDrawingLayer();this._zoom=zn().scaleExtent(Bd).extent(()=>{let{width:e,height:r}=this._canvas.getSize();return[[0,0],[e,r]]}).on("start",()=>this._eventBus.emit("zoom.start")).on("zoom",e=>{if(!this._isZoomable)return;let{x:r,y:n,k:i}=e.transform;this.setZoom(r,n,i)}).on("end",()=>this._eventBus.emit("zoom.end")),t.on("click",e=>{X(e.target).classed("element-outline")||this._eventBus.emit("background.click")}),t=t.call(this._zoom).append("g"),this._canvas.setDrawingLayer(t),this._eventBus.on("zoom.to.element",(e,r)=>{let n=this._isZoomable,i=ht(r),o=this._calculateCenter.getCenterPosition(),s={x:0,y:0};if(this.setZoomable(!0),i==="node"){let a=r.position,l=r.size??0;s.x=1.5+a.x+l/2,s.y=1.5+a.y+l/2}else if(i==="link"){let a=r.waypoint,l=a.length-1;l>=0&&(s.x=a[l].x,s.y=a[l].y)}this.setInitialZoom(o.x-s.x*oi,o.y-s.y*oi,oi,Ld),this.setZoomable(n)}),this._eventBus.emit("zoom.init")}};$a.$inject=["d3polytree.definitions.settings.zoom","canvas","eventBus","calculateCenter"];var za=class{constructor(t){t.setZoomable(!0)}};za.$inject=["zoom"];var Oa=class{constructor(t,e,r){this._bgRect=null,this._canvas=t,this._settings=e,this._eventBus=r,this._init()}setColor(t){this._bgRect&&(this._settings.backgroundColor=t,this._refill())}_refill(){this._bgRect?.attr("fill",this._settings.backgroundColor??"")}_init(){this._bgRect=this._canvas.getRootLayer().insert("rect",":first-child").attr("width","100%").attr("height","100%").attr("fill",this._settings.backgroundColor??""),this._eventBus.on("canvas.resized",()=>this._refill())}};Oa.$inject=["canvas","d3polytree.definitions.settings","eventBus"];var Ra=class{constructor(t,e,r,n){this._svg=null,this._x=null,this._y=null,this._xAxis=null,this._yAxis=null,this._gX=null,this._gY=null,this._options=t,this._isVisible=t.show??!0,this._canvas=e,this._eventBus=r,this._zoom=n,this._init()}setVisible(t){this._svg&&(this._isVisible=t,this._svg.style("display",t?"inline":"none"))}toggleVisible(){this._svg&&this.setVisible(!this._isVisible)}_init(){let t=!1;this._eventBus.on("zoom.start",()=>{this._zoom&&!this._zoom.isZoomable()||(t=this._isVisible,this.setVisible(!1))}),this._eventBus.on("zoom.end",()=>{t&&(this.setVisible(!0),this._rescale())}),this._draw(),this._rescale(),this.setVisible(this._options.show??!0)}_rescale(){if(!this._x||!this._y||!this._xAxis||!this._yAxis||!this._gX||!this._gY)return;let{width:t,height:e}=this._canvas.getSize(),r=this._canvas.getTransform(),n=r.a,i=this._options.size??1,o=Bt.translate(r.e,r.f).scale(n);this._x.domain([-1,t-1]).range([-1,t-1]),this._y.domain([-1,e-1]).range([-1,e-1]),this._gX.call(this._xAxis.scale(o.rescaleX(this._x)).ticks(t/n/i).tickSize(e)),this._gY.call(this._yAxis.scale(o.rescaleY(this._y)).ticks(e/n/i).tickSize(t));for(let s of[this._gX,this._gY])s.selectAll("line, path").style("stroke-width",String(this._options.lineWidth??1)).style("stroke",this._options.lineColor??"").style("stroke-dasharray","2")}_draw(){this._svg&&this._svg.remove(),this._svg=this._canvas.getRootLayer().insert("g",":first-child").attr("class","axis");let{width:t,height:e}=this._canvas.getSize();this._x=ge().domain([-1,t-1]).range([-1,t-1]),this._y=ge().domain([-1,e-1]).range([-1,e-1]),this._xAxis=ei(this._x).tickFormat(()=>"").tickSize(e),this._yAxis=ti(this._y).tickFormat(()=>"").tickSize(t),this._gX=this._svg.append("g").call(this._xAxis),this._gY=this._svg.append("g").call(this._yAxis)}};Ra.$inject=["d3polytree.definitions.settings.grid","canvas","eventBus","zoom"];var qr=6,Ia=class{constructor(t){this._eventBus=t,this._init()}_computeBox(t,e){let r=ht(e);if(r==="link"){let o=e.waypoint??[];if(o.length>0){let s=o[0],a=o[o.length-1];return{x:Math.min(s.x,a.x),y:Math.min(s.y,a.y),width:Math.abs(a.x-s.x),height:Math.abs(a.y-s.y)}}return{x:0,y:0,width:0,height:0}}if(r==="node"){let o=Number(e.size??0);return{x:0,y:0,width:o,height:o}}let n=t.select(".innerElement").node(),i=n&&typeof n.getBBox=="function"?n.getBBox():{width:0,height:0};return{x:0,y:0,width:i.width,height:i.height}}_createOutline(t,e){let r=this._computeBox(t,e),n=t.insert("rect",":first-child").attr("class","element-outline").attr("x",r.x).attr("y",r.y).attr("fill","none").attr("stroke","red").attr("stroke-width",0).attr("stroke-dasharray","3").attr("width",r.width+qr).attr("height",r.height+qr);this._eventBus.emit("outline.created",t,e,n)}_updateOutline(t,e){let r=this._computeBox(t,e),n=t.select(".element-outline").attr("x",r.x).attr("y",r.y).attr("width",r.width+qr).attr("height",r.height+qr);this._eventBus.emit("outline.updated",t,e,n)}_init(){["node","label","zone","link"].forEach(t=>{this._eventBus.on(`${t}.created`,this._createOutline,this),this._eventBus.on(`${t}.updated`,this._updateOutline,this)})}};Ia.$inject=["eventBus"];var Da=class{constructor(t,e,r,n){this._canvas=t,this._eventBus=e,this._drawingRegistry=r,this._selection=n,this._init()}applyOffsetToSelected(t,e){this._selection.getSelectedElements().forEach(r=>{if(ht(r.definition)==="link")return;this._applyOffset(r.element,r.definition,t,e);let n=r.definition.label;if(n){let i=this._drawingRegistry.get(n.id);i&&this._applyOffset(i,n,t,e)}})}notifyMovedSelected(){this._selection.getSelectedElements().forEach(t=>{ht(t.definition)!=="link"&&this._eventBus.emit(`${ht(t.definition)}.moved`,t.element,t.definition)})}_applyOffset(t,e,r,n){let i=Number(t.attr("x"))+r,o=Number(t.attr("y"))+n;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`);let s=e.position;s.x=i,s.y=o,e.get("status")!==1&&e.set("status",2),this._eventBus.emit(`${ht(e)}.moving`,t,e)}_setElemToDrag(t,e){t.call(Ce().on("start",r=>{this._selection.select(t,e,r.sourceEvent),this._canvas.getRootLayer().classed("no-drag")||r.on("drag",n=>this.applyOffsetToSelected(n.dx,n.dy)).on("end",()=>this.notifyMovedSelected())}))}_init(){this._eventBus.on("outline.created",(t,e)=>{ht(e)!=="link"&&this._setElemToDrag(t,e)})}};Da.$inject=["canvas","eventBus","drawingRegistry","selection"];function ya(t){let e=new TextEncoder().encode(t),r="";return e.forEach(n=>{r+=String.fromCharCode(n)}),btoa(r)}var ja=class{constructor(t,e){this._canvas=t,this._host=e,this._exporter=this._createExporter()}async trigger(t){let e;if(t==="pfdn")e=this._encodeXml(this._host.exportDiagram());else if(t==="svg")e=this._encodeXml(this._host.exportSVG());else if(t==="png")e=await this._svgToImage(this._host.exportSVG());else{console.error("Format not supported");return}this._exporter.setAttribute("href",e),this._exporter.setAttribute("download",`diagram.${t}`),this._exporter.click()}_encodeXml(t){return`data:application/xml;base64,${ya(t)}`}_svgToImage(t){return new Promise(e=>{let r=`data:image/svg+xml;base64,${ya(t)}`,n=document.createElement("canvas"),i=n.getContext("2d"),o=this._canvas.getSVG().node()?.parentNode,s=o?.offsetWidth??0,a=o?.offsetHeight??0;n.width=s,n.height=a;let l=new Image;l.onload=()=>{i?.clearRect(0,0,s,a),i?.drawImage(l,0,0,s,a),e(n.toDataURL("image/png"))},l.src=r})}_createExporter(){let t=document.createElement("a");Object.assign(t.style,{width:"1px",height:"1px",display:"none",overflow:"hidden"});let e=this._canvas.getContainer();return e.insertBefore(t,e.firstChild),t}};ja.$inject=["canvas","d3polytree"];var xa="diagram",Fa=class{constructor(t,e){this._host=t,this._notifications=e}loadSaved(){let t=this._read()??this._host.initialDiagram;t&&this._host.importDiagram(t)}save(){this._write(this._host.exportDiagram()),this._notifications.success({title:"Success",text:"Diagram saved"})}_read(){try{return window.localStorage.getItem(xa)}catch{return null}}_write(t){try{window.localStorage.setItem(xa,t)}catch{this._notifications.error({title:"Error",text:"Could not save the diagram"})}}};Fa.$inject=["d3polytree","notifications"];var Ha=class{constructor(t,e){this._host=e,this._fileInput=this._createInput(t)}openDialog(){this._fileInput.click()}_createInput(t){let e=document.createElement("input");e.type="file",Object.assign(e.style,{width:"1px",height:"1px",display:"none",overflow:"hidden"});let r=t.getContainer();return r.insertBefore(e,r.firstChild),e.addEventListener("change",n=>{let i=n.target.files?.[0];this._openFile(i)}),e}_openFile(t){if(typeof FileReader>"u"){window.alert("Your browser does not support file upload. Try a modern browser.");return}if(!t)return;let e=new FileReader;e.onload=r=>{let n=r.target?.result;typeof n=="string"&&this._host.importDiagram(n)},e.readAsText(t)}};Ha.$inject=["canvas","d3polytree"];var si=16,ai=2.5+3,Vr=6,qa=class{constructor(t,e){this._eventBus=t,this._canvas=e,this._init()}_createCorners(t,e,r){let n=Number(r.attr("width")),i=X(r.node().parentNode).append("g").attr("class","resize-container"),o=i.append("rect"),s=li(i,"resize-drag-ne",n-2.5,-2.5),a=li(i,"resize-drag-sw",-2.5,n-2.5),l=li(i,"resize-drag-se",n-2.5,n-2.5),u=()=>{this._eventBus.emit("element.updated",e.id,e)},c=f=>{t.select(".innerElement").select("svg").attr("width",f).attr("height",f)};this._setCornerToDrag(s,f=>{let d=Q(f,a.node()),m=Math.max(si,d[0],d[1]*-1)-ai,P=Number(e.size);c(m);let A=Number(t.attr("y"))+P-m,R=Number(t.attr("x"));t.attr("y",A).attr("transform",`translate(${R},${A})`),e.size=m,e.position.y=A,this._updateOutlineAndCorners(r,i,m+Vr)},u),this._setCornerToDrag(a,f=>{let d=Q(f,s.node()),m=Math.max(si,d[0]*-1,d[1])-ai,P=Number(e.size);c(m);let A=Number(t.attr("x"))+P-m,R=Number(t.attr("y"));t.attr("x",A).attr("transform",`translate(${A},${R})`),e.size=m,e.position.x=A,this._updateOutlineAndCorners(r,i,m+Vr)},u),this._setCornerToDrag(l,f=>{let d=Q(f,o.node()),m=Math.max(si,d[0],d[1])-ai;e.size=m,c(m),this._updateOutlineAndCorners(r,i,m+Vr)},u)}_updateOutlineAndCorners(t,e,r){t.attr("width",r).attr("height",r),e.select(".resize-drag-ne").attr("x",r-2.5),e.select(".resize-drag-sw").attr("y",r-2.5),e.select(".resize-drag-se").attr("x",r-2.5).attr("y",r-2.5)}_setCornerToDrag(t,e,r){t.call(Ce().on("start",n=>{this._canvas.getRootLayer().classed("no-drag")||n.on("drag",e).on("end",r)}))}_init(){this._eventBus.on("outline.created",(t,e,r)=>{e.$instanceOf("pfdn:Node")&&this._createCorners(t,e,r)}),this._eventBus.on("outline.updated",(t,e,r)=>{if(e.$instanceOf("pfdn:Node")){let n=t.select(".resize-container");this._updateOutlineAndCorners(r,n,Vr+Number(e.size))}})}};qa.$inject=["eventBus","canvas"];function li(t,e,r,n){return t.append("rect").attr("fill","none").attr("x",r).attr("y",n).attr("width",5).attr("height",5).attr("class",e)}var $d='More info about this project in <a href="https://github.com/davcs86/d3-polytree" target="_blank" rel="noopener">https://github.com/davcs86/d3-polytree</a>',zd=class{constructor(t,e){let r=document.createElement("div");r.className="noticePopup",t.getContainer().appendChild(r),r.addEventListener("click",()=>{e.notify({title:"D3-Polytree",text:$d,html:!0},"info")})}};zd.$inject=["canvas","notifications"];var Od="http://www.w3.org/2000/svg",Rd={error:"error",info:"info",success:"success",warning:"warning"},Id={error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#D8000C"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M153.663 134.653l-35.265-32.672 35.265-32.67-16.566-15.345-35.265 32.67-35.265-32.67L50 69.31l35.265 32.67L50 134.654 66.567 150l35.265-32.67L137.097 150"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#1F75FE"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M114.605 39.133c-5.14 0-9.307 4.167-9.307 9.307 0 5.14 4.167 9.307 9.307 9.307 5.14 0 9.307-4.167 9.307-9.307 0-5.14-4.167-9.307-9.307-9.307zM103.22 63.106c-6.1.304-12.586 3.594-18.03 8.227l-.583 7.063c5.145-2.234 10.427-2.245 12.008 3.075 3.848 12.943-9.362 35.627-12.963 47.49-9.77 32.19 13.684 35.91 30.413 22.645l.665-7.644c-9.102 3.16-15.607-.716-10.346-17.533 2.535-8.112 23.754-48.99 9.1-60.245-3.07-2.356-6.603-3.256-10.263-3.074z"/></svg>',success:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#4BB543"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M150.003 52.712c-1.95-1.952-5.15-1.952-7.102 0l-62.994 63c-1.952 1.952-5.15 1.952-7.103 0l-15.516-15.515c-1.952-1.952-5.15-1.952-7.102 0l-9.516 9.52c-1.953 1.953-1.953 5.152 0 7.104l32.133 32.13c1.952 1.95 5.15 1.95 7.103 0l79.614-79.62c1.952-1.952 1.952-5.15 0-7.102z"/></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#F8CA00"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M102.506 40.44c-7.136 0-12.922 5.786-12.922 12.923l2.585 51.687c0 5.71 4.626 10.338 10.335 10.338 5.71 0 10.338-4.63 10.338-10.338l2.584-51.687c0-7.137-5.785-12.922-12.922-12.922zm0 87.87c-8.564 0-15.506 6.94-15.506 15.505 0 8.563 6.942 15.506 15.506 15.506s15.507-6.942 15.507-15.505c0-8.564-6.943-15.507-15.507-15.507z"/></svg>'},Dd=class{constructor(t,e,r){this._viewBoxes={},this._alerts={},this._defs=t,this._notifications=e,this._drawingRegistry=r,this._buildSymbols()}showAlert(t,e,r){let n=this._drawingRegistry.get(t);if(!n)return;let i=Rd[r]??"info",o=this.getAlert(t);this._alerts[t]=o?this._updateAlert(o,e,i):this._createAlert(n,e,i)}getAlert(t){return this._alerts[t]}removeAlert(t){let e=this.getAlert(t);e&&(this._clearAlert(e),delete this._alerts[t])}clear(){Object.values(this._alerts).forEach(t=>this._clearAlert(t)),this._alerts={}}_clearAlert(t){t.element.select(".innerElement").classed("blink",!1),t.selection.on("mousedown",null),t.selection.remove()}_createAlert(t,e,r){let n=t.select(".innerElement").append("svg").attr("class","alertIcon").attr("x",-2).attr("y",-2).attr("width",10).attr("height",10).attr("preserveAspectRatio","xMaxYMax meet");n.append("use");let i={element:t,selection:n,message:e,type:r};return this._updateAlert(i,e,r)}_updateAlert(t,e,r){return t.selection.attr("viewBox",this._viewBoxes[r]??"").select("use").attr("href",`#${r}_alerticon_def`),t.message=e.replace(/(<([^>]+)>)/gi,""),t.type=r,t.selection.on("mousedown",()=>{this._notifications.notify({title:t.type,text:t.message},t.type)}),t.element.select(".innerElement").classed("blink",!0),t}_buildSymbols(){let t=this._defs.node();t&&Object.entries(Id).forEach(([e,r])=>{let i=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;if(!i||i.nodeName.toLowerCase()!=="svg")return;let o=i.getAttribute("viewBox")??"",s=document.createElementNS(Od,"symbol");s.setAttribute("id",`${e}_alerticon_def`),o&&s.setAttribute("viewBox",o),Array.from(i.childNodes).forEach(a=>s.appendChild(document.importNode(a,!0))),t.appendChild(s),this._viewBoxes[e]=o})}};Dd.$inject=["defs","notifications","drawingRegistry"];var jd=.8,Fd=class{constructor(t,e,r){this._tip=null,typeof t=="function"&&(this._tip=document.createElement("div"),this._tip.className="d3-tip",this._tip.style.position="absolute",this._tip.style.display="none",document.body.appendChild(this._tip),r.on("node.mouseover",(n,i,o)=>{e.getTransform().a<jd&&this._show(t(i),o)}),r.on("node.mouseout",()=>this._hide()))}_show(t,e){if(!this._tip)return;this._tip.innerHTML=t,this._tip.style.display="block";let r=e;this._tip.style.left=`${r.pageX}px`,this._tip.style.top=`${r.pageY-10}px`}_hide(){this._tip&&(this._tip.style.display="none")}};Fd.$inject=["d3polytree.options.tooltip","canvas","eventBus"];var Va=class{constructor(t,e,r,n,i){this._className=t,this._drawingRegistry=e,this._selection=r,this._canvas=n,this._modelling=i}_getElemOfReference(){let t=this._drawingRegistry.getAll();return t.length>0?X(t[0].node()):this._canvas.getDrawingLayer()}_calculatePosition(){let t=this._getElemOfReference(),e=this._canvas.getContainer().getBoundingClientRect(),r=t.node().getBoundingClientRect(),n=this._canvas.getTransform(t),i=this._canvas.getTransform(),o=n.e,s=n.f,a=i.a||1;return{x:-1*(r.left-o*a-(e.left+e.width/2))/a,y:-1*(r.top-s*a-(e.top+e.height/2))/a}}_create(t){return this._modelling.doAction(this._className,"create",[t])}append(t={}){t.position=this._calculatePosition();let e=this._create(t),r=this._drawingRegistry.get(e.id);return r&&this._selection.select(r,e,{}),e}},Ua=class extends Va{constructor(t,e,r,n){super("node",t,e,r,n)}};Ua.$inject=["drawingRegistry","selection","canvas","modelling"];var Xa=class extends Va{constructor(t,e,r,n){super("label",t,e,r,n)}};Xa.$inject=["drawingRegistry","selection","canvas","modelling"];var Ga=class{constructor(t,e,r){this.active=!1,this._selectedNodes=[],this._eventBus=t,this._canvas=e,this._modelling=r,this._fakeLink=this._canvas.getDrawingLayer().insert("path",".node-group").attr("class","fake-link").attr("d","M0,0L0,0").style("stroke","black").style("fill","none")}activate(){this.active=!0,this._selectedNodes=[],this._canvas.getRootLayer().classed("no-drag",!0).classed("cursor-add-link",!0),this._registerMouseMove(),this._registerNodeClick()}deactivate(){this.active=!1,this._canvas.getRootLayer().classed("no-drag",!1).classed("cursor-add-link",!1),this._resetFakeLink()}_registerNodeClick(){this._eventBus.once("node.click",(t,e,r)=>{if(!this.active)return;r.stopImmediatePropagation();let n=this._selectedNodes;(n.length===0||n.length===1&&n[0].element!==t)&&n.push({element:t,definition:e}),n.length===2?(this._appendLink(),this.deactivate()):(n.length===1&&this._showFakeLink(),this._registerNodeClick())})}_registerMouseMove(){this._canvas.getRootLayer().on("mousemove",t=>{if(!this.active||this._selectedNodes.length!==1)return;let e=this._selectedNodes[0].definition,r=e.position,n=e.size??0,i=this._canvas.getDrawingLayer().node(),[o,s]=Q(t,i),a=r.x+n/2,l=r.y+n/2;this._fakeLink.attr("d",`M${a},${l}L${o},${s}`)})}_showFakeLink(){let t=this._selectedNodes[0].definition.position;this._fakeLink.attr("d",`M${t.x},${t.y}L${t.x},${t.y}`)}_resetFakeLink(){this._fakeLink.attr("d","M0,0L0,0")}_appendLink(){this._modelling.doAction("link","create",[this._selectedNodes[0].definition,this._selectedNodes[1].definition])}};Ga.$inject=["eventBus","canvas","modelling"];var Za=class{constructor(t,e,r,n,i,o,s,a,l,u,c){this._host=t,this._localStorage=r,this._upload=n,this._exporting=i,this._axes=o,this._selection=s,this._addNodeHandler=a,this._addLabelHandler=l,this._notifications=c,this._tools={addLinkTool:u}}getPaletteTools(){return this._tools}getPaletteEntries(){return{new:{title:"New diagram",group:"file-ops",iconClassName:"icon-doc",action:{click:()=>{this._notifications.warning({title:"Are you sure?",text:"All current progress will be unrecoverable."},t=>{t&&this._host.createDiagram()})}}},save:{title:"Save diagram",group:"file-ops",iconClassName:"icon-floppy",action:{click:()=>this._localStorage.save()}},open:{title:"Open diagram",group:"file-ops",iconClassName:"icon-folder-open-empty",action:{click:()=>this._upload.openDialog()}},download:{title:"Download diagram",group:"file-ops",iconClassName:"icon-download",action:{click:()=>{this._exporting.trigger("pfdn")}}},"export-svg":{title:"Download as SVG image",group:"file-export",iconClassName:"icon-file-code",action:{click:()=>{this._exporting.trigger("svg")}}},"export-png":{title:"Download as PNG image",group:"file-export",iconClassName:"icon-image",action:{click:()=>{this._exporting.trigger("png")}}},"new-connection":{title:"New connection",group:"drawing",iconClassName:"icon-arrow",action:{click:()=>this._tools.addLinkTool.activate()}},"new-label":{title:"New label",group:"drawing",iconClassName:"icon-text",action:{click:()=>this._addLabelHandler.append()}},"new-node":{title:"New node",group:"drawing",iconClassName:"icon-check-empty",action:{click:()=>this._addNodeHandler.append()}},"delete-item":{title:"Delete selected item(s)",group:"utils",iconClassName:"icon-trash",action:{click:()=>this._selection.deleteSelected()}},"toggle-grid":{title:"Show/hide grid",group:"settings",iconClassName:"icon-grid",action:{click:()=>this._axes.toggleVisible()}}}}};Za.$inject=["d3polytree","eventBus","localStorage","upload","exporting","axes","selection","addNodeHandler","addLabelHandler","addLinkTool","notifications"];function ui(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var di=class Wa{constructor(e,r){this._actions={},this._canvas=e,this._paletteProvider=r,this._init()}trigger(e,r,n){this._deactivateTools();let i=n??r.target.closest(".pfdjs-entry");if(!i)return;let o=this._actions[i.getAttribute("data-action")??""];if(!o)return;let s=o.action;typeof s=="function"?e==="click"&&s(r):s[e]?.(r)}getContainer(){return this._paletteContainer}_deactivateTools(){let e=this._paletteProvider.getPaletteTools();Object.values(e).forEach(r=>r.deactivate())}_drawContainer(){this._paletteContainer=ui(Wa.HTML_MARKUP);let e=this._canvas.getContainer();e.insertBefore(this._paletteContainer,e.firstChild),this._entriesContainer=this._paletteContainer.querySelector(".pfdjs-entries")}_drawEntry(e,r){let n=e.group??"default",i=this._entriesContainer.querySelector(`[data-group="${n}"]`);i||(i=ui(`<div class="pfdjs-entries-group" data-group="${n}"></div>`),this._entriesContainer.appendChild(i));let o=ui(e.html??'<div class="pfdjs-entry"></div>');if(i.appendChild(o),o.setAttribute("data-action",r),e.title&&o.setAttribute("title",e.title),e.className&&o.classList.add(e.className),e.iconClassName){let s=document.createElement("span");s.className=e.iconClassName,o.appendChild(s)}}_drawEntries(){this._actions=this._paletteProvider.getPaletteEntries(),Object.entries(this._actions).forEach(([e,r])=>this._drawEntry(r,e))}_createDelegates(){this._paletteContainer.addEventListener("click",e=>{let r=e.target.closest(".pfdjs-entry");r&&(this.trigger("click",e,r),e.stopImmediatePropagation())}),this._paletteContainer.addEventListener("mousedown",()=>this._deactivateTools())}_init(){this._drawContainer(),this._drawEntries(),this._createDelegates()}};di.$inject=["canvas","paletteProvider"];di.HTML_MARKUP='<div class="pfdjs-palette"><div class="pfdjs-entries"></div></div>';var Hd=di,qd=class{info(t,e){this.notify(t,"info",e)}success(t,e){this.notify(t,"success",e)}warning(t,e){this.notify(t,"warning",e)}error(t,e){this.notify(t,"error",e)}notify(t,e,r){let n=[e.toUpperCase(),t.title,t.text].filter(Boolean).join(": ");(e==="error"?console.error:e==="warning"?console.warn:console.info).call(console,n),r?.(!1)}},Ge={__init__:["notifications"],notifications:["type",qd]},Gr=class{constructor(t,e,r,n,i){this._definitions=t,this._drawer=e,this._drawingRegistry=r,this._notifications=n,this._eventBus=i}reconcile(t,e){this._drawer.reconcile(t,e)}saveToModel(t,e){let r=ht(e);Ta(this._definitions.get(r),e)}delete(t,e){let r=ht(e);if(r==="label"&&e.isReadOnly===!0){this._notifications.error({title:"Not allowed!",text:"You can't delete an associated label, you should remove the main element"});return}let n=e.get("label");if(r!=="label"&&n&&n.$instanceOf("pfdn:Label")){n.isReadOnly=!1;let i=this._drawingRegistry.get(n.id);this._eventBus.emit("label.deleted",i,n)}e.set("status",3),this._drawer.reconcile(e.id,void 0)}},Ya=class extends Gr{constructor(t,e,r,n,i,o){super(t,o,r,n,i),this._moddle=e}create(t={}){let e=t.position??{x:0,y:0},r=this._moddle.create("pfdn:Coordinates",{x:e.x,y:e.y}),n=this._moddle.create("pfdn:Label",{position:r,status:1});return this._drawer.reconcile(n.id,n),n.text=n.id,this._drawer.reconcile(n.id,n),n}};Ya.$inject=["d3polytree.definitions","d3polytree.moddle","drawingRegistry","notifications","eventBus","labels"];var Ka=class extends Gr{constructor(t,e,r,n,i){super(t,i,e,r,n)}create(){return null}};Ka.$inject=["d3polytree.definitions","drawingRegistry","notifications","eventBus","zones"];var Vd=15,Qa=class extends Gr{constructor(t,e,r,n,i,o,s){super(t,o,r,n,i),this._moddle=e,this._modellingLabels=s}create(t={}){let e=t.type??"default",r=t.position??{x:0,y:0},n=this._moddle.create("pfdn:Coordinates",{x:r.x,y:r.y}),i=this._moddle.create("pfdn:Node",{type:e,position:n,status:1});this._drawer.reconcile(i.id,i);let o=i.position,s=i.size??0,a=this._modellingLabels.create({position:{x:o.x,y:o.y+s+Vd}});return a.text=i.id,a.isReadOnly=!0,i.label=a,this._modellingLabels.reconcile(a.id,a),i}};Qa.$inject=["d3polytree.definitions","d3polytree.moddle","drawingRegistry","notifications","eventBus","nodes","modellingLabels"];var Ft=80,va=20,Ja=class extends Gr{constructor(t,e,r,n,i,o,s){super(t,r,i,o,n),this._routing=new Map,this._moddle=e,this._modellingLabels=s,this.init()}init(){this._eventBus.on("node.moved",this.updateNodeLinks,this),this._eventBus.on("node.updated",this.updateNodeLinks,this)}create(t,e){let r=t.position,n=e.position,i=t.size??0,o=e.size??0,s=r.x+i/2,a=r.y+i/2,l=n.x+o/2,u=n.y+o/2,c=this._createWaypoint(s,a),f=this._createWaypoint(l,u),d=this._moddle.create("pfdn:Link",{source:t,target:e,waypoint:[c,f],status:1});this._drawer.reconcile(d.id,d),this.updateNodeLinks(void 0,d.target),this.updateNodeLinks(void 0,d.source);let m=this._modellingLabels.create({position:{x:(c.x+f.x)/2,y:(c.y+f.y)/2}});return m.text=d.id,m.isReadOnly=!0,d.label=m,this._modellingLabels.reconcile(m.id,m),d}updateNodeLinks(t,e){let r=this._fillPredAndSuc(e);r.predecessors.forEach(n=>this._updateLink(n)),r.successors.forEach(n=>this._updateLink(n))}get _links(){return this._drawer}_createWaypoint(t,e){return this._moddle.create("pfdn:Coordinates",{x:t,y:e})}_calculateAngle(t,e){let r=t.x*e.x+t.y*e.y,n=Math.sqrt(t.x**2+t.y**2),i=Math.sqrt(e.x**2+e.y**2);return Math.acos(r/(n*i))}_sortSide(t,e,r){let n={x:1,y:1},i=1;return e===0?n.x=-1:e===1?i=-1:e===2?(n.y=-1,i=-1):e===3&&(n.x=-1,n.y=-1),[...t].sort((o,s)=>{let a=l=>{let u={x:l.pos.x-r.x,y:l.pos.y-r.y};return i*this._calculateAngle(n,u)};return a(o)-a(s)})}_setQuadrants(t,e,r,n,i){let o=!1,s=Math.abs(r.x-e.x),a=Math.abs(r.y-e.y);r.x>=e.x&&r.y>=e.y?s>=a?(o=3,i&&a>Ft&&(o=0)):(o=0,i&&s>Ft&&(o=3)):r.x<e.x&&r.y>=e.y?s>=a?(o=1,i&&a>Ft&&(o=0)):(o=0,i&&s>Ft&&(o=1)):r.x>=e.x&&r.y<e.y?s>=a?(o=3,i&&a>Ft&&(o=2)):(o=2,i&&s>Ft&&(o=3)):r.x<e.x&&r.y<e.y&&(s>=a?(o=1,i&&a>Ft&&(o=2)):(o=2,i&&s>Ft&&(o=1))),o!==!1&&(t[o].push({obj:n,pos:e}),t[o]=this._sortSide(t[o],o,r))}_setSideConnectors(t,e){let r=[[],[],[],[]];if(!this._drawingRegistry.get(t.id))return;let i=this._fillPredAndSuc(t),o=t.position;i.predecessors.forEach(s=>{let a=s.source;a&&this._setQuadrants(r,a.position,o,a.id,e)}),i.successors.forEach(s=>{let a=s.target;a&&this._setQuadrants(r,a.position,o,a.id,!1)}),i.sides=r}_updateLink(t){let e=t.source,r=t.target;if(!e||!r){console.error(`Link #${t.id} should have valid source and target.`);return}this._setSideConnectors(e,!1),this._setSideConnectors(r,!0);let n=this._routing.get(e.id),i=this._routing.get(r.id);if(!n||!i)return;let o=e.position,s=r.position,a={x:o.x,y:o.y},l={x:s.x,y:s.y},u={idx:0},c={idx:0},f=[],d=!1,m=!1;if(this._adjustSidePoint(a,n.sides,r.id,e.size??0,u),this._adjustSidePoint(l,i.sides,e.id,r.size??0,c),f.push(this._createWaypoint(a.x,a.y)),u.idx===1||u.idx===3){if(c.idx===0||c.idx===2)d={x:l.x,y:a.y};else if(Math.abs(a.y-l.y)>va){let P={x:(l.x+a.x)/2,y:(l.y+a.y)/2};d={x:P.x,y:a.y},m={x:P.x,y:l.y}}}else if(c.idx===1||c.idx===3)d={x:a.x,y:l.y};else if(Math.abs(a.x-l.x)>va){let P={x:(l.x+a.x)/2,y:(l.y+a.y)/2};d={x:a.x,y:P.y},m={x:l.x,y:P.y}}d!==!1&&f.push(this._createWaypoint(d.x,d.y)),m!==!1&&f.push(this._createWaypoint(m.x,m.y)),f.push(this._createWaypoint(l.x,l.y)),t.waypoint=f,this._links.reconcile(t.id,t)}_adjustSidePoint(t,e,r,n,i){let o=!1,s=n*1;e.forEach((a,l)=>{let u=a.length;if(o||u===0)return;let c=s*.8/(u+1),f=s/2-c*(u+1)/2;a.forEach(d=>{f+=c,d.obj===r&&(i.idx=l,l===0?(t.x+=f,t.y-=5):l===1?(t.x+=s+5,t.y+=f):l===2?(t.x+=f,t.y+=s+5):l===3&&(t.x-=5,t.y+=f),o=!0)})})}_fillPredAndSuc(t){let e=[],r=[];this._links.getAll().forEach(o=>{o.target===t&&e.push(o),o.source===t&&r.push(o)});let n=this._routing.get(t.id),i={predecessors:e,successors:r,sides:n?n.sides:[[],[],[],[]]};return this._routing.set(t.id,i),i}};Ja.$inject=["d3polytree.definitions","d3polytree.moddle","links","eventBus","drawingRegistry","notifications","modellingLabels"];var tl=class{constructor(t,e,r,n,i,o){this._eventBus=t,this._elements={label:n,node:r,zone:i,link:o},this._init()}doAction(t,e,r){let n=this._elements[t];if(n){let i=n[e];if(i)return i.apply(n,r)}return null}_init(){let t=(e,r,n)=>{this._eventBus.on(e,(...i)=>this.doAction(r,n,i))};t("label.created","label","saveToModel"),t("link.created","link","saveToModel"),t("node.created","node","saveToModel"),t("zone.created","zone","saveToModel"),t("label.deleted","label","delete"),t("link.deleted","link","delete"),t("node.deleted","node","delete"),t("zone.deleted","zone","delete"),this._eventBus.on("element.updated",(e,r)=>{let n=ht(r),i=this._elements[n];i&&i.reconcile(e,r)})}};tl.$inject=["eventBus","d3polytree.definitions","modellingNodes","modellingLabels","modellingZones","modellingLinks"];var pi={__init__:["modellingLabels"],modellingLabels:["type",Ya],__depends__:[Xe,Ge]},Ud={__init__:["modellingZones"],modellingZones:["type",Ka],__depends__:[Xr,Ge]},Xd={__init__:["modellingNodes"],modellingNodes:["type",Qa],__depends__:[fi,pi,Ge]},Gd={__init__:["modellingLinks"],modellingLinks:["type",Ja],__depends__:[ci,pi,Ge]},Ze={__init__:["modelling"],modelling:["type",tl],__depends__:[pi,Gd,Xd,Ud]},el=class{constructor(t){this._canvas=t}getCenterPosition(){let t=this._canvas.getSVG().node().getBoundingClientRect(),e=this._canvas.getTransform();return{x:t.width/2,y:t.height/2,s:e.a}}};el.$inject=["canvas"];var Zd={__init__:["calculateCenter"],calculateCenter:["type",el]},hi={__init__:["mouseEvents"],mouseEvents:["type",Ba]},_e={__init__:["selection"],selection:["type",La],__depends__:[hi]},Zr={__init__:["zoom"],zoom:["type",$a],__depends__:[Zd]},rl={__init__:["zoomScroll"],zoomScroll:["type",za],__depends__:[Zr]},nl={__init__:["backgroundColor"],backgroundColor:["type",Oa]},mi={__init__:["axes"],axes:["type",Ra],__depends__:[Zr]},Wr={__init__:["outline"],outline:["type",Ia]},il={__init__:["drag"],drag:["type",Da],__depends__:[Wr,_e,oe]},gi={__init__:["exporting"],exporting:["type",ja]},_i={__init__:["localStorage"],localStorage:["type",Fa]},yi={__init__:["upload"],upload:["type",Ha]},Wd={__init__:["addNodeHandler"],addNodeHandler:["type",Ua],__depends__:[oe,_e,Ze]},Yd={__init__:["addLabelHandler"],addLabelHandler:["type",Xa],__depends__:[oe,_e,Ze]},Kd={__init__:["addLinkTool"],addLinkTool:["type",Ga],__depends__:[Ze]},Qd={__init__:["paletteProvider"],paletteProvider:["type",Za],__depends__:[Wd,Yd,Kd,_i,yi,gi,mi,_e,Ge]},ol={__init__:["palette"],palette:["type",Hd],__depends__:[Qd]},sl={__init__:["resizeElement"],resizeElement:["type",qa],__depends__:[Wr]};function Jd(t){let e=[],r=[],n=o=>{e.includes(o)||((o.__depends__??[]).forEach(n),!e.includes(o)&&(e.push(o),(o.__init__??[]).forEach(s=>r.push(s))))};t.forEach(n);let i=new ii(e);return r.forEach(o=>i.get(o)),i}function tp(t){let r=[{config:["value",t]},Mo,...t.modules??[]];return Jd(r)}var al=class{constructor(t={},e){this.injector=e??tp(t),this.get("eventBus").emit("d3canvas.init")}get(t,e){return this.injector.get(t,e)}destroy(){this.get("eventBus").emit("d3canvas.destroy")}clear(){this.get("eventBus").emit("d3canvas.clear")}};function ll(t,e){let r=t.settings;r||(r=e.create("pfdn:Settings",{}),t.settings=r);let n=r.zoom;return n?n.offset||(n.offset=e.create("pfdn:Coordinates",{x:0,y:0})):r.zoom=e.create("pfdn:Zoom",{offset:e.create("pfdn:Coordinates",{x:0,y:0}),scale:1}),r.grid||(r.grid=e.create("pfdn:Grid",{})),t}function ul(){let t=wn();return{definitions:ll(t.create("pfdn:Diagram",{}),t),moddle:t}}async function cl(t){let e=wn(),{rootElement:r}=await e.fromXML(t,"pfdn:Diagram");return{definitions:ll(r,e),moddle:e}}var fl=class dl{constructor(e={}){this.definitions=null,this.moddle=null,this._diagram=null,this._host=null,this.options=e}getModules(){return dl.modules}async importDiagram(e){this._boot(await cl(e))}createEmpty(){this._boot(ul())}getHost(){return this._host}exportDiagram(){if(!this.moddle||!this.definitions)throw new Error("no diagram loaded");return this.moddle.toXML(this.definitions)}exportSVG(){return this.get("canvas").getSVGStr()}get(e,r){if(!this._diagram)throw new Error("no diagram loaded");return this._diagram.get(e,r)}destroy(){this._diagram?.destroy(),this._diagram=null,this._host=null,this.definitions=null,this.moddle=null}_boot(e){this._diagram&&this.destroy(),this._host=e,this.definitions=e.definitions,this.moddle=e.moddle,this._diagram=new al({container:this.options.container,modules:[...this.getModules(),...this.options.modules??[],{d3polytree:["value",this]}]})}};fl.modules=[Xe,Xr,ci,fi];var We=fl;function xi(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var vi=class pl{constructor(e,r,n){this._actions=[],this._canvas=e,this._sideTabsProvider=r,this._eventBus=n,this._init()}trigger(e,r,n){let i=r?r.getAttribute("data-action")??void 0:n;if(i===void 0)return;let o=this._actions[Number(i)];if(!o)return;e==="click"?this._readjustTabs(i):e==="close"&&this._readjustTabs();let s=this._contentsEl.querySelector(`.pfdjs-st-content[data-action="${i}"] > .content-body`),a=o.action;typeof a=="function"?e==="click"&&a(s):a[e]?.(s)}_readjustTabs(e){e===void 0?this._container.classList.remove("open"):this._container.classList.add("open"),this._actions.forEach((r,n)=>{let i=this._tabsEl.querySelector(`[data-action="${n}"]`),o=this._contentsEl.querySelector(`.pfdjs-st-content[data-action="${n}"]`),s=String(n)===e;i?.classList.toggle("active",s),o?.classList.toggle("hidden",!s)})}_drawContainer(){this._container=xi(pl.HTML_MARKUP);let e=this._canvas.getContainer();e.insertBefore(this._container,e.firstChild),this._tabsEl=this._container.querySelector(".pfdjs-st-tabs"),this._contentsEl=this._container.querySelector(".pfdjs-st-contents")}_drawEntry(e,r){let n=xi('<div class="pfdjs-st-tab"></div>');if(this._tabsEl.appendChild(n),n.setAttribute("data-action",String(r)),e.title&&n.setAttribute("title",e.title),e.iconClassName){let o=document.createElement("span");o.className=e.iconClassName,n.appendChild(o)}let i=xi(`<div class="pfdjs-st-content hidden"><div class="content-title"><span class="content-title-span">${e.title??""}</span><span class="icon-cancel" title="Close"></span><span>&nbsp;</span></div><div class="content-body"></div></div>`);this._contentsEl.appendChild(i),i.setAttribute("data-action",String(r)),i.querySelector(".icon-cancel")?.setAttribute("data-action",String(r)),this.trigger("created",null,String(r))}_drawEntries(){this._actions=this._sideTabsProvider.getSideTabsEntries(),this._actions.forEach((e,r)=>this._drawEntry(e,r))}_update(){this._tabsEl&&(this._tabsEl.replaceChildren(),this._contentsEl.replaceChildren()),this._drawEntries()}_createDelegates(){this._tabsEl.addEventListener("click",e=>{let r=e.target.closest(".pfdjs-st-tab");r&&(this.trigger("click",r),e.stopImmediatePropagation())}),this._contentsEl.addEventListener("click",e=>{let r=e.target.closest(".icon-cancel");r&&(this.trigger("close",r),e.stopImmediatePropagation())})}_init(){this._drawContainer(),this._update(),this._eventBus.on("sidetab.registered",()=>this._update()),this._createDelegates()}};vi.$inject=["canvas","sideTabsProvider","eventBus"];vi.HTML_MARKUP='<div class="pfdjs-st-container"><div class="pfdjs-st-tabs"></div><div class="pfdjs-st-contents"></div></div>';var ep=vi,hl=class{constructor(t){this._registeredSideTabs=[],this._eventBus=t}registerSideTab(t,e){e===void 0?this._registeredSideTabs.push(t):this._registeredSideTabs.splice(e,0,t),this._eventBus.emit("sidetab.registered",t)}getSideTabsEntries(){return this._registeredSideTabs}};hl.$inject=["eventBus"];var ml={__init__:["sideTabs","sideTabsProvider"],sideTabs:["type",ep],sideTabsProvider:["type",hl]};var gl=class{constructor(t,e){this._items=new Map,this._searchInput=null,this._listEl=null,this._eventBus=e,this._registerSideTab(t),this._init()}addOrUpdateItem(t){t.name&&(this._items.set(t.id,t),this._render())}removeItem(t){this._items.delete(t)&&this._render()}_init(){this._eventBus.on("node.created",(t,e)=>{this.addOrUpdateItem(this._toItem(t,e,"Node",e.type??""))}),this._eventBus.on("link.created",(t,e)=>{this.addOrUpdateItem(this._toItem(t,e,"Connection",""))}),this._eventBus.on("node.deleted",(t,e)=>{this.removeItem(e.id)}),this._eventBus.on("link.deleted",(t,e)=>{this.removeItem(e.id)})}_toItem(t,e,r,n){return{id:e.id,name:e.label?.text??"",elementType:r,elementSubType:n,element:t,definition:e}}_drawForm(t){if(!t)return;t.replaceChildren();let e=document.createElement("div");e.id="pfdjs-searchpanel",this._searchInput=document.createElement("input"),this._searchInput.className="search",this._searchInput.placeholder="Search",this._listEl=document.createElement("ul"),this._listEl.className="list",e.append(this._searchInput,this._listEl),t.appendChild(e),this._searchInput.addEventListener("input",()=>this._render()),this._listEl.addEventListener("click",r=>{let n=r.target.closest("li[data-id]");n&&(this._activate(n.getAttribute("data-id")??""),r.stopImmediatePropagation())}),this._render()}_activate(t){let e=this._items.get(t);if(!e)return;this._eventBus.emit("zoom.to.element",e.element,e.definition);let r=`${e.definition.$descriptor.ns.localName.toLowerCase()}.click`;this._eventBus.emit(r,e.element,e.definition,null)}_render(){if(!this._listEl)return;let t=(this._searchInput?.value??"").trim().toLowerCase(),e=[...this._items.values()].filter(r=>!t||r.name.toLowerCase().includes(t)).sort((r,n)=>r.name.localeCompare(n.name));this._listEl.replaceChildren();for(let r of e){let n=document.createElement("li");n.setAttribute("data-id",r.id),n.innerHTML='<h3 class="name"></h3><p><span class="elementType"></span>&nbsp;&nbsp;<span class="elementSubType"></span></p>',n.querySelector(".name").textContent=r.name,n.querySelector(".elementType").textContent=r.elementType,n.querySelector(".elementSubType").textContent=r.elementSubType,this._listEl.appendChild(n)}}_registerSideTab(t){t.registerSideTab({title:"Search element",iconClassName:"icon-glass",action:{created:e=>this._drawForm(e),click:()=>this._render()}},0)}};gl.$inject=["sideTabsProvider","eventBus"];var _l={__init__:["searchPanel"],searchPanel:["type",gl]};var yl=class xl extends We{getModules(){return[...xl.interactionModules,...We.modules]}};yl.interactionModules=[nl,Zr,rl,mi,hi,_e,Wr,ml,_l];var wi=yl;function pt(t,e){return t.$instanceOf(e)}function Yr(t,e){return e.split(".").reduce((r,n)=>r?.[n],t)}function wl(t,e,r){let n=e.split("."),i=t;for(let o=0;o<n.length-1;o+=1){let s=n[o];(i[s]==null||typeof i[s]!="object")&&(i[s]={}),i=i[s]}i[n[n.length-1]]=r}function rp(t,e){let r;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>t(...n),e)}}function np(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([a-zA-Z])([0-9])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function ip(t){return typeof t=="string"&&/^#[0-9a-fA-F]{6}$/.test(t)}function vl(t){if(!t)throw new Error(`${t} must be set.`);return t}var bl=class{constructor(t){this._eventBus=t}setDefaultParameters(t){let e=this._eventBus;return{html:"",description:"",get:(o,s)=>{let a=vl(t.modelProperty),l=Yr(o,a),u=s.querySelector("input");u&&(u.value=l==null?"":String(l))},set:(o,s)=>{let a=vl(t.modelProperty);return wl(o,a,Yr(s,a)),!0},validate:()=>({}),...t,triggerUpdate:(o,s)=>{e.emit("PropertiesPanel.propertyChanged",o,s)}}}textField(t){return op(this.setDefaultParameters(t))}selectBox(t){return sp(this.setDefaultParameters(t))}colorPicker(t){return ap(this.setDefaultParameters(t))}spreadsheet(t){return this.setDefaultParameters(t)}};bl.$inject=["eventBus"];function bi(t,e){let r=t.label??t.id;return`<div class="pfdjs-pp-field-wrapper"><label for="pfdjs-${t.id}">${r}</label>${e}</div>`}function op(t){let e=t.type??"text";return t.html=bi(t,`<input id="pfdjs-${t.id}" type="${e}" name="${t.modelProperty}" />`),t}function sp(t){let e=t.allowEmpty??!0,n=(Array.isArray(t.selectOptions)?t.selectOptions.concat(e?[{name:"",value:""}]:[]):[{name:"",value:""}]).map(i=>`<option value="${i.value}">${i.name}</option>`).join("");return t.html=bi(t,`<select id="pfdjs-${t.id}" name="${t.modelProperty}">${n}</select>`),t.get=(i,o)=>{let s=i.get(t.modelProperty)??"default";o.querySelectorAll(`select#pfdjs-${t.id} > option`).forEach(a=>{a.selected=a.value===s})},t}function ap(t){return t.html=bi(t,`<input id="pfdjs-${t.id}" type="color" name="${t.modelProperty}" />`),t.get=(e,r)=>{let n=r.querySelector("input[type=color]"),i=Yr(e,t.modelProperty);n&&ip(i)&&(n.value=i)},t}var Nl={__init__:["entryFactory"],entryFactory:["type",bl]};function lp(t,e,r){pt(e,"pfdn:Node")?(t.entries.push(r.textField({id:"name",label:"Name",modelProperty:"name"})),t.entries.push(r.textField({id:"tag",label:"Tag",modelProperty:"tag"})),t.entries.push(r.textField({id:"label.text",label:"Diagram label",modelProperty:"label.text"}))):pt(e,"pfdn:Settings")?(t.entries.push(r.textField({id:"name",label:"Diagram name",modelProperty:"name"})),t.entries.push(r.textField({id:"author",label:"Author's name",modelProperty:"author"}))):pt(e,"pfdn:Link")?t.entries.push(r.textField({id:"label.text",label:"Diagram label",modelProperty:"label.text"})):pt(e,"pfdn:Label")&&t.entries.push(r.textField({id:"text",label:"Label",modelProperty:"text"}))}function up(t,e,r,n){if(!pt(e,"pfdn:Node"))return;let i=Object.keys(n).map(o=>({value:o,name:np(o)}));t.entries.push(r.selectBox({id:"type",label:"Icon",modelProperty:"type",allowEmpty:!1,selectOptions:i})),t.entries.push(r.textField({id:"size",label:"Size",modelProperty:"size",type:"number"}))}function cp(t,e,r){pt(e,"pfdn:Link")&&(t.entries.push(r.textField({id:"lineWidth",label:"Line width",modelProperty:"lineWidth",type:"number"})),t.entries.push(r.colorPicker({id:"lineColor",label:"Line color",modelProperty:"lineColor"})))}function fp(t,e,r){pt(e,"pfdn:Node")||pt(e,"pfdn:Link")?(t.entries.push(r.textField({id:"label.fontSize",label:"Font size",modelProperty:"label.fontSize",type:"number"})),t.entries.push(r.colorPicker({id:"label.color",label:"Color",modelProperty:"label.color"}))):pt(e,"pfdn:Label")&&(t.entries.push(r.textField({id:"fontSize",label:"Font size",modelProperty:"fontSize",type:"number"})),t.entries.push(r.colorPicker({id:"color",label:"Color",modelProperty:"color"})))}function dp(t,e,r){pt(e,"pfdn:Settings")&&(t.entries.push(r.colorPicker({id:"backgroundColor",label:"Background color",modelProperty:"backgroundColor"})),t.entries.push(r.colorPicker({id:"grid.lineColor",label:"Line color",modelProperty:"grid.lineColor"})),t.entries.push(r.textField({id:"grid.size",label:"Square size",modelProperty:"grid.size",type:"number"})),t.entries.push(r.textField({id:"grid.lineWidth",label:"Line width",modelProperty:"grid.lineWidth",type:"number"})))}var El=class{constructor(t,e,r){this._icons=t,this._entryFactory=e,this._eventBus=r}updateDrawing(t){if(pt(t,"pfdn:Settings")){this._eventBus.emit("canvas.resized");return}if(this._eventBus.emit("element.updated",t.id,t),pt(t,"pfdn:Link")||pt(t,"pfdn:Node")){let e=t.label;e&&this._eventBus.emit("element.updated",e.id,e)}}getTabs(t){let e=this._entryFactory;return[this._propertiesTab(t,e),this._formatTab(t,e)]}_propertiesTab(t,e){let r={id:"general",label:"General",entries:[]};return lp(r,t,e),{id:"properties",label:"Properties",groups:[r]}}_formatTab(t,e){let r={id:"elementFormat",label:"Element format",entries:[]},n={id:"labelFormat",label:"Label format",entries:[]},i={id:"gridFormat",label:"Grid format",entries:[]};return up(r,t,e,this._icons),cp(r,t,e),fp(n,t,e),dp(i,t,e),{id:"format",label:"Format",groups:[r,n,i]}}};El.$inject=["icons","entryFactory","eventBus"];var Ml={__init__:["propertiesProvider"],propertiesProvider:["type",El]};function Ye(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var pp=new Set(["INPUT","TEXTAREA","SELECT"]),Ni=class Sl{constructor(e,r,n,i){this._entries={},this._container=null,this._tabsEl=null,this._contentsEl=null,this._eventBus=r,this._propertiesProvider=n,this._diagramSettings=i,this._registerSideTab(e),this._registerSelectionListener()}_registerSideTab(e){e.registerSideTab({title:"Properties",iconClassName:"icon-sliders",action:{created:r=>this._drawPanel(r)}},1)}_registerSelectionListener(){this._eventBus.on("selection.changed",(e,r)=>{let n=this._diagramSettings;r.length===1&&(e.length!==1||e[0].definition.id!==r[0].definition.id)&&(n=r[0].definition),this._update(n)})}_drawPanel(e){e&&(this._drawContainer(e),this._update(this._diagramSettings))}_drawContainer(e){this._container=Ye(Sl.HTML_MARKUP),e.insertBefore(this._container,e.firstChild),this._tabsEl=this._container.querySelector(".tab-sheets"),this._contentsEl=this._container.querySelector(".pfdjs-pp-contents"),this._container.addEventListener("click",r=>{let n=r.target.closest(".tab-sheet");n&&(this._selectTab(n.getAttribute("data-tab-target")),r.stopImmediatePropagation())}),this._registerInputChangeHandlers()}_registerInputChangeHandlers(){let e=this._container;if(!e)return;let r=rp(n=>this._applyChange(n),300);e.addEventListener("input",n=>{let i=n.target;(i.tagName==="INPUT"||i.tagName==="TEXTAREA")&&r(i)}),e.addEventListener("change",n=>{let i=n.target;pp.has(i.tagName)&&this._applyChange(i)}),this._eventBus.on("PropertiesPanel.propertyChanged",(n,i)=>this._applyChangeByProperty(n,i))}_applyChange(e){let r=e.getAttribute("name");r&&this._commit(r,e.value)}_applyChangeByProperty(e,r){this._commit(e,Yr(r,e))}_commit(e,r){let n=this._entries[e];if(!n)return;let i={};wl(i,e,r),n.scope.set(n.definition,i),this._propertiesProvider.updateDrawing(n.definition)}_selectTab(e){this._tabsEl?.querySelectorAll(".tab-sheet").forEach(r=>{r.classList.toggle("tab-sheet-active",r.getAttribute("data-tab-target")===e)}),this._contentsEl?.querySelectorAll(".pfdjs-pp-content").forEach(r=>{r.classList.toggle("open",r.getAttribute("data-tab-target")===e)})}_update(e){this._tabsEl&&this._contentsEl&&(this._tabsEl.replaceChildren(),this._contentsEl.replaceChildren()),e&&this._drawEntries(e)}_drawEntries(e){if(!this._tabsEl||!this._contentsEl)return;let r=this._propertiesProvider.getTabs(e),n=[];this._entries={};for(let o of r){let s=Ye(`<div class="pfdjs-pp-content" data-tab-target="${o.id}"></div>`),a=!1;for(let l of o.groups){if(l.entries.length===0)continue;let u=Ye(`<div class="pfdjs-pp-content-group" data-group-target="${l.id}"><div class="tab-content-group-title">${l.label}</div></div>`);for(let c of l.entries){let f=Ye(`<div>${c.html}</div>`);u.appendChild(f),this._entries[c.id]={scope:c,definition:e,formNode:f}}s.appendChild(u),a=!0}a&&(this._contentsEl.appendChild(s),n.push({id:o.id,label:o.label}))}Object.values(this._entries).forEach(o=>o.scope.get(o.definition,o.formNode));let i=null;for(let o of n)i??(i=o.id),this._tabsEl.appendChild(Ye(`<li class="tab-sheet" data-tab-target="${o.id}"><a href="#">${o.label}</a></li>`));this._selectTab(i)}};Ni.$inject=["sideTabsProvider","eventBus","propertiesProvider","d3polytree.definitions.settings"];Ni.HTML_MARKUP='<div id="pfdjs-pp-container"><div class="pfdjs-pp-tabs"><ul class="tab-sheets"></ul></div><div class="pfdjs-pp-contents"></div></div>';var hp=Ni,kl={__init__:["propertiesPanel"],propertiesPanel:["type",hp]};var mp='<?xml version="1.0" encoding="UTF-8"?><pfdn:diagram xmlns:pfdn="http://pfdn" xmlns="http://pfdn"><settings author="No Author" name="No Name Diagram" status="1"><zoom><offset x="0" y="0" /><scale>1</scale></zoom><grid /></settings><node id="node_1" label="label_1" status="1"><position x="20" y="100" /></node><label id="label_1" fontSize="12" isReadOnly="true" status="1"><position x="33" y="140" /><text>Node 1</text></label></pfdn:diagram>',Qr=class Qr extends wi{constructor(){super(...arguments);this.initialDiagram=mp}createDiagram(){return this.importDiagram(this.initialDiagram)}getModules(){return[...wi.interactionModules,...Qr.editionModules,...We.modules]}createNode(r={}){return this.get("modellingNodes").create(r)}select(r){let n=this.get("drawingRegistry").get(r.id);n&&this.get("selection").select(n,r)}deleteSelected(){this.get("selection").deleteSelected()}};Qr.editionModules=[il,Ze,gi,_i,yi,ol,sl,Nl,Ml,kl];var Kr=Qr,gp=Kr;return Ol(_p);})();
1
+ "use strict";var d3PolytreeEditor=(()=>{var Cl=Object.create;var rr=Object.defineProperty;var Tl=Object.getOwnPropertyDescriptor;var Pl=Object.getOwnPropertyNames;var Ll=Object.getPrototypeOf,Bl=Object.prototype.hasOwnProperty;var Rl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$l=(t,e)=>{for(var r in e)rr(t,r,{get:e[r],enumerable:!0})},Bi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Pl(e))!Bl.call(t,i)&&i!==r&&rr(t,i,{get:()=>e[i],enumerable:!(n=Tl(e,i))||n.enumerable});return t};var zl=(t,e,r)=>(r=t!=null?Cl(Ll(t)):{},Bi(e||!t||!t.__esModule?rr(r,"default",{value:t,enumerable:!0}):r,t)),Ol=t=>Bi(rr({},"__esModule",{value:!0}),t);var Mo=Rl((Pm,fn)=>{"use strict";var zu=Object.prototype.hasOwnProperty,ot="~";function Me(){}Object.create&&(Me.prototype=Object.create(null),new Me().__proto__||(ot=!1));function Ou(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function No(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new Ou(r,n||t,i),s=ot?ot+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],o]:t._events[s].push(o):(t._events[s]=o,t._eventsCount++),t}function lr(t,e){--t._eventsCount===0?t._events=new Me:delete t._events[e]}function nt(){this._events=new Me,this._eventsCount=0}nt.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)zu.call(r,n)&&e.push(ot?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};nt.prototype.listeners=function(e){var r=ot?ot+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};nt.prototype.listenerCount=function(e){var r=ot?ot+e:e,n=this._events[r];return n?n.fn?1:n.length:0};nt.prototype.emit=function(e,r,n,i,o,s){var a=ot?ot+e:e;if(!this._events[a])return!1;var l=this._events[a],u=arguments.length,c,f;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,r),!0;case 3:return l.fn.call(l.context,r,n),!0;case 4:return l.fn.call(l.context,r,n,i),!0;case 5:return l.fn.call(l.context,r,n,i,o),!0;case 6:return l.fn.call(l.context,r,n,i,o,s),!0}for(f=1,c=new Array(u-1);f<u;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var p=l.length,m;for(f=0;f<p;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),u){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,r);break;case 3:l[f].fn.call(l[f].context,r,n);break;case 4:l[f].fn.call(l[f].context,r,n,i);break;default:if(!c)for(m=1,c=new Array(u-1);m<u;m++)c[m-1]=arguments[m];l[f].fn.apply(l[f].context,c)}}return!0};nt.prototype.on=function(e,r,n){return No(this,e,r,n,!1)};nt.prototype.once=function(e,r,n){return No(this,e,r,n,!0)};nt.prototype.removeListener=function(e,r,n,i){var o=ot?ot+e:e;if(!this._events[o])return this;if(!r)return lr(this,o),this;var s=this._events[o];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&lr(this,o);else{for(var a=0,l=[],u=s.length;a<u;a++)(s[a].fn!==r||i&&!s[a].once||n&&s[a].context!==n)&&l.push(s[a]);l.length?this._events[o]=l.length===1?l[0]:l:lr(this,o)}return this};nt.prototype.removeAllListeners=function(e){var r;return e?(r=ot?ot+e:e,this._events[r]&&lr(this,r)):(this._events=new Me,this._eventsCount=0),this};nt.prototype.off=nt.prototype.removeListener;nt.prototype.addListener=nt.prototype.on;nt.prefixed=ot;nt.EventEmitter=nt;typeof fn<"u"&&(fn.exports=nt)});var gd={};$l(gd,{Editor:()=>on,EntryFactory:()=>ve,PfdnPropertiesProvider:()=>xe,PropertiesPanel:()=>we,default:()=>md,entryFactoryModule:()=>rn,pfdnPropertiesProviderModule:()=>nn,propertiesPanelModule:()=>Ti});var nr="http://www.w3.org/1999/xhtml",an={svg:"http://www.w3.org/2000/svg",xhtml:nr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function kt(t){var e=t+="",r=e.indexOf(":");return r>=0&&(e=t.slice(0,r))!=="xmlns"&&(t=t.slice(r+1)),an.hasOwnProperty(e)?{space:an[e],local:t}:t}function Il(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===nr&&e.documentElement.namespaceURI===nr?e.createElement(t):e.createElementNS(r,t)}}function Dl(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function ir(t){var e=kt(t);return(e.local?Dl:Il)(e)}function Fl(){}function Vt(t){return t==null?Fl:function(){return this.querySelector(t)}}function Ri(t){typeof t!="function"&&(t=Vt(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=new Array(s),l,u,c=0;c<s;++c)(l=o[c])&&(u=t.call(l,l.__data__,c,o))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new G(n,this._parents)}function ln(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function jl(){return[]}function be(t){return t==null?jl:function(){return this.querySelectorAll(t)}}function Hl(t){return function(){return ln(t.apply(this,arguments))}}function $i(t){typeof t=="function"?t=Hl(t):t=be(t);for(var e=this._groups,r=e.length,n=[],i=[],o=0;o<r;++o)for(var s=e[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&(n.push(t.call(l,l.__data__,u,s)),i.push(l));return new G(n,i)}function Ee(t){return function(){return this.matches(t)}}function or(t){return function(e){return e.matches(t)}}var ql=Array.prototype.find;function Vl(t){return function(){return ql.call(this.children,t)}}function Gl(){return this.firstElementChild}function zi(t){return this.select(t==null?Gl:Vl(typeof t=="function"?t:or(t)))}var Ul=Array.prototype.filter;function Xl(){return Array.from(this.children)}function Zl(t){return function(){return Ul.call(this.children,t)}}function Oi(t){return this.selectAll(t==null?Xl:Zl(typeof t=="function"?t:or(t)))}function Ii(t){typeof t!="function"&&(t=Ee(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&a.push(l);return new G(n,this._parents)}function sr(t){return new Array(t.length)}function Di(){return new G(this._enter||this._groups.map(sr),this._parents)}function Ne(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Ne.prototype={constructor:Ne,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Fi(t){return function(){return t}}function Wl(t,e,r,n,i,o){for(var s=0,a,l=e.length,u=o.length;s<u;++s)(a=e[s])?(a.__data__=o[s],n[s]=a):r[s]=new Ne(t,o[s]);for(;s<l;++s)(a=e[s])&&(i[s]=a)}function Yl(t,e,r,n,i,o,s){var a,l,u=new Map,c=e.length,f=o.length,p=new Array(c),m;for(a=0;a<c;++a)(l=e[a])&&(p[a]=m=s.call(l,l.__data__,a,e)+"",u.has(m)?i[a]=l:u.set(m,l));for(a=0;a<f;++a)m=s.call(t,o[a],a,o)+"",(l=u.get(m))?(n[a]=l,l.__data__=o[a],u.delete(m)):r[a]=new Ne(t,o[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(p[a])===l&&(i[a]=l)}function Kl(t){return t.__data__}function ji(t,e){if(!arguments.length)return Array.from(this,Kl);var r=e?Yl:Wl,n=this._parents,i=this._groups;typeof t!="function"&&(t=Fi(t));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),u=0;u<o;++u){var c=n[u],f=i[u],p=f.length,m=Ql(t.call(c,c&&c.__data__,u,n)),T=m.length,A=a[u]=new Array(T),O=s[u]=new Array(T),N=l[u]=new Array(p);r(c,f,A,O,N,m,e);for(var _=0,M=0,d,y;_<T;++_)if(d=A[_]){for(_>=M&&(M=_+1);!(y=O[M])&&++M<T;);d._next=y||null}}return s=new G(s,n),s._enter=a,s._exit=l,s}function Ql(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Hi(){return new G(this._exit||this._groups.map(sr),this._parents)}function qi(t,e,r){var n=this.enter(),i=this,o=this.exit();return typeof t=="function"?(n=t(n),n&&(n=n.selection())):n=n.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),r==null?o.remove():r(o),n&&i?n.merge(i).order():i}function Vi(t){for(var e=t.selection?t.selection():t,r=this._groups,n=e._groups,i=r.length,o=n.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var u=r[l],c=n[l],f=u.length,p=a[l]=new Array(f),m,T=0;T<f;++T)(m=u[T]||c[T])&&(p[T]=m);for(;l<i;++l)a[l]=r[l];return new G(a,this._parents)}function Gi(){for(var t=this._groups,e=-1,r=t.length;++e<r;)for(var n=t[e],i=n.length-1,o=n[i],s;--i>=0;)(s=n[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Ui(t){t||(t=Jl);function e(f,p){return f&&p?t(f.__data__,p.__data__):!f-!p}for(var r=this._groups,n=r.length,i=new Array(n),o=0;o<n;++o){for(var s=r[o],a=s.length,l=i[o]=new Array(a),u,c=0;c<a;++c)(u=s[c])&&(l[c]=u);l.sort(e)}return new G(i,this._parents).order()}function Jl(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Xi(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Zi(){return Array.from(this)}function Wi(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],i=0,o=n.length;i<o;++i){var s=n[i];if(s)return s}return null}function Yi(){let t=0;for(let e of this)++t;return t}function Ki(){return!this.node()}function Qi(t){for(var e=this._groups,r=0,n=e.length;r<n;++r)for(var i=e[r],o=0,s=i.length,a;o<s;++o)(a=i[o])&&t.call(a,a.__data__,o,i);return this}function tu(t){return function(){this.removeAttribute(t)}}function eu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ru(t,e){return function(){this.setAttribute(t,e)}}function nu(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function iu(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttribute(t):this.setAttribute(t,r)}}function ou(t,e){return function(){var r=e.apply(this,arguments);r==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,r)}}function Ji(t,e){var r=kt(t);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((e==null?r.local?eu:tu:typeof e=="function"?r.local?ou:iu:r.local?nu:ru)(r,e))}function ar(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function su(t){return function(){this.style.removeProperty(t)}}function au(t,e,r){return function(){this.style.setProperty(t,e,r)}}function lu(t,e,r){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(t):this.style.setProperty(t,n,r)}}function to(t,e,r){return arguments.length>1?this.each((e==null?su:typeof e=="function"?lu:au)(t,e,r??"")):Rt(this.node(),t)}function Rt(t,e){return t.style.getPropertyValue(e)||ar(t).getComputedStyle(t,null).getPropertyValue(e)}function uu(t){return function(){delete this[t]}}function cu(t,e){return function(){this[t]=e}}function fu(t,e){return function(){var r=e.apply(this,arguments);r==null?delete this[t]:this[t]=r}}function eo(t,e){return arguments.length>1?this.each((e==null?uu:typeof e=="function"?fu:cu)(t,e)):this.node()[t]}function ro(t){return t.trim().split(/^|\s+/)}function un(t){return t.classList||new no(t)}function no(t){this._node=t,this._names=ro(t.getAttribute("class")||"")}no.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function io(t,e){for(var r=un(t),n=-1,i=e.length;++n<i;)r.add(e[n])}function oo(t,e){for(var r=un(t),n=-1,i=e.length;++n<i;)r.remove(e[n])}function pu(t){return function(){io(this,t)}}function du(t){return function(){oo(this,t)}}function hu(t,e){return function(){(e.apply(this,arguments)?io:oo)(this,t)}}function so(t,e){var r=ro(t+"");if(arguments.length<2){for(var n=un(this.node()),i=-1,o=r.length;++i<o;)if(!n.contains(r[i]))return!1;return!0}return this.each((typeof e=="function"?hu:e?pu:du)(r,e))}function mu(){this.textContent=""}function gu(t){return function(){this.textContent=t}}function yu(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function ao(t){return arguments.length?this.each(t==null?mu:(typeof t=="function"?yu:gu)(t)):this.node().textContent}function _u(){this.innerHTML=""}function vu(t){return function(){this.innerHTML=t}}function xu(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function lo(t){return arguments.length?this.each(t==null?_u:(typeof t=="function"?xu:vu)(t)):this.node().innerHTML}function wu(){this.nextSibling&&this.parentNode.appendChild(this)}function uo(){return this.each(wu)}function bu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function co(){return this.each(bu)}function fo(t){var e=typeof t=="function"?t:ir(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Eu(){return null}function po(t,e){var r=typeof t=="function"?t:ir(t),n=e==null?Eu:typeof e=="function"?e:Vt(e);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function Nu(){var t=this.parentNode;t&&t.removeChild(this)}function ho(){return this.each(Nu)}function Mu(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Su(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function mo(t){return this.select(t?Su:Mu)}function go(t){return arguments.length?this.property("__data__",t):this.node().__data__}function ku(t){return function(e){t.call(this,e,this.__data__)}}function Au(t){return t.trim().split(/^|\s+/).map(function(e){var r="",n=e.indexOf(".");return n>=0&&(r=e.slice(n+1),e=e.slice(0,n)),{type:e,name:r}})}function Cu(t){return function(){var e=this.__on;if(e){for(var r=0,n=-1,i=e.length,o;r<i;++r)o=e[r],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++n]=o;++n?e.length=n:delete this.__on}}}function Tu(t,e,r){return function(){var n=this.__on,i,o=ku(e);if(n){for(var s=0,a=n.length;s<a;++s)if((i=n[s]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=r),i.value=e;return}}this.addEventListener(t.type,o,r),i={type:t.type,name:t.name,value:e,listener:o,options:r},n?n.push(i):this.__on=[i]}}function yo(t,e,r){var n=Au(t+""),i,o=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(i=0,c=a[l];i<o;++i)if((s=n[i]).type===c.type&&s.name===c.name)return c.value}return}for(a=e?Tu:Cu,i=0;i<o;++i)this.each(a(n[i],e,r));return this}function _o(t,e,r){var n=ar(t),i=n.CustomEvent;typeof i=="function"?i=new i(e,r):(i=n.document.createEvent("Event"),r?(i.initEvent(e,r.bubbles,r.cancelable),i.detail=r.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Pu(t,e){return function(){return _o(this,t,e)}}function Lu(t,e){return function(){return _o(this,t,e.apply(this,arguments))}}function vo(t,e){return this.each((typeof e=="function"?Lu:Pu)(t,e))}function*xo(){for(var t=this._groups,e=0,r=t.length;e<r;++e)for(var n=t[e],i=0,o=n.length,s;i<o;++i)(s=n[i])&&(yield s)}var cn=[null];function G(t,e){this._groups=t,this._parents=e}function wo(){return new G([[document.documentElement]],cn)}function Bu(){return this}G.prototype=wo.prototype={constructor:G,select:Ri,selectAll:$i,selectChild:zi,selectChildren:Oi,filter:Ii,data:ji,enter:Di,exit:Hi,join:qi,merge:Vi,selection:Bu,order:Gi,sort:Ui,call:Xi,nodes:Zi,node:Wi,size:Yi,empty:Ki,each:Qi,attr:Ji,style:to,property:eo,classed:so,text:ao,html:lo,raise:uo,lower:co,append:fo,insert:po,remove:ho,clone:mo,datum:go,on:yo,dispatch:vo,[Symbol.iterator]:xo};var At=wo;function U(t){return typeof t=="string"?new G([[document.querySelector(t)]],[document.documentElement]):new G([[t]],cn)}function bo(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Q(t,e){if(t=bo(t),e===void 0&&(e=t.currentTarget),e){var r=e.ownerSVGElement||e;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}function Ru(t,e){return e={exports:{}},t(e,e.exports),e.exports}var $u=Ru(function(t){var e=t.exports=function(r,n){if(n||(n=16),r===void 0&&(r=128),r<=0)return"0";for(var i=Math.log(Math.pow(2,r))/Math.log(n),o=2;i===1/0;o*=2)i=Math.log(Math.pow(2,r/o))/Math.log(n)*o;for(var s=i-Math.floor(i),a="",o=0;o<Math.floor(i);o++){var l=Math.floor(Math.random()*n).toString(n);a=l+a}if(s){var u=Math.pow(n,s),l=Math.floor(Math.random()*u).toString(n);a=l+a}var c=parseInt(a,n);return c!==1/0&&c>=Math.pow(2,r)?e(r,n):a};e.rack=function(r,n,i){var o=function(a){var l=0;do{if(l++>10)if(i)r+=i;else throw new Error("too many ID collisions, use more bits");var u=e(r,n)}while(Object.hasOwnProperty.call(s,u));return s[u]=a,u},s=o.hats={};return o.get=function(a){return o.hats[a]},o.set=function(a,l){return o.hats[a]=l,o},o.bits=r||128,o.base=n||16,o}});function Ct(t){if(!(this instanceof Ct))return new Ct(t);t=t||[128,36,1],this._seed=t.length?$u.rack(t[0],t[1],t[2]):t}Ct.prototype.next=function(t){return this._seed(t||!0)};Ct.prototype.nextPrefixed=function(t,e){var r;do r=t+this.next(!0);while(this.assigned(r));return this.claim(r,e),r};Ct.prototype.claim=function(t,e){this._seed.set(t,e||!0)};Ct.prototype.assigned=function(t){return this._seed.get(t)||!1};Ct.prototype.unclaim=function(t){delete this._seed.hats[t]};Ct.prototype.clear=function(){var t=this._seed.hats,e;for(e in t)this.unclaim(e)};var Eo=Ct;var So=zl(Mo(),1);var ko=So.default;function Iu(t){t.setAttribute("xlink","http://www.w3.org/1999/xlink"),ju(Fu(t),t);let r=new XMLSerializer().serializeToString(t);return r=r.replace(/(\w+)?:?xlink=/g,"xmlns:xlink="),r=r.replace(/NS\d+:href/g,"xlink:href"),r}function Du(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function Ao(t,e){return e.some(r=>t.match(r)!==null)}function Fu(t){let e="[\\.,#\\s\\*>+~\\[=:]",r=a=>new RegExp(`.*${e}${Du(a)}${e}.*`,"gi"),n=[],i=a=>{Ao(a,n)||n.push(r(a))};i(`#${t.id}`),t.classList.forEach(a=>i(`.${a}`));let o=t.getElementsByTagName("*");for(let a=0;a<o.length;a++){let l=o[a];l.id&&i(`#${l.id}`),l.classList.forEach(u=>i(`.${u}`))}let s="";for(let a=0;a<document.styleSheets.length;a++){let l=document.styleSheets[a],u=null;try{u=l.cssRules}catch(c){if(c.name!=="SecurityError")throw c;continue}if(u)for(let c=0;c<u.length;c++){let f=u[c];f.selectorText&&Ao(`${f.selectorText} `,n)&&(s+=f.cssText)}}return s}function ju(t,e){let r=document.createElement("style");r.setAttribute("type","text/css"),r.textContent=t;let n=e.hasChildNodes()?e.children[0]:null;e.insertBefore(r,n)}function Co(t){return typeof t=="number"?`${t}px`:t}function Hu(t){let e=t.container??document.body,r=document.createElement("div");return r.setAttribute("class","pfdjs-container"),Object.assign(r.style,{position:"absolute",overflow:"hidden",width:Co(t.width??"100%"),height:Co(t.height??"100%")}),e.appendChild(r),r}var To=class{constructor(t,e){this._eventBus=e,this._init(t??{})}_init(t){let e=this._eventBus;this._container=Hu(t),this._svg=U(this._container).append("svg").attr("width","100%").attr("height","100%").attr("pointer-events","all"),this._rootLayer=this._drawingLayer=this._svg.append("g").attr("class","full-group"),e.on("d3canvas.init",()=>{e.emit("canvas.init",{svg:this._svg}),this.resized()}),e.on("d3canvas.destroy",()=>this._destroy())}_destroy(){this._eventBus.emit("canvas.destroy",{svg:this._svg});let t=this._container?.parentNode;t&&t.removeChild(this._container)}getContainer(){return this._container}getSVG(){return this._svg}getSVGStr(){return Iu(this._svg.node())}getRootLayer(){return this._rootLayer}getDrawingLayer(){return this._drawingLayer}setDrawingLayer(t){this._drawingLayer=t}getTransform(t){let r=(t??this._drawingLayer).attr("transform"),n={a:1,d:1,e:0,f:0};if(!r)return n;let i=document.createElementNS("http://www.w3.org/2000/svg","g");i.setAttributeNS(null,"transform",r);let s=i.transform?.baseVal?.consolidate?.()?.matrix;return s?{a:s.a,d:s.d,e:s.e,f:s.f}:n}getSize(){return{width:this._container.clientWidth,height:this._container.clientHeight}}resized(){this._eventBus.emit("canvas.resized")}};To.$inject=["config","eventBus"];var qu=class{constructor(){this._ids=new Eo([8,24,86]),this._elements=new Map}claim(t,e){this._ids.claim(t,e),this._elements.set(t,e)}claimId(t,e){t.id=t.id||this._ids.nextPrefixed(`${e}_`,t),this._ids.claim(t.id,t),this._elements.set(t.id,t)}unClaim(t){t.id&&(this._ids.unclaim(t.id),this._elements.delete(t.id))}removeElement(t){this.unClaim(t)}removeElementById(t){this._ids.unclaim(t),this._elements.delete(t)}get(t){return this._elements.get(t)??!1}getAll(){return Object.fromEntries(this._elements)}},Po=class{constructor(t){this._elementRegistry=t}create(t,e,r,n){e!==""&&(this._elementRegistry.claimId(t,e),r.call(n,t))}};Po.$inject=["elementRegistry"];var Lo={__init__:["canvas"],canvas:["type",To],elementRegistry:["type",qu],elementBuilder:["type",Po],eventBus:["type",ko]};var ur=Object.prototype.toString,Vu=Object.prototype.hasOwnProperty;function pn(t){return t===void 0}function Gu(t){return t!==void 0}function Bo(t){return t==null}function Ro(t){return ur.call(t)==="[object Array]"}function $o(t){return ur.call(t)==="[object Object]"}function Uu(t){let e=ur.call(t);return e==="[object Function]"||e==="[object AsyncFunction]"||e==="[object GeneratorFunction]"||e==="[object AsyncGeneratorFunction]"||e==="[object Proxy]"}function $t(t){return ur.call(t)==="[object String]"}function dn(t,e){return!Bo(t)&&Vu.call(t,e)}function hn(t,e){let r=mn(e),n;return F(t,function(i,o){if(r(i,o))return n=i,!1}),n}function zo(t,e){let r=mn(e),n=Ro(t)?-1:void 0;return F(t,function(i,o){if(r(i,o))return n=o,!1}),n}function cr(t,e){let r=mn(e),n=[];return F(t,function(i,o){r(i,o)&&n.push(i)}),n}function F(t,e){let r,n;if(pn(t))return;let i=Ro(t)?Zu:Xu;for(let o in t)if(dn(t,o)&&(r=t[o],n=e(r,i(o)),n===!1))return r}function mn(t){return Uu(t)?t:e=>e===t}function Xu(t){return t}function Zu(t){return Number(t)}function Gt(t,e){return t.bind(e)}function Z(t,...e){return Object.assign(t,...e)}function Oo(t,e,r){let n=t;return F(e,function(i,o){if(typeof i!="number"&&typeof i!="string")throw new Error("illegal key type: "+typeof i+". Key should be of type number or string.");if(i==="constructor")throw new Error("illegal key: constructor");if(i==="__proto__")throw new Error("illegal key: __proto__");let s=e[o+1],a=n[i];Gu(s)&&Bo(a)&&(a=n[i]=isNaN(+s)?{}:[]),pn(s)?pn(r)?delete n[i]:n[i]=r:n=a}),t}function Io(t,e){let r={},n=Object(t);return F(e,function(i){i in n&&(r[i]=t[i])}),r}function _n(){}_n.prototype.get=function(t){return this.$model.properties.get(this,t)};_n.prototype.set=function(t,e){this.$model.properties.set(this,t,e)};function Fo(t,e){this.model=t,this.properties=e}Fo.prototype.createType=function(t){var e=this.model,r=this.properties,n=Object.create(_n.prototype);F(t.properties,function(s){!s.isMany&&s.default!==void 0&&(n[s.name]=s.default)}),r.defineModel(n,e),r.defineDescriptor(n,t);var i=t.ns.name;function o(s){r.define(this,"$type",{value:i,enumerable:!0}),r.define(this,"$attrs",{value:{}}),r.define(this,"$parent",{writable:!0}),F(s,Gt(function(a,l){this.set(l,a)},this))}return o.prototype=n,o.hasType=n.$instanceOf=this.model.hasType,r.defineModel(o,e),r.defineDescriptor(o,t),o};var Wu={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},jo={String:function(t){return t},Boolean:function(t){return t==="true"},Integer:function(t){return parseInt(t,10)},Real:function(t){return parseFloat(t)}};function fr(t,e){var r=jo[t];return r?r(e):e}function gn(t){return!!Wu[t]}function vn(t){return!!jo[t]}function J(t,e){var r=t.split(/:/),n,i;if(r.length===1)n=t,i=e;else if(r.length===2)n=r[1],i=r[0];else throw new Error("expected <prefix:localName> or <localName>, got "+t);return t=(i?i+":":"")+n,{name:t,prefix:i,localName:n}}function pt(t){this.ns=t,this.name=t.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}pt.prototype.build=function(){return Io(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])};pt.prototype.addProperty=function(t,e,r){typeof e=="boolean"&&(r=e,e=void 0),this.addNamedProperty(t,r!==!1);var n=this.properties;e!==void 0?n.splice(e,0,t):n.push(t)};pt.prototype.replaceProperty=function(t,e,r){var n=t.ns,i=this.properties,o=this.propertiesByName,s=t.name!==e.name;if(t.isId){if(!e.isId)throw new Error("property <"+e.ns.name+"> must be id property to refine <"+t.ns.name+">");this.setIdProperty(e,!1)}if(t.isBody){if(!e.isBody)throw new Error("property <"+e.ns.name+"> must be body property to refine <"+t.ns.name+">");this.setBodyProperty(e,!1)}var a=i.indexOf(t);if(a===-1)throw new Error("property <"+n.name+"> not found in property list");i.splice(a,1),this.addProperty(e,r?void 0:a,s),o[n.name]=o[n.localName]=e};pt.prototype.redefineProperty=function(t,e,r){var n=t.ns.prefix,i=e.split("#"),o=J(i[0],n),s=J(i[1],o.prefix).name,a=this.propertiesByName[s];if(a)this.replaceProperty(a,t,r);else throw new Error("refined property <"+s+"> not found");delete t.redefines};pt.prototype.addNamedProperty=function(t,e){var r=t.ns,n=this.propertiesByName;e&&(this.assertNotDefined(t,r.name),this.assertNotDefined(t,r.localName)),n[r.name]=n[r.localName]=t};pt.prototype.removeNamedProperty=function(t){var e=t.ns,r=this.propertiesByName;delete r[e.name],delete r[e.localName]};pt.prototype.setBodyProperty=function(t,e){if(e&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+t.ns.name+">)");this.bodyProperty=t};pt.prototype.setIdProperty=function(t,e){if(e&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+t.ns.name+">)");this.idProperty=t};pt.prototype.assertNotTrait=function(t){if((t.extends||[]).length)throw new Error(`cannot create <${t.name}> extending <${t.extends}>`)};pt.prototype.assertNotDefined=function(t,e){var r=t.name,n=this.propertiesByName[r];if(n)throw new Error("property <"+r+"> already defined; override of <"+n.definedBy.ns.name+"#"+n.ns.name+"> by <"+t.definedBy.ns.name+"#"+t.ns.name+"> not allowed without redefines")};pt.prototype.hasProperty=function(t){return this.propertiesByName[t]};pt.prototype.addTrait=function(t,e){e&&this.assertNotTrait(t);var r=this.allTypesByName,n=this.allTypes,i=t.name;i in r||(F(t.properties,Gt(function(o){o=Z({},o,{name:o.ns.localName,inherited:e}),Object.defineProperty(o,"definedBy",{value:t});var s=o.replaces,a=o.redefines;s||a?this.redefineProperty(o,s||a,s):(o.isBody&&this.setBodyProperty(o),o.isId&&this.setIdProperty(o),this.addProperty(o))},this)),n.push(t),r[i]=t)};function zt(t,e){this.packageMap={},this.typeMap={},this.packages=[],this.properties=e,F(t,Gt(this.registerPackage,this))}zt.prototype.getPackage=function(t){return this.packageMap[t]};zt.prototype.getPackages=function(){return this.packages};zt.prototype.registerPackage=function(t){t=Z({},t);var e=this.packageMap;Do(e,t,"prefix"),Do(e,t,"uri"),F(t.types,Gt(function(r){this.registerType(r,t)},this)),e[t.uri]=e[t.prefix]=t,this.packages.push(t)};zt.prototype.registerType=function(t,e){t=Z({},t,{superClass:(t.superClass||[]).slice(),extends:(t.extends||[]).slice(),properties:(t.properties||[]).slice(),meta:Z(t.meta||{})});var r=J(t.name,e.prefix),n=r.name,i={};F(t.properties,Gt(function(o){var s=J(o.name,r.prefix),a=s.name;gn(o.type)||(o.type=J(o.type,s.prefix).name),Z(o,{ns:s,name:a}),i[a]=o},this)),Z(t,{ns:r,name:n,propertiesByName:i}),F(t.extends,Gt(function(o){var s=J(o,r.prefix),a=this.typeMap[s.name];a.traits=a.traits||[],a.traits.push(n)},this)),this.definePackage(t,e),this.typeMap[n]=t};zt.prototype.mapTypes=function(t,e,r){var n=gn(t.name)?{name:t.name}:this.typeMap[t.name],i=this;function o(l,u){var c=J(l,gn(l)?"":t.prefix);i.mapTypes(c,e,u)}function s(l){return o(l,!0)}function a(l){return o(l,!1)}if(!n)throw new Error("unknown type <"+t.name+">");F(n.superClass,r?s:a),e(n,!r),F(n.traits,s)};zt.prototype.getEffectiveDescriptor=function(t){var e=J(t),r=new pt(e);this.mapTypes(e,function(i,o){r.addTrait(i,o)});var n=r.build();return this.definePackage(n,n.allTypes[n.allTypes.length-1].$pkg),n};zt.prototype.definePackage=function(t,e){this.properties.define(t,"$pkg",{value:e})};function Do(t,e,r){var n=e[r];if(n in t)throw new Error("package with "+r+" <"+n+"> already defined")}function Ut(t){this.model=t}Ut.prototype.set=function(t,e,r){if(!$t(e)||!e.length)throw new TypeError("property name must be a non-empty string");var n=this.getProperty(t,e),i=n&&n.name;Yu(r)?n?delete t[i]:delete t.$attrs[yn(e)]:n?i in t?t[i]=r:Ho(t,n,r):t.$attrs[yn(e)]=r};Ut.prototype.get=function(t,e){var r=this.getProperty(t,e);if(!r)return t.$attrs[yn(e)];var n=r.name;return!t[n]&&r.isMany&&Ho(t,r,[]),t[n]};Ut.prototype.define=function(t,e,r){if(!r.writable){var n=r.value;r=Z({},r,{get:function(){return n}}),delete r.value}Object.defineProperty(t,e,r)};Ut.prototype.defineDescriptor=function(t,e){this.define(t,"$descriptor",{value:e})};Ut.prototype.defineModel=function(t,e){this.define(t,"$model",{value:e})};Ut.prototype.getProperty=function(t,e){var r=this.model,n=r.getPropertyDescriptor(t,e);if(n)return n;if(e.includes(":"))return null;let i=r.config.strict;if(typeof i<"u"){let o=new TypeError(`unknown property <${e}> on <${t.$type}>`);if(i)throw o;typeof console<"u"&&console.warn(o)}return null};function Yu(t){return typeof t>"u"}function Ho(t,e,r){Object.defineProperty(t,e.name,{enumerable:!e.isReference,writable:!0,value:r,configurable:!0})}function yn(t){return t.replace(/^:/,"")}function dt(t,e={}){this.properties=new Ut(this),this.factory=new Fo(this,this.properties),this.registry=new zt(t,this.properties),this.typeCache={},this.config=e}dt.prototype.create=function(t,e){var r=this.getType(t);if(!r)throw new Error("unknown type <"+t+">");return new r(e)};dt.prototype.getType=function(t){var e=this.typeCache,r=$t(t)?t:t.ns.name,n=e[r];return n||(t=this.registry.getEffectiveDescriptor(r),n=e[r]=this.factory.createType(t)),n};dt.prototype.createAny=function(t,e,r){var n=J(t),i={$type:t,$instanceOf:function(s){return s===this.$type},get:function(s){return this[s]},set:function(s,a){Oo(this,[s],a)}},o={name:t,isGeneric:!0,ns:{prefix:n.prefix,localName:n.localName,uri:e}};return this.properties.defineDescriptor(i,o),this.properties.defineModel(i,this),this.properties.define(i,"get",{enumerable:!1,writable:!0}),this.properties.define(i,"set",{enumerable:!1,writable:!0}),this.properties.define(i,"$parent",{enumerable:!1,writable:!0}),this.properties.define(i,"$instanceOf",{enumerable:!1,writable:!0}),F(r,function(s,a){$o(s)&&s.value!==void 0?i[s.name]=s.value:i[a]=s}),i};dt.prototype.getPackage=function(t){return this.registry.getPackage(t)};dt.prototype.getPackages=function(){return this.registry.getPackages()};dt.prototype.getElementDescriptor=function(t){return t.$descriptor};dt.prototype.hasType=function(t,e){e===void 0&&(e=t,t=this);var r=t.$model.getElementDescriptor(t);return e in r.allTypesByName};dt.prototype.getPropertyDescriptor=function(t,e){return this.getElementDescriptor(t).propertiesByName[e]};dt.prototype.getTypeDescriptor=function(t){return this.registry.typeMap[t]};var qo=String.fromCharCode,Ku=Object.prototype.hasOwnProperty,Qu=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,Se={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(Se).forEach(function(t){Se[t.toUpperCase()]=Se[t]});function Ju(t,e,r,n){return n?Ku.call(Se,n)?Se[n]:"&"+n+";":qo(e||parseInt(r,16))}function Xt(t){return t.length>3&&t.indexOf("&")!==-1?t.replace(Qu,Ju):t}var Vo="non-whitespace outside of root node";function ae(t){return new Error(t)}function Go(t){return"missing namespace for prefix <"+t+">"}function pr(t){return{get:t,enumerable:!0}}function tc(t){var e={},r;for(r in t)e[r]=t[r];return e}function xn(t){return t+"$uri"}function ec(t){var e={},r,n;for(r in t)n=t[r],e[n]=n,e[xn(n)]=r;return e}function Uo(){return{line:0,column:0}}function rc(t){throw t}function wn(t){if(!this)return new wn(t);var e=t&&t.proxy,r,n,i,o,s=rc,a,l,u,c,f=Uo,p=!1,m=!1,T=null,A=!1,O;function N(d){d instanceof Error||(d=ae(d)),T=d,s(d,f)}function _(d){a&&(d instanceof Error||(d=ae(d)),a(d,f))}this.on=function(d,y){if(typeof y!="function")throw ae("required args <name, cb>");switch(d){case"openTag":n=y;break;case"text":r=y;break;case"closeTag":i=y;break;case"error":s=y;break;case"warn":a=y;break;case"cdata":o=y;break;case"attention":c=y;break;case"question":u=y;break;case"comment":l=y;break;default:throw ae("unsupported event: "+d)}return this},this.ns=function(d){if(typeof d>"u"&&(d={}),typeof d!="object")throw ae("required args <nsMap={}>");var y={},v;for(v in d)y[v]=d[v];return m=!0,O=y,this},this.parse=function(d){if(typeof d!="string")throw ae("required args <xml=string>");return T=null,M(d),f=Uo,A=!1,T},this.stop=function(){A=!0};function M(d){var y=m?[]:null,v=m?ec(O):null,E,P=[],B=0,R=!1,C=!1,x=0,b=0,h,S,g,w,L,$,k,D,q,at="",X=0,Y;function ct(){if(Y!==null)return Y;var K,mt,xt,Ht=m&&v.xmlns,Mt=m&&p?[]:null,V=X,tt=at,qt=tt.length,Pi,Bt,St,wt,j,se={},Li={},gt,z,I;t:for(;V<qt;V++)if(gt=!1,z=tt.charCodeAt(V),!(z===32||z<14&&z>8)){for((z<65||z>122||z>90&&z<97)&&z!==95&&z!==58&&(_("illegal first char attribute name"),gt=!0),I=V+1;I<qt;I++)if(z=tt.charCodeAt(I),!(z>96&&z<123||z>64&&z<91||z>47&&z<59||z===46||z===45||z===95)){if(z===32||z<14&&z>8){_("missing attribute value"),V=I;continue t}if(z===61)break;_("illegal attribute name char"),gt=!0}if(j=tt.substring(V,I),j==="xmlns:xmlns"&&(_("illegal declaration of xmlns"),gt=!0),z=tt.charCodeAt(I+1),z===34)I=tt.indexOf('"',V=I+2),I===-1&&(I=tt.indexOf("'",V),I!==-1&&(_("attribute value quote missmatch"),gt=!0));else if(z===39)I=tt.indexOf("'",V=I+2),I===-1&&(I=tt.indexOf('"',V),I!==-1&&(_("attribute value quote missmatch"),gt=!0));else for(_("missing attribute value quotes"),gt=!0,I=I+1;I<qt&&(z=tt.charCodeAt(I+1),!(z===32||z<14&&z>8));I++);for(I===-1&&(_("missing closing quotes"),I=qt,gt=!0),gt||(St=tt.substring(V,I)),V=I;I+1<qt&&(z=tt.charCodeAt(I+1),!(z===32||z<14&&z>8));I++)V===I&&(_("illegal character after attribute end"),gt=!0);if(V=I+1,gt)continue t;if(j in Li){_("attribute <"+j+"> already defined");continue}if(Li[j]=!0,!m){se[j]=St;continue}if(p){if(Bt=j==="xmlns"?"xmlns":j.charCodeAt(0)===120&&j.substr(0,6)==="xmlns:"?j.substr(6):null,Bt!==null){if(K=Xt(St),mt=xn(Bt),wt=O[K],!wt){if(Bt==="xmlns"||mt in v&&v[mt]!==K)do wt="ns"+B++;while(typeof v[wt]<"u");else wt=Bt;O[K]=wt}v[Bt]!==wt&&(Pi||(v=tc(v),Pi=!0),v[Bt]=wt,Bt==="xmlns"&&(v[xn(wt)]=K,Ht=wt),v[mt]=K),se[j]=St;continue}Mt.push(j,St);continue}if(z=j.indexOf(":"),z===-1){se[j]=St;continue}if(!(xt=v[j.substring(0,z)])){_(Go(j.substring(0,z)));continue}j=Ht===xt?j.substr(z+1):xt+j.substr(z),se[j]=St}if(p)for(V=0,qt=Mt.length;V<qt;V++){if(j=Mt[V++],St=Mt[V],z=j.indexOf(":"),z!==-1){if(!(xt=v[j.substring(0,z)])){_(Go(j.substring(0,z)));continue}j=Ht===xt?j.substr(z+1):xt+j.substr(z)}se[j]=St}return Y=se}function ft(){for(var K=/(\r\n|\r|\n)/g,mt=0,xt=0,Ht=0,Mt=b,V,tt;x>=Ht&&(V=K.exec(d),!(!V||(Mt=V[0].length+V.index,Mt>x)));)mt+=1,Ht=Mt;return x==-1?(xt=Mt,tt=d.substring(b)):b===0?tt=d.substring(b,x):(xt=x-Ht,tt=b==-1?d.substring(x):d.substring(x,b+1)),{data:tt,line:mt,column:xt}}for(f=ft,e&&(q=Object.create({},{name:pr(function(){return k}),originalName:pr(function(){return D}),attrs:pr(ct),ns:pr(function(){return v})}));b!==-1;){if(d.charCodeAt(b)===60?x=b:x=d.indexOf("<",b),x===-1){if(P.length)return N("unexpected end of file");if(b===0)return N("missing start tag");b<d.length&&d.substring(b).trim()&&_(Vo);return}if(b!==x){if(P.length){if(r&&(r(d.substring(b,x),Xt,f),A))return}else if(d.substring(b,x).trim()&&(_(Vo),A))return}if(w=d.charCodeAt(x+1),w===33){if(g=d.charCodeAt(x+2),g===91&&d.substr(x+3,6)==="CDATA["){if(b=d.indexOf("]]>",x),b===-1)return N("unclosed cdata");if(o&&(o(d.substring(x+9,b),f),A))return;b+=3;continue}if(g===45&&d.charCodeAt(x+3)===45){if(b=d.indexOf("-->",x),b===-1)return N("unclosed comment");if(l&&(l(d.substring(x+4,b),Xt,f),A))return;b+=3;continue}}if(w===63){if(b=d.indexOf("?>",x),b===-1)return N("unclosed question");if(u&&(u(d.substring(x,b+2),f),A))return;b+=2;continue}for(h=x+1;;h++){if(L=d.charCodeAt(h),isNaN(L))return b=-1,N("unclosed tag");if(L===34)g=d.indexOf('"',h+1),h=g!==-1?g:h;else if(L===39)g=d.indexOf("'",h+1),h=g!==-1?g:h;else if(L===62){b=h;break}}if(w===33){if(c&&(c(d.substring(x,b+1),Xt,f),A))return;b+=1;continue}if(Y={},w===47){if(R=!1,C=!0,!P.length)return N("missing open tag");if(h=k=P.pop(),g=x+2+h.length,d.substring(x+2,g)!==h)return N("closing tag mismatch");for(;g<b;g++)if(w=d.charCodeAt(g),!(w===32||w>8&&w<14))return N("close tag")}else{if(d.charCodeAt(b-1)===47?(h=k=d.substring(x+1,b-1),R=!0,C=!0):(h=k=d.substring(x+1,b),R=!0,C=!1),!(w>96&&w<123||w>64&&w<91||w===95||w===58))return N("illegal first char nodeName");for(g=1,S=h.length;g<S;g++)if(w=h.charCodeAt(g),!(w>96&&w<123||w>64&&w<91||w>47&&w<59||w===45||w===95||w==46)){if(w===32||w<14&&w>8){k=h.substring(0,g),Y=null;break}return N("invalid nodeName")}C||P.push(k)}if(m){if(E=v,R&&(C||y.push(E),Y===null&&(p=h.indexOf("xmlns",g)!==-1)&&(X=g,at=h,ct(),p=!1)),D=k,w=k.indexOf(":"),w!==-1){if($=v[k.substring(0,w)],!$)return N("missing namespace on <"+D+">");k=k.substr(w+1)}else $=v.xmlns;$&&(k=$+":"+k)}if(R&&(X=g,at=h,n&&(e?n(q,Xt,C,f):n(k,ct,Xt,C,f),A)))return;if(C){if(i&&(i(e?q:k,Xt,R,f),A))return;m&&(R?v=E:v=y.pop())}b+=1}}}function Xo(t){return t.xml&&t.xml.tagAlias==="lowerCase"}var bn={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},Zo="property";function Wo(t){return t.xml&&t.xml.serialize}function nc(t){let e=Wo(t);return e!==Zo&&(e||null)}function ic(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Yo(t,e){return Xo(e)?t.prefix+":"+ic(t.localName):t.name}function oc(t,e){var r=t.name,n=t.localName,i=e&&e.xml&&e.xml.typePrefix;return i&&n.indexOf(i)===0?t.prefix+":"+n.slice(i.length):r}function sc(t,e,r){let n=J(t,e.xmlns),i=`${e[n.prefix]||n.prefix}:${n.localName}`,o=J(i);var s=r.getPackage(o.prefix);return oc(o,s)}function Ot(t){return new Error(t)}function Tt(t){return t.$descriptor}function ac(t){Z(this,t),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw Ot("expected element");var r=this.elementsById,n=Tt(e),i=n.idProperty,o;if(i&&(o=e.get(i.name),o)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(o))throw new Error("illegal ID <"+o+">");if(r[o])throw Ot("duplicate ID <"+o+">");r[o]=e}},this.addWarning=function(e){this.warnings.push(e)}}function ke(){}ke.prototype.handleEnd=function(){};ke.prototype.handleText=function(){};ke.prototype.handleNode=function(){};function En(){}En.prototype=Object.create(ke.prototype);En.prototype.handleNode=function(){return this};function ue(){}ue.prototype=Object.create(ke.prototype);ue.prototype.handleText=function(t){this.body=(this.body||"")+t};function Ae(t,e){this.property=t,this.context=e}Ae.prototype=Object.create(ue.prototype);Ae.prototype.handleNode=function(t){if(this.element)throw Ot("expected no sub nodes");return this.element=this.createReference(t),this};Ae.prototype.handleEnd=function(){this.element.id=this.body};Ae.prototype.createReference=function(t){return{property:this.property.ns.name,id:""}};function Nn(t,e){this.element=e,this.propertyDesc=t}Nn.prototype=Object.create(ue.prototype);Nn.prototype.handleEnd=function(){var t=this.body||"",e=this.element,r=this.propertyDesc;t=fr(r.type,t),r.isMany?e.get(r.name).push(t):e.set(r.name,t)};function dr(){}dr.prototype=Object.create(ue.prototype);dr.prototype.handleNode=function(t){var e=this,r=this.element;return r?e=this.handleChild(t):(r=this.element=this.createElement(t),this.context.addElement(r)),e};function it(t,e,r){this.model=t,this.type=t.getType(e),this.context=r}it.prototype=Object.create(dr.prototype);it.prototype.addReference=function(t){this.context.addReference(t)};it.prototype.handleText=function(t){var e=this.element,r=Tt(e),n=r.bodyProperty;if(!n)throw Ot("unexpected body text <"+t+">");ue.prototype.handleText.call(this,t)};it.prototype.handleEnd=function(){var t=this.body,e=this.element,r=Tt(e),n=r.bodyProperty;n&&t!==void 0&&(t=fr(n.type,t),e.set(n.name,t))};it.prototype.createElement=function(t){var e=t.attributes,r=this.type,n=Tt(r),i=this.context,o=new r({}),s=this.model,a;return F(e,function(l,u){var c=n.propertiesByName[u],f;c&&c.isReference?c.isMany?(f=l.split(" "),F(f,function(p){i.addReference({element:o,property:c.ns.name,id:p})})):i.addReference({element:o,property:c.ns.name,id:l}):(c?l=fr(c.type,l):u==="xmlns"?u=":"+u:(a=J(u,n.ns.prefix),s.getPackage(a.prefix)&&i.addWarning({message:"unknown attribute <"+u+">",element:o,property:u,value:l})),o.set(u,l))}),o};it.prototype.getPropertyForNode=function(t){var e=t.name,r=J(e),n=this.type,i=this.model,o=Tt(n),s=r.name,a=o.propertiesByName[s];if(a&&!a.isAttr){let u=nc(a);if(u){let c=t.attributes[u];if(c){let f=sc(c,t.ns,i),p=i.getType(f);return Z({},a,{effectiveType:Tt(p).name})}}return a}var l=i.getPackage(r.prefix);if(l){let u=Yo(r,l),c=i.getType(u);if(a=hn(o.properties,function(f){return!f.isVirtual&&!f.isReference&&!f.isAttribute&&c.hasType(f.type)}),a)return Z({},a,{effectiveType:Tt(c).name})}else if(a=hn(o.properties,function(u){return!u.isReference&&!u.isAttribute&&u.type==="Element"}),a)return a;throw Ot("unrecognized element <"+r.name+">")};it.prototype.toString=function(){return"ElementDescriptor["+Tt(this.type).name+"]"};it.prototype.valueHandler=function(t,e){return new Nn(t,e)};it.prototype.referenceHandler=function(t){return new Ae(t,this.context)};it.prototype.handler=function(t){return t==="Element"?new le(this.model,t,this.context):new it(this.model,t,this.context)};it.prototype.handleChild=function(t){var e,r,n,i;if(e=this.getPropertyForNode(t),n=this.element,r=e.effectiveType||e.type,vn(r))return this.valueHandler(e,n);e.isReference?i=this.referenceHandler(e).handleNode(t):i=this.handler(r).handleNode(t);var o=i.element;return o!==void 0&&(e.isMany?n.get(e.name).push(o):n.set(e.name,o),e.isReference?(Z(o,{element:n}),this.context.addReference(o)):o.$parent=n),i};function Mn(t,e,r){it.call(this,t,e,r)}Mn.prototype=Object.create(it.prototype);Mn.prototype.createElement=function(t){var e=t.name,r=J(e),n=this.model,i=this.type,o=n.getPackage(r.prefix),s=o&&Yo(r,o)||e;if(!i.hasType(s))throw Ot("unexpected element <"+t.originalName+">");return it.prototype.createElement.call(this,t)};function le(t,e,r){this.model=t,this.context=r}le.prototype=Object.create(dr.prototype);le.prototype.createElement=function(t){var e=t.name,r=J(e),n=r.prefix,i=t.ns[n+"$uri"],o=t.attributes;return this.model.createAny(e,i,o)};le.prototype.handleChild=function(t){var e=new le(this.model,"Element",this.context).handleNode(t),r=this.element,n=e.element,i;return n!==void 0&&(i=r.$children=r.$children||[],i.push(n),n.$parent=r),e};le.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function hr(t){t instanceof dt&&(t={model:t}),Z(this,{lax:!1},t)}hr.prototype.fromXML=function(t,e,r){var n=e.rootHandler;e instanceof it?(n=e,e={}):typeof e=="string"?(n=this.handler(e),e={}):typeof n=="string"&&(n=this.handler(n));var i=this.model,o=this.lax,s=new ac(Z({},e,{rootHandler:n})),a=new wn({proxy:!0}),l=lc();n.context=s,l.push(n);function u(y,v,E){var P=v(),B=P.line,R=P.column,C=P.data;C.charAt(0)==="<"&&C.indexOf(" ")!==-1&&(C=C.slice(0,C.indexOf(" "))+">");var x="unparsable content "+(C?C+" ":"")+`detected
2
+ line: `+B+`
3
+ column: `+R+`
4
+ nested error: `+y.message;if(E)return s.addWarning({message:x,error:y}),!0;throw Ot(x)}function c(y,v){return u(y,v,!0)}function f(){var y=s.elementsById,v=s.references,E,P;for(E=0;P=v[E];E++){var B=P.element,R=y[P.id],C=Tt(B).propertiesByName[P.property];if(R||s.addWarning({message:"unresolved reference <"+P.id+">",element:P.element,property:P.property,value:P.id}),C.isMany){var x=B.get(C.name),b=x.indexOf(P);b===-1&&(b=x.length),R?x[b]=R:x.splice(b,1)}else B.set(C.name,R)}}function p(){l.pop().handleEnd()}var m=/^<\?xml /i,T=/ encoding="([^"]+)"/i,A=/^utf-8$/i;function O(y){if(m.test(y)){var v=T.exec(y),E=v&&v[1];!E||A.test(E)||s.addWarning({message:"unsupported document encoding <"+E+">, falling back to UTF-8"})}}function N(y,v){var E=l.peek();try{l.push(E.handleNode(y))}catch(P){u(P,v,o)&&l.push(new En)}}function _(y,v){try{l.peek().handleText(y)}catch(E){c(E,v)}}function M(y,v){y.trim()&&_(y,v)}var d=i.getPackages().reduce(function(y,v){return y[v.uri]=v.prefix,y},Object.entries(bn).reduce(function(y,[v,E]){return y[E]=v,y},i.config&&i.config.nsMap||{}));return a.ns(d).on("openTag",function(y,v,E,P){var B=y.attrs||{},R=Object.keys(B).reduce(function(x,b){var h=v(B[b]);return x[b]=h,x},{}),C={name:y.name,originalName:y.originalName,attributes:R,ns:y.ns};N(C,P)}).on("question",O).on("closeTag",p).on("cdata",_).on("text",function(y,v,E){M(v(y),E)}).on("error",u).on("warn",c),new Promise(function(y,v){var E;try{a.parse(t),f()}catch(x){E=x}var P=n.element;!E&&!P&&(E=Ot("failed to parse document as <"+n.type.$descriptor.name+">"));var B=s.warnings,R=s.references,C=s.elementsById;return E?(E.warnings=B,v(E)):y({rootElement:P,elementsById:C,references:R,warnings:B})})};hr.prototype.handler=function(t){return new Mn(this.model,t)};function lc(){var t=[];return Object.defineProperty(t,"peek",{value:function(){return this[this.length-1]}}),t}var uc=`<?xml version="1.0" encoding="UTF-8"?>
5
+ `,cc=/<|>|'|"|&|\n\r|\n/g,Ko=/<|>|&/g;function bt(t){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=t,this.defaultPrefixMap=t&&t.defaultPrefixMap||{}}bt.prototype.mapDefaultPrefixes=function(t){this.defaultPrefixMap=t};bt.prototype.defaultUriByPrefix=function(t){return this.defaultPrefixMap[t]};bt.prototype.byUri=function(t){return this.uriMap[t]||this.parent&&this.parent.byUri(t)};bt.prototype.add=function(t,e){this.uriMap[t.uri]=t,e?this.wellknown.push(t):this.custom.push(t),this.mapPrefix(t.prefix,t.uri)};bt.prototype.uriByPrefix=function(t){return this.prefixMap[t||"xmlns"]||this.parent&&this.parent.uriByPrefix(t)};bt.prototype.mapPrefix=function(t,e){this.prefixMap[t||"xmlns"]=e};bt.prototype.getNSKey=function(t){return t.prefix!==void 0?t.uri+"|"+t.prefix:t.uri};bt.prototype.logUsed=function(t){var e=t.uri,r=this.getNSKey(t);this.used[r]=this.byUri(e),this.parent&&this.parent.logUsed(t)};bt.prototype.getUsed=function(t){var e=[].concat(this.wellknown,this.custom);return e.filter(r=>{var n=this.getNSKey(r);return this.used[n]})};function fc(t){return t.charAt(0).toLowerCase()+t.slice(1)}function pc(t,e){return Xo(e)?fc(t):t}function Qo(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}function Jo(t){return $t(t)?t:(t.prefix?t.prefix+":":"")+t.localName}function dc(t){return t.getUsed().filter(function(e){return e.prefix!=="xml"}).map(function(e){var r="xmlns"+(e.prefix?":"+e.prefix:"");return{name:r,value:e.uri}})}function hc(t,e){return e.isGeneric?Z({localName:e.ns.localName},t):Z({localName:pc(e.ns.localName,e.$pkg)},t)}function mc(t,e){return Z({localName:e.ns.localName},t)}function gc(t){var e=t.$descriptor;return cr(e.properties,function(r){var n=r.name;if(r.isVirtual||!dn(t,n))return!1;var i=t[n];return i===r.default||i===null?!1:r.isMany?i.length:!0})}var yc={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},_c={"<":"lt",">":"gt","&":"amp"};function ts(t,e,r){return t=$t(t)?t:""+t,t.replace(e,function(n){return"&"+r[n]+";"})}function vc(t){return ts(t,cc,yc)}function xc(t){return ts(t,Ko,_c)}function wc(t){return cr(t,function(e){return e.isAttr})}function bc(t){return cr(t,function(e){return!e.isAttr})}function Sn(t){this.tagName=t}Sn.prototype.build=function(t){return this.element=t,this};Sn.prototype.serializeTo=function(t){t.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function Zt(){}Zt.prototype.serializeValue=Zt.prototype.serializeTo=function(t){t.append(this.escape?xc(this.value):this.value)};Zt.prototype.build=function(t,e){return this.value=e,t.type==="String"&&e.search(Ko)!==-1&&(this.escape=!0),this};function kn(t){this.tagName=t}Qo(kn,Zt);kn.prototype.serializeTo=function(t){t.appendIndent().append("<"+this.tagName+">"),this.serializeValue(t),t.append("</"+this.tagName+">").appendNewLine()};function H(t,e){this.body=[],this.attrs=[],this.parent=t,this.propertyDescriptor=e}H.prototype.build=function(t){this.element=t;var e=t.$descriptor,r=this.propertyDescriptor,n,i,o=e.isGeneric;return o?n=this.parseGenericNsAttributes(t):n=this.parseNsAttributes(t),r?this.ns=this.nsPropertyTagName(r):this.ns=this.nsTagName(e),this.tagName=this.addTagName(this.ns),o?this.parseGenericContainments(t):(i=gc(t),this.parseAttributes(wc(i)),this.parseContainments(bc(i))),this.parseGenericAttributes(t,n),this};H.prototype.nsTagName=function(t){var e=this.logNamespaceUsed(t.ns);return hc(e,t)};H.prototype.nsPropertyTagName=function(t){var e=this.logNamespaceUsed(t.ns);return mc(e,t)};H.prototype.isLocalNs=function(t){return t.uri===this.ns.uri};H.prototype.nsAttributeName=function(t){var e;if($t(t)?e=J(t):e=t.ns,t.inherited)return{localName:e.localName};var r=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(r),this.isLocalNs(r)?{localName:e.localName}:Z({localName:e.localName},r)};H.prototype.parseGenericNsAttributes=function(t){return Object.entries(t).filter(([e,r])=>!e.startsWith("$")&&this.parseNsAttribute(t,e,r)).map(([e,r])=>({name:e,value:r}))};H.prototype.parseGenericContainments=function(t){var e=t.$body;e&&this.body.push(new Zt().build({type:"String"},e));var r=t.$children;r&&F(r,n=>{this.body.push(new H(this).build(n))})};H.prototype.parseNsAttribute=function(t,e,r){var n=t.$model,i=J(e),o;if(i.prefix==="xmlns"&&(o={prefix:i.localName,uri:r}),!i.prefix&&i.localName==="xmlns"&&(o={uri:r}),!o)return{name:e,value:r};if(n&&n.getPackage(r))this.logNamespace(o,!0,!0);else{var s=this.logNamespaceUsed(o,!0);this.getNamespaces().logUsed(s)}};H.prototype.parseNsAttributes=function(t){var e=this,r=t.$attrs,n=[];return F(r,function(i,o){var s=e.parseNsAttribute(t,o,i);s&&n.push(s)}),n};H.prototype.parseGenericAttributes=function(t,e){var r=this;F(e,function(n){try{r.addAttribute(r.nsAttributeName(n.name),n.value)}catch(i){typeof console<"u"&&console.warn(`missing namespace information for <${n.name}=${n.value}> on`,t,i)}})};H.prototype.parseContainments=function(t){var e=this,r=this.body,n=this.element;F(t,function(i){var o=n.get(i.name),s=i.isReference,a=i.isMany;if(a||(o=[o]),i.isBody)r.push(new Zt().build(i,o[0]));else if(vn(i.type))F(o,function(u){r.push(new kn(e.addTagName(e.nsPropertyTagName(i))).build(i,u))});else if(s)F(o,function(u){r.push(new Sn(e.addTagName(e.nsPropertyTagName(i))).build(u))});else{var l=Wo(i);F(o,function(u){var c;l?l===Zo?c=new H(e,i):c=new mr(e,i,l):c=new H(e),r.push(c.build(u))})}})};H.prototype.getNamespaces=function(t){var e=this.namespaces,r=this.parent,n;return e||(n=r&&r.getNamespaces(),t||!n?this.namespaces=e=new bt(n):e=n),e};H.prototype.logNamespace=function(t,e,r){var n=this.getNamespaces(r),i=t.uri,o=t.prefix,s=n.byUri(i);return(!s||r)&&n.add(t,e),n.mapPrefix(o,i),t};H.prototype.logNamespaceUsed=function(t,e){var r=this.getNamespaces(e),n=t.prefix,i=t.uri,o,s,a;if(!n&&!i)return{localName:t.localName};if(a=r.defaultUriByPrefix(n),i=i||a||r.uriByPrefix(n),!i)throw new Error("no namespace uri given for prefix <"+n+">");if(t=r.byUri(i),!t&&!n&&(t=this.logNamespace({uri:i},a===i,!0)),!t){for(o=n,s=1;r.uriByPrefix(o);)o=n+"_"+s++;t=this.logNamespace({prefix:o,uri:i},a===i)}return n&&r.mapPrefix(n,i),t};H.prototype.parseAttributes=function(t){var e=this,r=this.element;F(t,function(n){var i=r.get(n.name);if(n.isReference)if(!n.isMany)i=i.id;else{var o=[];F(i,function(s){o.push(s.id)}),i=o.join(" ")}e.addAttribute(e.nsAttributeName(n),i)})};H.prototype.addTagName=function(t){var e=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(e),Jo(t)};H.prototype.addAttribute=function(t,e){var r=this.attrs;$t(e)&&(e=vc(e));var n=zo(r,function(o){return o.name.localName===t.localName&&o.name.uri===t.uri&&o.name.prefix===t.prefix}),i={name:t,value:e};n!==-1?r.splice(n,1,i):r.push(i)};H.prototype.serializeAttributes=function(t){var e=this.attrs,r=this.namespaces;r&&(e=dc(r).concat(e)),F(e,function(n){t.append(" ").append(Jo(n.name)).append('="').append(n.value).append('"')})};H.prototype.serializeTo=function(t){var e=this.body[0],r=e&&e.constructor!==Zt;t.appendIndent().append("<"+this.tagName),this.serializeAttributes(t),t.append(e?">":" />"),e&&(r&&t.appendNewLine().indent(),F(this.body,function(n){n.serializeTo(t)}),r&&t.unindent().appendIndent(),t.append("</"+this.tagName+">")),t.appendNewLine()};function mr(t,e,r){H.call(this,t,e),this.serialization=r}Qo(mr,H);mr.prototype.parseNsAttributes=function(t){var e=H.prototype.parseNsAttributes.call(this,t).filter(s=>s.name!==this.serialization),r=t.$descriptor;if(r.name===this.propertyDescriptor.type)return e;var n=this.typeNs=this.nsTagName(r);this.getNamespaces().logUsed(this.typeNs);var i=t.$model.getPackage(n.uri),o=i.xml&&i.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(n.prefix?n.prefix+":":"")+o+r.ns.localName),e};mr.prototype.isLocalNs=function(t){return t.uri===(this.typeNs||this.ns).uri};function Ec(){this.value="",this.write=function(t){this.value+=t}}function Nc(t,e){var r=[""];this.append=function(n){return t.write(n),this},this.appendNewLine=function(){return e&&t.write(`
6
+ `),this},this.appendIndent=function(){return e&&t.write(r.join(" ")),this},this.indent=function(){return r.push(""),this},this.unindent=function(){return r.pop(),this}}function es(t){t=Z({format:!1,preamble:!0},t||{});function e(r,n){var i=n||new Ec,o=new Nc(i,t.format);t.preamble&&o.append(uc);var s=new H,a=r.$model;if(s.getNamespaces().mapDefaultPrefixes(Mc(a)),s.build(r).serializeTo(o),!n)return i.value}return{toXML:e}}function Mc(t){let e=t.config&&t.config.nsMap||{},r={};for(let n in bn)r[n]=bn[n];for(let n in e){let i=e[n];r[i]=n}for(let n of t.getPackages())r[n.prefix]=n.uri;return r}var Sc={name:"Process Flow Diagram Definition",uri:"http://pfdn",associations:[],types:[{name:"Statusable",isAbstract:!0,properties:[{name:"status",type:"Real",isAttr:!0,default:0}]},{name:"Base",isAbstract:!0,superClass:["Statusable"],properties:[{name:"id",type:"String",isAttr:!0,isId:!0},{name:"name",type:"String",isAttr:!0}]},{name:"Property",superClass:["Statusable"],properties:[{name:"name",type:"String",isAttr:!0},{name:"type",type:"String",isAttr:!0,default:"string"},{name:"value",type:"String",isAttr:!0,default:""}]},{name:"PropertiesSet",superClass:["Statusable"],properties:[{name:"id",type:"String",isAttr:!0,isId:!0},{name:"property",type:"Property",isMany:!0,xml:{serialize:"xsi:type"}}]},{name:"Coordinates",properties:[{name:"x",type:"Real",isAttr:!0,default:0},{name:"y",type:"Real",isAttr:!0,default:0}]},{name:"Zoom",superClass:["Statusable"],properties:[{name:"offset",type:"Coordinates",default:{x:0,y:0,scale:2},xml:{serialize:"xsi:type"}},{name:"scale",type:"Real",default:1}]},{name:"Grid",properties:[{name:"show",type:"Boolean",isAttr:!0,default:!0},{name:"lineColor",type:"String",isAttr:!0,default:"#dddddd"},{name:"size",type:"Real",isAttr:!0,default:25},{name:"lineWidth",type:"Real",isAttr:!0,default:1}]},{name:"Settings",superClass:["Base"],properties:[{name:"author",type:"String",default:"No Author",isAttr:!0},{name:"backgroundColor",type:"String",default:"#ffffff",isAttr:!0},{name:"zoom",type:"Zoom",xml:{serialize:"xsi:type"}},{name:"grid",type:"Grid",xml:{serialize:"xsi:type"}}]},{name:"Label",superClass:["Base"],properties:[{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"isReadOnly",type:"Boolean",isAttr:!0,default:!1},{name:"text",type:"String"},{name:"color",type:"String",isAttr:!0,default:"#303030"},{name:"fontSize",type:"Real",isAttr:!0,default:13}]},{name:"Node",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"type",type:"String",isAttr:!0,default:"default"},{name:"tag",isAttr:!0,type:"String"},{name:"propertiesSet",type:"PropertiesSet",isAttr:!0,isReference:!0},{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"size",type:"Real",isAttr:!0,default:25}]},{name:"Border",properties:[{name:"lineWidth",type:"Real",isAttr:!0,default:1},{name:"lineColor",type:"String",isAttr:!0,default:"#dddddd"}]},{name:"Zone",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"position",type:"Coordinates",xml:{serialize:"xsi:type"}},{name:"width",type:"Real",isAttr:!0,default:25},{name:"height",type:"Real",isAttr:!0,default:25},{name:"fillColor",type:"String",isAttr:!0,default:"#dddddd"},{name:"opacity",type:"Real",isAttr:!0,default:.6},{name:"border",type:"Border",xml:{serialize:"xsi:type"}}]},{name:"Link",superClass:["Base"],properties:[{name:"label",type:"Label",isAttr:!0,isReference:!0},{name:"source",type:"String",isAttr:!0,isReference:!0},{name:"target",type:"String",isAttr:!0,isReference:!0},{name:"lineColor",type:"String",isAttr:!0,default:"#000000"},{name:"lineWidth",type:"Real",isAttr:!0,default:4},{name:"fillColor",type:"String",isAttr:!0,default:"#ffffff"},{name:"waypoint",type:"Coordinates",isMany:!0,xml:{serialize:"xsi:type"}},{name:"tag",isAttr:!0,type:"String"},{name:"propertiesSet",type:"PropertiesSet",isAttr:!0,isReference:!0}]},{name:"Diagram",superClass:["Base"],properties:[{name:"settings",type:"Settings",xml:{serialize:"xsi:type"}},{name:"node",type:"Node",isMany:!0,xml:{serialize:"xsi:type"}},{name:"link",type:"Link",isMany:!0,xml:{serialize:"xsi:type"}},{name:"label",type:"Label",isMany:!0,xml:{serialize:"xsi:type"}},{name:"zone",type:"Zone",isMany:!0,xml:{serialize:"xsi:type"}},{name:"propertiesSet",type:"PropertiesSet",isMany:!0,xml:{serialize:"xsi:type"}}]}],prefix:"pfdn",xml:{tagAlias:"lowerCase"}},kc=class extends dt{async fromXML(t,e="pfdn:Diagram",r={}){return new hr({model:this,lax:!0,...r}).fromXML(t,e)}toXML(t,e={}){return new es(e).toXML(t)}},Ac={pfdn:Sc};function An(t={},e){return new kc({...Ac,...t},e)}var Cc={value:()=>{}};function ns(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new gr(r)}function gr(t){this._=t}function Tc(t,e){return t.trim().split(/^|\s+/).map(function(r){var n="",i=r.indexOf(".");if(i>=0&&(n=r.slice(i+1),r=r.slice(0,i)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}gr.prototype=ns.prototype={constructor:gr,on:function(t,e){var r=this._,n=Tc(t+"",r),i,o=-1,s=n.length;if(arguments.length<2){for(;++o<s;)if((i=(t=n[o]).type)&&(i=Pc(r[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<s;)if(i=(t=n[o]).type)r[i]=rs(r[i],t.name,e);else if(e==null)for(i in r)r[i]=rs(r[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new gr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var r=new Array(i),n=0,i,o;n<i;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],n=0,i=o.length;n<i;++n)o[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],i=0,o=n.length;i<o;++i)n[i].value.apply(e,r)}};function Pc(t,e){for(var r=0,n=t.length,i;r<n;++r)if((i=t[r]).name===e)return i.value}function rs(t,e,r){for(var n=0,i=t.length;n<i;++n)if(t[n].name===e){t[n]=Cc,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var Wt=ns;var is={passive:!1},Yt={capture:!0,passive:!1};function yr(t){t.stopImmediatePropagation()}function It(t){t.preventDefault(),t.stopImmediatePropagation()}function Ce(t){var e=t.document.documentElement,r=U(t).on("dragstart.drag",It,Yt);"onselectstart"in e?r.on("selectstart.drag",It,Yt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Te(t,e){var r=t.document.documentElement,n=U(t).on("dragstart.drag",null);e&&(n.on("click.drag",It,Yt),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in r?n.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}var Pe=t=>()=>t;function Le(t,{sourceEvent:e,subject:r,target:n,identifier:i,active:o,x:s,y:a,dx:l,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Le.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Lc(t){return!t.ctrlKey&&!t.button}function Bc(){return this.parentNode}function Rc(t,e){return e??{x:t.x,y:t.y}}function $c(){return navigator.maxTouchPoints||"ontouchstart"in this}function Be(){var t=Lc,e=Bc,r=Rc,n=$c,i={},o=Wt("start","drag","end"),s=0,a,l,u,c,f=0;function p(d){d.on("mousedown.drag",m).filter(n).on("touchstart.drag",O).on("touchmove.drag",N,is).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(d,y){if(!(c||!t.call(this,d,y))){var v=M(this,e.call(this,d,y),d,y,"mouse");v&&(U(d.view).on("mousemove.drag",T,Yt).on("mouseup.drag",A,Yt),Ce(d.view),yr(d),u=!1,a=d.clientX,l=d.clientY,v("start",d))}}function T(d){if(It(d),!u){var y=d.clientX-a,v=d.clientY-l;u=y*y+v*v>f}i.mouse("drag",d)}function A(d){U(d.view).on("mousemove.drag mouseup.drag",null),Te(d.view,u),It(d),i.mouse("end",d)}function O(d,y){if(t.call(this,d,y)){var v=d.changedTouches,E=e.call(this,d,y),P=v.length,B,R;for(B=0;B<P;++B)(R=M(this,E,d,y,v[B].identifier,v[B]))&&(yr(d),R("start",d,v[B]))}}function N(d){var y=d.changedTouches,v=y.length,E,P;for(E=0;E<v;++E)(P=i[y[E].identifier])&&(It(d),P("drag",d,y[E]))}function _(d){var y=d.changedTouches,v=y.length,E,P;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),E=0;E<v;++E)(P=i[y[E].identifier])&&(yr(d),P("end",d,y[E]))}function M(d,y,v,E,P,B){var R=o.copy(),C=Q(B||v,y),x,b,h;if((h=r.call(d,new Le("beforestart",{sourceEvent:v,target:p,identifier:P,active:s,x:C[0],y:C[1],dx:0,dy:0,dispatch:R}),E))!=null)return x=h.x-C[0]||0,b=h.y-C[1]||0,function S(g,w,L){var $=C,k;switch(g){case"start":i[P]=S,k=s++;break;case"end":delete i[P],--s;case"drag":C=Q(L||w,y),k=s;break}R.call(g,d,new Le(g,{sourceEvent:w,subject:h,target:p,identifier:P,active:k,x:C[0]+x,y:C[1]+b,dx:C[0]-$[0],dy:C[1]-$[1],dispatch:R}),E)}}return p.filter=function(d){return arguments.length?(t=typeof d=="function"?d:Pe(!!d),p):t},p.container=function(d){return arguments.length?(e=typeof d=="function"?d:Pe(d),p):e},p.subject=function(d){return arguments.length?(r=typeof d=="function"?d:Pe(d),p):r},p.touchable=function(d){return arguments.length?(n=typeof d=="function"?d:Pe(!!d),p):n},p.on=function(){var d=o.on.apply(o,arguments);return d===o?p:d},p.clickDistance=function(d){return arguments.length?(f=(d=+d)*d,p):Math.sqrt(f)},p}function _r(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function Cn(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function ze(){}var Re=.7,wr=1/Re,ce="\\s*([+-]?\\d+)\\s*",$e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zc=/^#([0-9a-f]{3,8})$/,Oc=new RegExp(`^rgb\\(${ce},${ce},${ce}\\)$`),Ic=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),Dc=new RegExp(`^rgba\\(${ce},${ce},${ce},${$e}\\)$`),Fc=new RegExp(`^rgba\\(${Et},${Et},${Et},${$e}\\)$`),jc=new RegExp(`^hsl\\(${$e},${Et},${Et}\\)$`),Hc=new RegExp(`^hsla\\(${$e},${Et},${Et},${$e}\\)$`),os={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};_r(ze,_t,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ss,formatHex:ss,formatHex8:qc,formatHsl:Vc,formatRgb:as,toString:as});function ss(){return this.rgb().formatHex()}function qc(){return this.rgb().formatHex8()}function Vc(){return ds(this).formatHsl()}function as(){return this.rgb().formatRgb()}function _t(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=zc.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?ls(e):r===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?vr(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?vr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Oc.exec(t))?new lt(e[1],e[2],e[3],1):(e=Ic.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Dc.exec(t))?vr(e[1],e[2],e[3],e[4]):(e=Fc.exec(t))?vr(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=jc.exec(t))?fs(e[1],e[2]/100,e[3]/100,1):(e=Hc.exec(t))?fs(e[1],e[2]/100,e[3]/100,e[4]):os.hasOwnProperty(t)?ls(os[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function ls(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function vr(t,e,r,n){return n<=0&&(t=e=r=NaN),new lt(t,e,r,n)}function Gc(t){return t instanceof ze||(t=_t(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function fe(t,e,r,n){return arguments.length===1?Gc(t):new lt(t,e,r,n??1)}function lt(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}_r(lt,fe,Cn(ze,{brighter(t){return t=t==null?wr:Math.pow(wr,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Re:Math.pow(Re,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(Qt(this.r),Qt(this.g),Qt(this.b),br(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:us,formatHex:us,formatHex8:Uc,formatRgb:cs,toString:cs}));function us(){return`#${Kt(this.r)}${Kt(this.g)}${Kt(this.b)}`}function Uc(){return`#${Kt(this.r)}${Kt(this.g)}${Kt(this.b)}${Kt((isNaN(this.opacity)?1:this.opacity)*255)}`}function cs(){let t=br(this.opacity);return`${t===1?"rgb(":"rgba("}${Qt(this.r)}, ${Qt(this.g)}, ${Qt(this.b)}${t===1?")":`, ${t})`}`}function br(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Qt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Kt(t){return t=Qt(t),(t<16?"0":"")+t.toString(16)}function fs(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new yt(t,e,r,n)}function ds(t){if(t instanceof yt)return new yt(t.h,t.s,t.l,t.opacity);if(t instanceof ze||(t=_t(t)),!t)return new yt;if(t instanceof yt)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),o=Math.max(e,r,n),s=NaN,a=o-i,l=(o+i)/2;return a?(e===o?s=(r-n)/a+(r<n)*6:r===o?s=(n-e)/a+2:s=(e-r)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new yt(s,a,l,t.opacity)}function hs(t,e,r,n){return arguments.length===1?ds(t):new yt(t,e,r,n??1)}function yt(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}_r(yt,hs,Cn(ze,{brighter(t){return t=t==null?wr:Math.pow(wr,t),new yt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Re:Math.pow(Re,t),new yt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new lt(Tn(t>=240?t-240:t+120,i,n),Tn(t,i,n),Tn(t<120?t+240:t-120,i,n),this.opacity)},clamp(){return new yt(ps(this.h),xr(this.s),xr(this.l),br(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=br(this.opacity);return`${t===1?"hsl(":"hsla("}${ps(this.h)}, ${xr(this.s)*100}%, ${xr(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ps(t){return t=(t||0)%360,t<0?t+360:t}function xr(t){return Math.max(0,Math.min(1,t||0))}function Tn(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}function Pn(t,e,r,n,i){var o=t*t,s=o*t;return((1-3*t+3*o-s)*e+(4-6*o+3*s)*r+(1+3*t+3*o-3*s)*n+s*i)/6}function ms(t){var e=t.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,e-1):Math.floor(r*e),i=t[n],o=t[n+1],s=n>0?t[n-1]:2*i-o,a=n<e-1?t[n+2]:2*o-i;return Pn((r-n/e)*e,s,i,o,a)}}function gs(t){var e=t.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*e),i=t[(n+e-1)%e],o=t[n%e],s=t[(n+1)%e],a=t[(n+2)%e];return Pn((r-n/e)*e,i,o,s,a)}}var Oe=t=>()=>t;function Xc(t,e){return function(r){return t+r*e}}function Zc(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function ys(t){return(t=+t)==1?Er:function(e,r){return r-e?Zc(e,r,t):Oe(isNaN(e)?r:e)}}function Er(t,e){var r=e-t;return r?Xc(t,r):Oe(isNaN(t)?e:t)}var Jt=(function t(e){var r=ys(e);function n(i,o){var s=r((i=fe(i)).r,(o=fe(o)).r),a=r(i.g,o.g),l=r(i.b,o.b),u=Er(i.opacity,o.opacity);return function(c){return i.r=s(c),i.g=a(c),i.b=l(c),i.opacity=u(c),i+""}}return n.gamma=t,n})(1);function _s(t){return function(e){var r=e.length,n=new Array(r),i=new Array(r),o=new Array(r),s,a;for(s=0;s<r;++s)a=fe(e[s]),n[s]=a.r||0,i[s]=a.g||0,o[s]=a.b||0;return n=t(n),i=t(i),o=t(o),a.opacity=1,function(l){return a.r=n(l),a.g=i(l),a.b=o(l),a+""}}}var Wc=_s(ms),Yc=_s(gs);function vs(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),i;return function(o){for(i=0;i<r;++i)n[i]=t[i]*(1-o)+e[i]*o;return n}}function xs(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function ws(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,i=new Array(n),o=new Array(r),s;for(s=0;s<n;++s)i[s]=te(t[s],e[s]);for(;s<r;++s)o[s]=e[s];return function(a){for(s=0;s<n;++s)o[s]=i[s](a);return o}}function bs(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function et(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function Es(t,e){var r={},n={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?r[i]=te(t[i],e[i]):n[i]=e[i];return function(o){for(i in r)n[i]=r[i](o);return n}}var Bn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ln=new RegExp(Bn.source,"g");function Kc(t){return function(){return t}}function Qc(t){return function(e){return t(e)+""}}function Ie(t,e){var r=Bn.lastIndex=Ln.lastIndex=0,n,i,o,s=-1,a=[],l=[];for(t=t+"",e=e+"";(n=Bn.exec(t))&&(i=Ln.exec(e));)(o=i.index)>r&&(o=e.slice(r,o),a[s]?a[s]+=o:a[++s]=o),(n=n[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:et(n,i)})),r=Ln.lastIndex;return r<e.length&&(o=e.slice(r),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?Qc(l[0].x):Kc(e):(e=l.length,function(u){for(var c=0,f;c<e;++c)a[(f=l[c]).i]=f.x(u);return a.join("")})}function te(t,e){var r=typeof e,n;return e==null||r==="boolean"?Oe(e):(r==="number"?et:r==="string"?(n=_t(e))?(e=n,Jt):Ie:e instanceof _t?Jt:e instanceof Date?bs:xs(e)?vs:Array.isArray(e)?ws:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Es:et)(t,e)}function Rn(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}var Ns=180/Math.PI,Nr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $n(t,e,r,n,i,o){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*r+e*n)&&(r-=t*l,n-=e*l),(a=Math.sqrt(r*r+n*n))&&(r/=a,n/=a,l/=a),t*n<e*r&&(t=-t,e=-e,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Ns,skewX:Math.atan(l)*Ns,scaleX:s,scaleY:a}}var Mr;function Ms(t){let e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Nr:$n(e.a,e.b,e.c,e.d,e.e,e.f)}function Ss(t){return t==null?Nr:(Mr||(Mr=document.createElementNS("http://www.w3.org/2000/svg","g")),Mr.setAttribute("transform",t),(t=Mr.transform.baseVal.consolidate())?(t=t.matrix,$n(t.a,t.b,t.c,t.d,t.e,t.f)):Nr)}function ks(t,e,r,n){function i(u){return u.length?u.pop()+" ":""}function o(u,c,f,p,m,T){if(u!==f||c!==p){var A=m.push("translate(",null,e,null,r);T.push({i:A-4,x:et(u,f)},{i:A-2,x:et(c,p)})}else(f||p)&&m.push("translate("+f+e+p+r)}function s(u,c,f,p){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),p.push({i:f.push(i(f)+"rotate(",null,n)-2,x:et(u,c)})):c&&f.push(i(f)+"rotate("+c+n)}function a(u,c,f,p){u!==c?p.push({i:f.push(i(f)+"skewX(",null,n)-2,x:et(u,c)}):c&&f.push(i(f)+"skewX("+c+n)}function l(u,c,f,p,m,T){if(u!==f||c!==p){var A=m.push(i(m)+"scale(",null,",",null,")");T.push({i:A-4,x:et(u,f)},{i:A-2,x:et(c,p)})}else(f!==1||p!==1)&&m.push(i(m)+"scale("+f+","+p+")")}return function(u,c){var f=[],p=[];return u=t(u),c=t(c),o(u.translateX,u.translateY,c.translateX,c.translateY,f,p),s(u.rotate,c.rotate,f,p),a(u.skewX,c.skewX,f,p),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,f,p),u=c=null,function(m){for(var T=-1,A=p.length,O;++T<A;)f[(O=p[T]).i]=O.x(m);return f.join("")}}}var zn=ks(Ms,"px, ","px)","deg)"),On=ks(Ss,", ",")",")");var Jc=1e-12;function As(t){return((t=Math.exp(t))+1/t)/2}function tf(t){return((t=Math.exp(t))-1/t)/2}function ef(t){return((t=Math.exp(2*t))-1)/(t+1)}var In=(function t(e,r,n){function i(o,s){var a=o[0],l=o[1],u=o[2],c=s[0],f=s[1],p=s[2],m=c-a,T=f-l,A=m*m+T*T,O,N;if(A<Jc)N=Math.log(p/u)/e,O=function(E){return[a+E*m,l+E*T,u*Math.exp(e*E*N)]};else{var _=Math.sqrt(A),M=(p*p-u*u+n*A)/(2*u*r*_),d=(p*p-u*u-n*A)/(2*p*r*_),y=Math.log(Math.sqrt(M*M+1)-M),v=Math.log(Math.sqrt(d*d+1)-d);N=(v-y)/e,O=function(E){var P=E*N,B=As(y),R=u/(r*_)*(B*ef(e*P+y)-tf(y));return[a+R*m,l+R*T,u*B/As(e*P+y)]}}return O.duration=N*1e3*e/Math.SQRT2,O}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return t(s,a,l)},i})(Math.SQRT2,2,4);var pe=0,Fe=0,De=0,Ts=1e3,Sr,je,kr=0,ee=0,Ar=0,He=typeof performance=="object"&&performance.now?performance:Date,Ps=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ve(){return ee||(Ps(rf),ee=He.now()+Ar)}function rf(){ee=0}function qe(){this._call=this._time=this._next=null}qe.prototype=Cr.prototype={constructor:qe,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?Ve():+r)+(e==null?0:+e),!this._next&&je!==this&&(je?je._next=this:Sr=this,je=this),this._call=t,this._time=r,Dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Dn())}};function Cr(t,e,r){var n=new qe;return n.restart(t,e,r),n}function Ls(){Ve(),++pe;for(var t=Sr,e;t;)(e=ee-t._time)>=0&&t._call.call(void 0,e),t=t._next;--pe}function Cs(){ee=(kr=He.now())+Ar,pe=Fe=0;try{Ls()}finally{pe=0,of(),ee=0}}function nf(){var t=He.now(),e=t-kr;e>Ts&&(Ar-=e,kr=t)}function of(){for(var t,e=Sr,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:Sr=r);je=t,Dn(n)}function Dn(t){if(!pe){Fe&&(Fe=clearTimeout(Fe));var e=t-ee;e>24?(t<1/0&&(Fe=setTimeout(Cs,t-He.now()-Ar)),De&&(De=clearInterval(De))):(De||(kr=He.now(),De=setInterval(nf,Ts)),pe=1,Ps(Cs))}}function Tr(t,e,r){var n=new qe;return e=e==null?0:+e,n.restart(i=>{n.stop(),t(i+e)},e,r),n}var sf=Wt("start","end","cancel","interrupt"),af=[],$s=0,Bs=1,Lr=2,Pr=3,Rs=4,Br=5,Ge=6;function Dt(t,e,r,n,i,o){var s=t.__transition;if(!s)t.__transition={};else if(r in s)return;lf(t,r,{name:e,index:n,group:i,on:sf,tween:af,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:$s})}function Ue(t,e){var r=W(t,e);if(r.state>$s)throw new Error("too late; already scheduled");return r}function rt(t,e){var r=W(t,e);if(r.state>Pr)throw new Error("too late; already running");return r}function W(t,e){var r=t.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function lf(t,e,r){var n=t.__transition,i;n[e]=r,r.timer=Cr(o,0,r.time);function o(u){r.state=Bs,r.timer.restart(s,r.delay,r.time),r.delay<=u&&s(u-r.delay)}function s(u){var c,f,p,m;if(r.state!==Bs)return l();for(c in n)if(m=n[c],m.name===r.name){if(m.state===Pr)return Tr(s);m.state===Rs?(m.state=Ge,m.timer.stop(),m.on.call("interrupt",t,t.__data__,m.index,m.group),delete n[c]):+c<e&&(m.state=Ge,m.timer.stop(),m.on.call("cancel",t,t.__data__,m.index,m.group),delete n[c])}if(Tr(function(){r.state===Pr&&(r.state=Rs,r.timer.restart(a,r.delay,r.time),a(u))}),r.state=Lr,r.on.call("start",t,t.__data__,r.index,r.group),r.state===Lr){for(r.state=Pr,i=new Array(p=r.tween.length),c=0,f=-1;c<p;++c)(m=r.tween[c].value.call(t,t.__data__,r.index,r.group))&&(i[++f]=m);i.length=f+1}}function a(u){for(var c=u<r.duration?r.ease.call(null,u/r.duration):(r.timer.restart(l),r.state=Br,1),f=-1,p=i.length;++f<p;)i[f].call(t,c);r.state===Br&&(r.on.call("end",t,t.__data__,r.index,r.group),l())}function l(){r.state=Ge,r.timer.stop(),delete n[e];for(var u in n)return;delete t.__transition}}function re(t,e){var r=t.__transition,n,i,o=!0,s;if(r){e=e==null?null:e+"";for(s in r){if((n=r[s]).name!==e){o=!1;continue}i=n.state>Lr&&n.state<Br,n.state=Ge,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete r[s]}o&&delete t.__transition}}function zs(t){return this.each(function(){re(this,t)})}function uf(t,e){var r,n;return function(){var i=rt(this,t),o=i.tween;if(o!==r){n=r=o;for(var s=0,a=n.length;s<a;++s)if(n[s].name===e){n=n.slice(),n.splice(s,1);break}}i.tween=n}}function cf(t,e,r){var n,i;if(typeof r!="function")throw new Error;return function(){var o=rt(this,t),s=o.tween;if(s!==n){i=(n=s).slice();for(var a={name:e,value:r},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=a;break}l===u&&i.push(a)}o.tween=i}}function Os(t,e){var r=this._id;if(t+="",arguments.length<2){for(var n=W(this.node(),r).tween,i=0,o=n.length,s;i<o;++i)if((s=n[i]).name===t)return s.value;return null}return this.each((e==null?uf:cf)(r,t,e))}function de(t,e,r){var n=t._id;return t.each(function(){var i=rt(this,n);(i.value||(i.value={}))[e]=r.apply(this,arguments)}),function(i){return W(i,n).value[e]}}function Rr(t,e){var r;return(typeof e=="number"?et:e instanceof _t?Jt:(r=_t(e))?(e=r,Jt):Ie)(t,e)}function ff(t){return function(){this.removeAttribute(t)}}function pf(t){return function(){this.removeAttributeNS(t.space,t.local)}}function df(t,e,r){var n,i=r+"",o;return function(){var s=this.getAttribute(t);return s===i?null:s===n?o:o=e(n=s,r)}}function hf(t,e,r){var n,i=r+"",o;return function(){var s=this.getAttributeNS(t.space,t.local);return s===i?null:s===n?o:o=e(n=s,r)}}function mf(t,e,r){var n,i,o;return function(){var s,a=r(this),l;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=a+"",s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a)))}}function gf(t,e,r){var n,i,o;return function(){var s,a=r(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=a+"",s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a)))}}function Is(t,e){var r=kt(t),n=r==="transform"?On:Rr;return this.attrTween(t,typeof e=="function"?(r.local?gf:mf)(r,n,de(this,"attr."+t,e)):e==null?(r.local?pf:ff)(r):(r.local?hf:df)(r,n,e))}function yf(t,e){return function(r){this.setAttribute(t,e.call(this,r))}}function _f(t,e){return function(r){this.setAttributeNS(t.space,t.local,e.call(this,r))}}function vf(t,e){var r,n;function i(){var o=e.apply(this,arguments);return o!==n&&(r=(n=o)&&_f(t,o)),r}return i._value=e,i}function xf(t,e){var r,n;function i(){var o=e.apply(this,arguments);return o!==n&&(r=(n=o)&&yf(t,o)),r}return i._value=e,i}function Ds(t,e){var r="attr."+t;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;var n=kt(t);return this.tween(r,(n.local?vf:xf)(n,e))}function wf(t,e){return function(){Ue(this,t).delay=+e.apply(this,arguments)}}function bf(t,e){return e=+e,function(){Ue(this,t).delay=e}}function Fs(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?wf:bf)(e,t)):W(this.node(),e).delay}function Ef(t,e){return function(){rt(this,t).duration=+e.apply(this,arguments)}}function Nf(t,e){return e=+e,function(){rt(this,t).duration=e}}function js(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Ef:Nf)(e,t)):W(this.node(),e).duration}function Mf(t,e){if(typeof e!="function")throw new Error;return function(){rt(this,t).ease=e}}function Hs(t){var e=this._id;return arguments.length?this.each(Mf(e,t)):W(this.node(),e).ease}function Sf(t,e){return function(){var r=e.apply(this,arguments);if(typeof r!="function")throw new Error;rt(this,t).ease=r}}function qs(t){if(typeof t!="function")throw new Error;return this.each(Sf(this._id,t))}function Vs(t){typeof t!="function"&&(t=Ee(t));for(var e=this._groups,r=e.length,n=new Array(r),i=0;i<r;++i)for(var o=e[i],s=o.length,a=n[i]=[],l,u=0;u<s;++u)(l=o[u])&&t.call(l,l.__data__,u,o)&&a.push(l);return new st(n,this._parents,this._name,this._id)}function Gs(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,r=t._groups,n=e.length,i=r.length,o=Math.min(n,i),s=new Array(n),a=0;a<o;++a)for(var l=e[a],u=r[a],c=l.length,f=s[a]=new Array(c),p,m=0;m<c;++m)(p=l[m]||u[m])&&(f[m]=p);for(;a<n;++a)s[a]=e[a];return new st(s,this._parents,this._name,this._id)}function kf(t){return(t+"").trim().split(/^|\s+/).every(function(e){var r=e.indexOf(".");return r>=0&&(e=e.slice(0,r)),!e||e==="start"})}function Af(t,e,r){var n,i,o=kf(e)?Ue:rt;return function(){var s=o(this,t),a=s.on;a!==n&&(i=(n=a).copy()).on(e,r),s.on=i}}function Us(t,e){var r=this._id;return arguments.length<2?W(this.node(),r).on.on(t):this.each(Af(r,t,e))}function Cf(t){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==t)return;e&&e.removeChild(this)}}function Xs(){return this.on("end.remove",Cf(this._id))}function Zs(t){var e=this._name,r=this._id;typeof t!="function"&&(t=Vt(t));for(var n=this._groups,i=n.length,o=new Array(i),s=0;s<i;++s)for(var a=n[s],l=a.length,u=o[s]=new Array(l),c,f,p=0;p<l;++p)(c=a[p])&&(f=t.call(c,c.__data__,p,a))&&("__data__"in c&&(f.__data__=c.__data__),u[p]=f,Dt(u[p],e,r,p,u,W(c,r)));return new st(o,this._parents,e,r)}function Ws(t){var e=this._name,r=this._id;typeof t!="function"&&(t=be(t));for(var n=this._groups,i=n.length,o=[],s=[],a=0;a<i;++a)for(var l=n[a],u=l.length,c,f=0;f<u;++f)if(c=l[f]){for(var p=t.call(c,c.__data__,f,l),m,T=W(c,r),A=0,O=p.length;A<O;++A)(m=p[A])&&Dt(m,e,r,A,p,T);o.push(p),s.push(c)}return new st(o,s,e,r)}var Tf=At.prototype.constructor;function Ys(){return new Tf(this._groups,this._parents)}function Pf(t,e){var r,n,i;return function(){var o=Rt(this,t),s=(this.style.removeProperty(t),Rt(this,t));return o===s?null:o===r&&s===n?i:i=e(r=o,n=s)}}function Ks(t){return function(){this.style.removeProperty(t)}}function Lf(t,e,r){var n,i=r+"",o;return function(){var s=Rt(this,t);return s===i?null:s===n?o:o=e(n=s,r)}}function Bf(t,e,r){var n,i,o;return function(){var s=Rt(this,t),a=r(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),Rt(this,t))),s===l?null:s===n&&l===i?o:(i=l,o=e(n=s,a))}}function Rf(t,e){var r,n,i,o="style."+e,s="end."+o,a;return function(){var l=rt(this,t),u=l.on,c=l.value[o]==null?a||(a=Ks(e)):void 0;(u!==r||i!==c)&&(n=(r=u).copy()).on(s,i=c),l.on=n}}function Qs(t,e,r){var n=(t+="")=="transform"?zn:Rr;return e==null?this.styleTween(t,Pf(t,n)).on("end.style."+t,Ks(t)):typeof e=="function"?this.styleTween(t,Bf(t,n,de(this,"style."+t,e))).each(Rf(this._id,t)):this.styleTween(t,Lf(t,n,e),r).on("end.style."+t,null)}function $f(t,e,r){return function(n){this.style.setProperty(t,e.call(this,n),r)}}function zf(t,e,r){var n,i;function o(){var s=e.apply(this,arguments);return s!==i&&(n=(i=s)&&$f(t,s,r)),n}return o._value=e,o}function Js(t,e,r){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,zf(t,e,r??""))}function Of(t){return function(){this.textContent=t}}function If(t){return function(){var e=t(this);this.textContent=e??""}}function ta(t){return this.tween("text",typeof t=="function"?If(de(this,"text",t)):Of(t==null?"":t+""))}function Df(t){return function(e){this.textContent=t.call(this,e)}}function Ff(t){var e,r;function n(){var i=t.apply(this,arguments);return i!==r&&(e=(r=i)&&Df(i)),e}return n._value=t,n}function ea(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Ff(t))}function ra(){for(var t=this._name,e=this._id,r=$r(),n=this._groups,i=n.length,o=0;o<i;++o)for(var s=n[o],a=s.length,l,u=0;u<a;++u)if(l=s[u]){var c=W(l,e);Dt(l,t,r,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new st(n,this._parents,t,r)}function na(){var t,e,r=this,n=r._id,i=r.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};r.each(function(){var u=rt(this,n),c=u.on;c!==t&&(e=(t=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),i===0&&o()})}var jf=0;function st(t,e,r,n){this._groups=t,this._parents=e,this._name=r,this._id=n}function ia(t){return At().transition(t)}function $r(){return++jf}var Pt=At.prototype;st.prototype=ia.prototype={constructor:st,select:Zs,selectAll:Ws,selectChild:Pt.selectChild,selectChildren:Pt.selectChildren,filter:Vs,merge:Gs,selection:Ys,transition:ra,call:Pt.call,nodes:Pt.nodes,node:Pt.node,size:Pt.size,empty:Pt.empty,each:Pt.each,on:Us,attr:Is,attrTween:Ds,style:Qs,styleTween:Js,text:ta,textTween:ea,remove:Xs,tween:Os,delay:Fs,duration:js,ease:Hs,easeVarying:qs,end:na,[Symbol.iterator]:Pt[Symbol.iterator]};function zr(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Hf={time:null,delay:0,duration:250,ease:zr};function qf(t,e){for(var r;!(r=t.__transition)||!(r=r[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return r}function oa(t){var e,r;t instanceof st?(e=t._id,t=t._name):(e=$r(),(r=Hf).time=Ve(),t=t==null?null:t+"");for(var n=this._groups,i=n.length,o=0;o<i;++o)for(var s=n[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&Dt(l,t,e,u,s,r||qf(l,e));return new st(n,this._parents,t,e)}At.prototype.interrupt=zs;At.prototype.transition=oa;var Xe=t=>()=>t;function Fn(t,{sourceEvent:e,target:r,transform:n,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:i}})}function vt(t,e,r){this.k=t,this.x=e,this.y=r}vt.prototype={constructor:vt,scale:function(t){return t===1?this:new vt(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new vt(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Lt=new vt(1,0,0);jn.prototype=vt.prototype;function jn(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Lt;return t.__zoom}function Or(t){t.stopImmediatePropagation()}function he(t){t.preventDefault(),t.stopImmediatePropagation()}function Vf(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Gf(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function sa(){return this.__zoom||Lt}function Uf(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Xf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Zf(t,e,r){var n=t.invertX(e[0][0])-r[0][0],i=t.invertX(e[1][0])-r[1][0],o=t.invertY(e[0][1])-r[0][1],s=t.invertY(e[1][1])-r[1][1];return t.translate(i>n?(n+i)/2:Math.min(0,n)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function Hn(){var t=Vf,e=Gf,r=Zf,n=Uf,i=Xf,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=In,u=Wt("start","zoom","end"),c,f,p,m=500,T=150,A=0,O=10;function N(h){h.property("__zoom",sa).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",R).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",x).on("touchend.zoom touchcancel.zoom",b).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(h,S,g,w){var L=h.selection?h.selection():h;L.property("__zoom",sa),h!==L?y(h,S,g,w):L.interrupt().each(function(){v(this,arguments).event(w).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},N.scaleBy=function(h,S,g,w){N.scaleTo(h,function(){var L=this.__zoom.k,$=typeof S=="function"?S.apply(this,arguments):S;return L*$},g,w)},N.scaleTo=function(h,S,g,w){N.transform(h,function(){var L=e.apply(this,arguments),$=this.__zoom,k=g==null?d(L):typeof g=="function"?g.apply(this,arguments):g,D=$.invert(k),q=typeof S=="function"?S.apply(this,arguments):S;return r(M(_($,q),k,D),L,s)},g,w)},N.translateBy=function(h,S,g,w){N.transform(h,function(){return r(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof g=="function"?g.apply(this,arguments):g),e.apply(this,arguments),s)},null,w)},N.translateTo=function(h,S,g,w,L){N.transform(h,function(){var $=e.apply(this,arguments),k=this.__zoom,D=w==null?d($):typeof w=="function"?w.apply(this,arguments):w;return r(Lt.translate(D[0],D[1]).scale(k.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof g=="function"?-g.apply(this,arguments):-g),$,s)},w,L)};function _(h,S){return S=Math.max(o[0],Math.min(o[1],S)),S===h.k?h:new vt(S,h.x,h.y)}function M(h,S,g){var w=S[0]-g[0]*h.k,L=S[1]-g[1]*h.k;return w===h.x&&L===h.y?h:new vt(h.k,w,L)}function d(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function y(h,S,g,w){h.on("start.zoom",function(){v(this,arguments).event(w).start()}).on("interrupt.zoom end.zoom",function(){v(this,arguments).event(w).end()}).tween("zoom",function(){var L=this,$=arguments,k=v(L,$).event(w),D=e.apply(L,$),q=g==null?d(D):typeof g=="function"?g.apply(L,$):g,at=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),X=L.__zoom,Y=typeof S=="function"?S.apply(L,$):S,ct=l(X.invert(q).concat(at/X.k),Y.invert(q).concat(at/Y.k));return function(ft){if(ft===1)ft=Y;else{var K=ct(ft),mt=at/K[2];ft=new vt(mt,q[0]-K[0]*mt,q[1]-K[1]*mt)}k.zoom(null,ft)}})}function v(h,S,g){return!g&&h.__zooming||new E(h,S)}function E(h,S){this.that=h,this.args=S,this.active=0,this.sourceEvent=null,this.extent=e.apply(h,S),this.taps=0}E.prototype={event:function(h){return h&&(this.sourceEvent=h),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(h,S){return this.mouse&&h!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&h!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&h!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(h){var S=U(this.that).datum();u.call(h,this.that,new Fn(h,{sourceEvent:this.sourceEvent,target:N,type:h,transform:this.that.__zoom,dispatch:u}),S)}};function P(h,...S){if(!t.apply(this,arguments))return;var g=v(this,S).event(h),w=this.__zoom,L=Math.max(o[0],Math.min(o[1],w.k*Math.pow(2,n.apply(this,arguments)))),$=Q(h);if(g.wheel)(g.mouse[0][0]!==$[0]||g.mouse[0][1]!==$[1])&&(g.mouse[1]=w.invert(g.mouse[0]=$)),clearTimeout(g.wheel);else{if(w.k===L)return;g.mouse=[$,w.invert($)],re(this),g.start()}he(h),g.wheel=setTimeout(k,T),g.zoom("mouse",r(M(_(w,L),g.mouse[0],g.mouse[1]),g.extent,s));function k(){g.wheel=null,g.end()}}function B(h,...S){if(p||!t.apply(this,arguments))return;var g=h.currentTarget,w=v(this,S,!0).event(h),L=U(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",at,!0),$=Q(h,g),k=h.clientX,D=h.clientY;Ce(h.view),Or(h),w.mouse=[$,this.__zoom.invert($)],re(this),w.start();function q(X){if(he(X),!w.moved){var Y=X.clientX-k,ct=X.clientY-D;w.moved=Y*Y+ct*ct>A}w.event(X).zoom("mouse",r(M(w.that.__zoom,w.mouse[0]=Q(X,g),w.mouse[1]),w.extent,s))}function at(X){L.on("mousemove.zoom mouseup.zoom",null),Te(X.view,w.moved),he(X),w.event(X).end()}}function R(h,...S){if(t.apply(this,arguments)){var g=this.__zoom,w=Q(h.changedTouches?h.changedTouches[0]:h,this),L=g.invert(w),$=g.k*(h.shiftKey?.5:2),k=r(M(_(g,$),w,L),e.apply(this,S),s);he(h),a>0?U(this).transition().duration(a).call(y,k,w,h):U(this).call(N.transform,k,w,h)}}function C(h,...S){if(t.apply(this,arguments)){var g=h.touches,w=g.length,L=v(this,S,h.changedTouches.length===w).event(h),$,k,D,q;for(Or(h),k=0;k<w;++k)D=g[k],q=Q(D,this),q=[q,this.__zoom.invert(q),D.identifier],L.touch0?!L.touch1&&L.touch0[2]!==q[2]&&(L.touch1=q,L.taps=0):(L.touch0=q,$=!0,L.taps=1+!!c);c&&(c=clearTimeout(c)),$&&(L.taps<2&&(f=q[0],c=setTimeout(function(){c=null},m)),re(this),L.start())}}function x(h,...S){if(this.__zooming){var g=v(this,S).event(h),w=h.changedTouches,L=w.length,$,k,D,q;for(he(h),$=0;$<L;++$)k=w[$],D=Q(k,this),g.touch0&&g.touch0[2]===k.identifier?g.touch0[0]=D:g.touch1&&g.touch1[2]===k.identifier&&(g.touch1[0]=D);if(k=g.that.__zoom,g.touch1){var at=g.touch0[0],X=g.touch0[1],Y=g.touch1[0],ct=g.touch1[1],ft=(ft=Y[0]-at[0])*ft+(ft=Y[1]-at[1])*ft,K=(K=ct[0]-X[0])*K+(K=ct[1]-X[1])*K;k=_(k,Math.sqrt(ft/K)),D=[(at[0]+Y[0])/2,(at[1]+Y[1])/2],q=[(X[0]+ct[0])/2,(X[1]+ct[1])/2]}else if(g.touch0)D=g.touch0[0],q=g.touch0[1];else return;g.zoom("touch",r(M(k,D,q),g.extent,s))}}function b(h,...S){if(this.__zooming){var g=v(this,S).event(h),w=h.changedTouches,L=w.length,$,k;for(Or(h),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),$=0;$<L;++$)k=w[$],g.touch0&&g.touch0[2]===k.identifier?delete g.touch0:g.touch1&&g.touch1[2]===k.identifier&&delete g.touch1;if(g.touch1&&!g.touch0&&(g.touch0=g.touch1,delete g.touch1),g.touch0)g.touch0[1]=this.__zoom.invert(g.touch0[0]);else if(g.end(),g.taps===2&&(k=Q(k,this),Math.hypot(f[0]-k[0],f[1]-k[1])<O)){var D=U(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return N.wheelDelta=function(h){return arguments.length?(n=typeof h=="function"?h:Xe(+h),N):n},N.filter=function(h){return arguments.length?(t=typeof h=="function"?h:Xe(!!h),N):t},N.touchable=function(h){return arguments.length?(i=typeof h=="function"?h:Xe(!!h),N):i},N.extent=function(h){return arguments.length?(e=typeof h=="function"?h:Xe([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),N):e},N.scaleExtent=function(h){return arguments.length?(o[0]=+h[0],o[1]=+h[1],N):[o[0],o[1]]},N.translateExtent=function(h){return arguments.length?(s[0][0]=+h[0][0],s[1][0]=+h[1][0],s[0][1]=+h[0][1],s[1][1]=+h[1][1],N):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},N.constrain=function(h){return arguments.length?(r=h,N):r},N.duration=function(h){return arguments.length?(a=+h,N):a},N.interpolate=function(h){return arguments.length?(l=h,N):l},N.on=function(){var h=u.on.apply(u,arguments);return h===u?N:h},N.clickDistance=function(h){return arguments.length?(A=(h=+h)*h,N):Math.sqrt(A)},N.tapDistance=function(h){return arguments.length?(O=+h,N):O},N}function ne(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function qn(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ir(t){let e,r,n;t.length!==2?(e=ne,r=(a,l)=>ne(t(a),l),n=(a,l)=>t(a)-l):(e=t===ne||t===qn?t:Wf,r=t,n=t);function i(a,l,u=0,c=a.length){if(u<c){if(e(l,l)!==0)return c;do{let f=u+c>>>1;r(a[f],l)<0?u=f+1:c=f}while(u<c)}return u}function o(a,l,u=0,c=a.length){if(u<c){if(e(l,l)!==0)return c;do{let f=u+c>>>1;r(a[f],l)<=0?u=f+1:c=f}while(u<c)}return u}function s(a,l,u=0,c=a.length){let f=i(a,l,u,c-1);return f>u&&n(a[f-1],l)>-n(a[f],l)?f-1:f}return{left:i,center:s,right:o}}function Wf(){return 0}function Vn(t){return t===null?NaN:+t}var aa=Ir(ne),la=aa.right,Yf=aa.left,Kf=Ir(Vn).center,Gn=la;var Qf=Math.sqrt(50),Jf=Math.sqrt(10),tp=Math.sqrt(2);function Dr(t,e,r){let n=(e-t)/Math.max(0,r),i=Math.floor(Math.log10(n)),o=n/Math.pow(10,i),s=o>=Qf?10:o>=Jf?5:o>=tp?2:1,a,l,u;return i<0?(u=Math.pow(10,-i)/s,a=Math.round(t*u),l=Math.round(e*u),a/u<t&&++a,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*s,a=Math.round(t/u),l=Math.round(e/u),a*u<t&&++a,l*u>e&&--l),l<a&&.5<=r&&r<2?Dr(t,e,r*2):[a,l,u]}function Fr(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];let n=e<t,[i,o,s]=n?Dr(e,t,r):Dr(t,e,r);if(!(o>=i))return[];let a=o-i+1,l=new Array(a);if(n)if(s<0)for(let u=0;u<a;++u)l[u]=(o-u)/-s;else for(let u=0;u<a;++u)l[u]=(o-u)*s;else if(s<0)for(let u=0;u<a;++u)l[u]=(i+u)/-s;else for(let u=0;u<a;++u)l[u]=(i+u)*s;return l}function Ze(t,e,r){return e=+e,t=+t,r=+r,Dr(t,e,r)[2]}function Un(t,e,r){e=+e,t=+t,r=+r;let n=e<t,i=n?Ze(e,t,r):Ze(t,e,r);return(n?-1:1)*(i<0?1/-i:i)}function ua(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Xn(t){return function(){return t}}function Zn(t){return+t}var ca=[0,1];function me(t){return t}function Wn(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:Xn(isNaN(e)?NaN:.5)}function ep(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function rp(t,e,r){var n=t[0],i=t[1],o=e[0],s=e[1];return i<n?(n=Wn(i,n),o=r(s,o)):(n=Wn(n,i),o=r(o,s)),function(a){return o(n(a))}}function np(t,e,r){var n=Math.min(t.length,e.length)-1,i=new Array(n),o=new Array(n),s=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<n;)i[s]=Wn(t[s],t[s+1]),o[s]=r(e[s],e[s+1]);return function(a){var l=Gn(t,a,1,n)-1;return o[l](i[l](a))}}function fa(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function ip(){var t=ca,e=ca,r=te,n,i,o,s=me,a,l,u;function c(){var p=Math.min(t.length,e.length);return s!==me&&(s=ep(t[0],t[p-1])),a=p>2?np:rp,l=u=null,f}function f(p){return p==null||isNaN(p=+p)?o:(l||(l=a(t.map(n),e,r)))(n(s(p)))}return f.invert=function(p){return s(i((u||(u=a(e,t.map(n),et)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,Zn),c()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),c()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),r=Rn,c()},f.clamp=function(p){return arguments.length?(s=p?!0:me,c()):s!==me},f.interpolate=function(p){return arguments.length?(r=p,c()):r},f.unknown=function(p){return arguments.length?(o=p,f):o},function(p,m){return n=p,i=m,c()}}function Yn(){return ip()(me,me)}function pa(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function ie(t,e){if(!isFinite(t)||t===0)return null;var r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function Nt(t){return t=ie(Math.abs(t)),t?t[1]:NaN}function da(t,e){return function(r,n){for(var i=r.length,o=[],s=0,a=t[0],l=0;i>0&&a>0&&(l+a+1>n&&(a=Math.max(1,n-l)),o.push(r.substring(i-=a,i+a)),!((l+=a+1)>n));)a=t[s=(s+1)%t.length];return o.reverse().join(e)}}function ha(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var op=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ft(t){if(!(e=op.exec(t)))throw new Error("invalid format: "+t);var e;return new jr({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Ft.prototype=jr.prototype;function jr(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}jr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ma(t){t:for(var e=t.length,r=1,n=-1,i;r<e;++r)switch(t[r]){case".":n=i=r;break;case"0":n===0&&(n=r),i=r;break;default:if(!+t[r])break t;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(i+1):t}var We;function ga(t,e){var r=ie(t,e);if(!r)return We=void 0,t.toPrecision(e);var n=r[0],i=r[1],o=i-(We=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=n.length;return o===s?n:o>s?n+new Array(o-s+1).join("0"):o>0?n.slice(0,o)+"."+n.slice(o):"0."+new Array(1-o).join("0")+ie(t,Math.max(0,e+o-1))[0]}function Kn(t,e){var r=ie(t,e);if(!r)return t+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}var Qn={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:pa,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Kn(t*100,e),r:Kn,s:ga,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Jn(t){return t}var ya=Array.prototype.map,_a=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];function va(t){var e=t.grouping===void 0||t.thousands===void 0?Jn:da(ya.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Jn:ha(ya.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"\u2212":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function u(f,p){f=Ft(f);var m=f.fill,T=f.align,A=f.sign,O=f.symbol,N=f.zero,_=f.width,M=f.comma,d=f.precision,y=f.trim,v=f.type;v==="n"?(M=!0,v="g"):Qn[v]||(d===void 0&&(d=12),y=!0,v="g"),(N||m==="0"&&T==="=")&&(N=!0,m="0",T="=");var E=(p&&p.prefix!==void 0?p.prefix:"")+(O==="$"?r:O==="#"&&/[boxX]/.test(v)?"0"+v.toLowerCase():""),P=(O==="$"?n:/[%p]/.test(v)?s:"")+(p&&p.suffix!==void 0?p.suffix:""),B=Qn[v],R=/[defgprs%]/.test(v);d=d===void 0?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,d)):Math.max(0,Math.min(20,d));function C(x){var b=E,h=P,S,g,w;if(v==="c")h=B(x)+h,x="";else{x=+x;var L=x<0||1/x<0;if(x=isNaN(x)?l:B(Math.abs(x),d),y&&(x=ma(x)),L&&+x==0&&A!=="+"&&(L=!1),b=(L?A==="("?A:a:A==="-"||A==="("?"":A)+b,h=(v==="s"&&!isNaN(x)&&We!==void 0?_a[8+We/3]:"")+h+(L&&A==="("?")":""),R){for(S=-1,g=x.length;++S<g;)if(w=x.charCodeAt(S),48>w||w>57){h=(w===46?i+x.slice(S+1):x.slice(S))+h,x=x.slice(0,S);break}}}M&&!N&&(x=e(x,1/0));var $=b.length+x.length+h.length,k=$<_?new Array(_-$+1).join(m):"";switch(M&&N&&(x=e(k+x,k.length?_-h.length:1/0),k=""),T){case"<":x=b+x+h+k;break;case"=":x=b+k+x+h;break;case"^":x=k.slice(0,$=k.length>>1)+b+x+h+k.slice($);break;default:x=k+b+x+h;break}return o(x)}return C.toString=function(){return f+""},C}function c(f,p){var m=Math.max(-8,Math.min(8,Math.floor(Nt(p)/3)))*3,T=Math.pow(10,-m),A=u((f=Ft(f),f.type="f",f),{suffix:_a[8+m/3]});return function(O){return A(T*O)}}return{format:u,formatPrefix:c}}var Hr,qr,Vr;ti({thousands:",",grouping:[3],currency:["$",""]});function ti(t){return Hr=va(t),qr=Hr.format,Vr=Hr.formatPrefix,Hr}function ei(t){return Math.max(0,-Nt(Math.abs(t)))}function ri(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Nt(e)/3)))*3-Nt(Math.abs(t)))}function ni(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Nt(e)-Nt(t))+1}function ii(t,e,r,n){var i=Un(t,e,r),o;switch(n=Ft(n??",f"),n.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(o=ri(i,s))&&(n.precision=o),Vr(n,s)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=ni(i,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=ei(i))&&(n.precision=o-(n.type==="%")*2);break}}return qr(n)}function sp(t){var e=t.domain;return t.ticks=function(r){var n=e();return Fr(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var i=e();return ii(i[0],i[i.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),i=0,o=n.length-1,s=n[i],a=n[o],l,u,c=10;for(a<s&&(u=s,s=a,a=u,u=i,i=o,o=u);c-- >0;){if(u=Ze(s,a,r),u===l)return n[i]=s,n[o]=a,e(n);if(u>0)s=Math.floor(s/u)*u,a=Math.ceil(a/u)*u;else if(u<0)s=Math.ceil(s*u)/u,a=Math.floor(a*u)/u;else break;l=u}return t},t}function ge(){var t=Yn();return t.copy=function(){return fa(t,ge())},ua.apply(t,arguments),sp(t)}function xa(t){return t}var oi=1,Ur=2,si=3,Gr=4,wa=1e-6;function ap(t){return"translate("+t+",0)"}function lp(t){return"translate(0,"+t+")"}function up(t){return e=>+t(e)}function cp(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),r=>+t(r)+e}function fp(){return!this.__axis}function ba(t,e){var r=[],n=null,i=null,o=6,s=6,a=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,u=t===oi||t===Gr?-1:1,c=t===Gr||t===Ur?"x":"y",f=t===oi||t===si?ap:lp;function p(m){var T=n??(e.ticks?e.ticks.apply(e,r):e.domain()),A=i??(e.tickFormat?e.tickFormat.apply(e,r):xa),O=Math.max(o,0)+a,N=e.range(),_=+N[0]+l,M=+N[N.length-1]+l,d=(e.bandwidth?cp:up)(e.copy(),l),y=m.selection?m.selection():m,v=y.selectAll(".domain").data([null]),E=y.selectAll(".tick").data(T,e).order(),P=E.exit(),B=E.enter().append("g").attr("class","tick"),R=E.select("line"),C=E.select("text");v=v.merge(v.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),E=E.merge(B),R=R.merge(B.append("line").attr("stroke","currentColor").attr(c+"2",u*o)),C=C.merge(B.append("text").attr("fill","currentColor").attr(c,u*O).attr("dy",t===oi?"0em":t===si?"0.71em":"0.32em")),m!==y&&(v=v.transition(m),E=E.transition(m),R=R.transition(m),C=C.transition(m),P=P.transition(m).attr("opacity",wa).attr("transform",function(x){return isFinite(x=d(x))?f(x+l):this.getAttribute("transform")}),B.attr("opacity",wa).attr("transform",function(x){var b=this.parentNode.__axis;return f((b&&isFinite(b=b(x))?b:d(x))+l)})),P.remove(),v.attr("d",t===Gr||t===Ur?s?"M"+u*s+","+_+"H"+l+"V"+M+"H"+u*s:"M"+l+","+_+"V"+M:s?"M"+_+","+u*s+"V"+l+"H"+M+"V"+u*s:"M"+_+","+l+"H"+M),E.attr("opacity",1).attr("transform",function(x){return f(d(x)+l)}),R.attr(c+"2",u*o),C.attr(c,u*O).text(A),y.filter(fp).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===Ur?"start":t===Gr?"end":"middle"),y.each(function(){this.__axis=d})}return p.scale=function(m){return arguments.length?(e=m,p):e},p.ticks=function(){return r=Array.from(arguments),p},p.tickArguments=function(m){return arguments.length?(r=m==null?[]:Array.from(m),p):r.slice()},p.tickValues=function(m){return arguments.length?(n=m==null?null:Array.from(m),p):n&&n.slice()},p.tickFormat=function(m){return arguments.length?(i=m,p):i},p.tickSize=function(m){return arguments.length?(o=s=+m,p):o},p.tickSizeInner=function(m){return arguments.length?(o=+m,p):o},p.tickSizeOuter=function(m){return arguments.length?(s=+m,p):s},p.tickPadding=function(m){return arguments.length?(a=+m,p):a},p.offset=function(m){return arguments.length?(l=+m,p):l},p}function ai(t){return ba(Ur,t)}function li(t){return ba(si,t)}var pp=/^class[ {]/;function dp(t){return pp.test(t.toString())}function ci(t){return Array.isArray(t)}function ui(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Xr(...t){t.length===1&&ci(t[0])&&(t=t[0]),t=[...t];let e=t.pop();return e.$inject=t,e}var hp=/constructor\s*[^(]*\(\s*([^)]*)\)/m,mp=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,gp=/\/\*([^*]*)\*\//m;function yp(t){if(typeof t!="function")throw new Error(`Cannot annotate "${t}". Expected a function!`);let e=t.toString().match(dp(t)?hp:mp);if(!e)return[];let r=e[1]||e[2];return r&&r.split(",").map(n=>{let i=n.match(gp);return(i&&i[1]||n).trim()})||[]}function fi(t,e){e=e||{get:function(_,M){if(r.push(_),M===!1)return null;throw s(`No provider for "${_}"!`)}};let r=[],n=this._providers=Object.create(e._providers||null),i=this._instances=Object.create(null),o=i.injector=this,s=function(_){let M=r.join(" -> ");return r.length=0,new Error(M?`${_} (Resolving: ${M})`:_)};function a(_,M){if(!n[_]&&_.indexOf(".")!==-1){let d=_.split("."),y=a(d.shift());for(;d.length;)y=y[d.shift()];return y}if(ui(i,_))return i[_];if(ui(n,_)){if(r.indexOf(_)!==-1)throw r.push(_),s("Cannot resolve circular dependency!");return r.push(_),i[_]=n[_][0](n[_][1]),r.pop(),i[_]}return e.get(_,M)}function l(_,M){if(typeof M>"u"&&(M={}),typeof _!="function")if(ci(_))_=Xr(_.slice());else throw s(`Cannot invoke "${_}". Expected a function!`);let y=(_.$inject||yp(_)).map(v=>ui(M,v)?M[v]:a(v));return{fn:_,dependencies:y}}function u(_){let{fn:M,dependencies:d}=l(_),y=Function.prototype.bind.apply(M,[null].concat(d));return new y}function c(_,M,d){let{fn:y,dependencies:v}=l(_,d);return y.apply(M,v)}function f(_){return Xr(M=>_.get(M))}function p(_,M){if(M&&M.length){let d=Object.create(null),y=Object.create(null),v=[],E=[],P=[],B,R,C,x;for(let b in n)B=n[b],M.indexOf(b)!==-1&&(B[2]==="private"?(R=v.indexOf(B[3]),R===-1?(C=B[3].createChild([],M),x=f(C),v.push(B[3]),E.push(C),P.push(x),d[b]=[x,b,"private",C]):d[b]=[P[R],b,"private",E[R]]):d[b]=[B[2],B[1]],y[b]=!0),(B[2]==="factory"||B[2]==="type")&&B[1].$scope&&M.forEach(h=>{B[1].$scope.indexOf(h)!==-1&&(d[b]=[B[2],B[1]],y[h]=!0)});M.forEach(b=>{if(!y[b])throw new Error('No provider for "'+b+'". Cannot use provider from the parent!')}),_.unshift(d)}return new fi(_,o)}let m={factory:c,type:u,value:function(_){return _}};function T(_,M){let d=_.__init__||[];return function(){d.forEach(y=>{typeof y=="string"?M.get(y):M.invoke(y)})}}function A(_){let M=_.__exports__;if(M){let d=_.__modules__,y=Object.keys(_).reduce((R,C)=>(C!=="__exports__"&&C!=="__modules__"&&C!=="__init__"&&C!=="__depends__"&&(R[C]=_[C]),R),Object.create(null)),v=(d||[]).concat(y),E=p(v),P=Xr(function(R){return E.get(R)});M.forEach(function(R){n[R]=[P,R,"private",E]});let B=(_.__init__||[]).slice();return B.unshift(function(){E.init()}),_=Object.assign({},_,{__init__:B}),T(_,E)}return Object.keys(_).forEach(function(d){if(d==="__init__"||d==="__depends__")return;if(_[d][2]==="private"){n[d]=_[d];return}let y=_[d][0],v=_[d][1];n[d]=[m[y],_p(y,v),y]}),T(_,o)}function O(_,M){return _.indexOf(M)!==-1||(_=(M.__depends__||[]).reduce(O,_),_.indexOf(M)!==-1)?_:_.concat(M)}function N(_){let M=_.reduce(O,[]).map(A),d=!1;return function(){d||(d=!0,M.forEach(y=>y()))}}this.get=a,this.invoke=c,this.instantiate=u,this.createChild=p,this.init=N(t)}function _p(t,e){return t!=="value"&&ci(e)&&(e=Xr(e.slice())),e}var vp=Object.defineProperty,xp=(t,e)=>{for(var r in e)vp(t,r,{get:e[r],enumerable:!0})},wp=class{constructor(){this._drawings=new Map}set(t,e){this._drawings.set(t,e)}remove(t){this._drawings.delete(t)}get(t){return this._drawings.get(t)??!1}getAll(){return[...this._drawings.values()]}},Yr=class{constructor(t,e,r,n,i,o,s){this._elements=new Map,this._elementsContainer=null,this._className=t,this._canvas=r,this._eventBus=n,this._elementBuilder=i,this._elementRegistry=o,this._drawingRegistry=s,this._init(e)}reconcile(t,e){this._builder(t,e)}_builder(t,e){let r=this._elementRegistry.get(t);r&&e?(e.get("status")!==1&&e.set("status",2),this.updateElement(e)):r&&!e?this.removeElementById(r.id):!r&&e&&this.appendElement(e)}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().append("g").attr("class",`${this._className}-group`)}removeElement(t){let e=t.id;if(typeof e!="string")return;this._elements.delete(e);let r=this._drawingRegistry.get(e);r&&(this._drawingRegistry.remove(e),this._elementRegistry.removeElementById(e),this._eventBus.emit(`${this._className}.removed`,r,t),r.remove())}removeElementById(t){this.removeElement({id:t})}appendElement(t){this._elementRegistry.claimId(t,this._className);let e=this._elementsContainer.append("g").datum(t).attr("element-id",t.id).attr("class",`${this._className}Item element`);e.append("g").attr("class","innerElement").attr("transform","translate(3, 3)"),this._createElement(e,t),this._drawingRegistry.set(t.id,e),this._elements.set(t.id,t),this._eventBus.emit(`${this._className}.created`,e,t)}updateElement(t){let e=this._drawingRegistry.get(t.id);e&&(e.datum(t),this._updateElement(e,t),this._drawingRegistry.set(t.id,e),this._elements.set(t.id,t),this._eventBus.emit(`${this._className}.updated`,e,t))}getAll(){return[...this._elements.values()]}getContainer(){return this._elementsContainer}_init(t){this._drawContainer(),t&&t.forEach(e=>this._builder(e.id,e))}},bp='"HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif',Aa=class extends Yr{constructor(t,e,r,n,i,o){super("label",t,e,r,n,i,o)}_createElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.select(".innerElement").attr("transform","translate(3.66,3.66)").append("text").style("font-family",bp).attr("dominant-baseline","hanging").attr("fill",r.color??null).style("font-size",`${r.fontSize}px`).text(r.text??"")}_updateElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.select(".innerElement").select("text").attr("fill",r.color??null).style("font-size",`${r.fontSize}px`).text(r.text??"")}};Aa.$inject=["d3polytree.definitions.label","canvas","eventBus","elementBuilder","elementRegistry","drawingRegistry"];var Ca=class extends Yr{constructor(t,e,r,n,i,o){super("zone",t,e,r,n,i,o)}_createElement(t,e){let r=e,{x:n,y:i}=r.position;t.attr("x",n).attr("y",i).attr("transform",`translate(${n},${i})`),t.append("rect").attr("height",r.height??0).attr("width",r.width??0).style("stroke",r.border.lineColor??"").style("fill",r.fillColor??"").style("opacity",r.opacity??"").style("stroke-width",r.border.lineWidth??"")}_updateElement(t,e){let r=e;t.select("rect").attr("height",r.height??0).attr("width",r.width??0).style("stroke",r.border.lineColor??"").style("fill",r.fillColor??"").style("opacity",r.opacity??"").style("stroke-width",r.border.lineWidth??"")}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",":first-child").attr("class",`${this._className}-group`)}};Ca.$inject=["d3polytree.definitions.zone","canvas","eventBus","elementBuilder","elementRegistry","drawingRegistry"];function Ea(t){return`M ${t.map(e=>`${e.x} ${e.y}`).join(", L ")}`}var Ta=class extends Yr{constructor(t,e,r,n,i,o,s){super("link",void 0,e,r,i,o,s),this._markers=n,this._init(t)}_createElement(t,e){let r=e,n=Ea(r.waypoint),i=t.select(".innerElement");i.append("path").attr("class","line-path").attr("marker-end",`url(#${this._markers.getMarker(r.id,r.lineColor,r.fillColor)})`).attr("d",n).style("stroke",r.lineColor??"").style("fill","none").style("stroke-width",`${r.lineWidth??0}px`).attr("stroke-linejoin","round").style("stroke-linecap","round"),i.append("path").attr("class","line-subpath").attr("d",n).style("stroke",r.fillColor??"").style("fill","none").style("stroke-width",`${.375*(r.lineWidth??0)}px`).attr("stroke-linejoin","round").style("stroke-linecap","round")}_updateElement(t,e){let r=e,n=Ea(r.waypoint),i=t.select(".innerElement");i.select(".line-path").attr("marker-end",`url(#${this._markers.getMarker(r.id,r.lineColor,r.fillColor)})`).attr("d",n).style("stroke",r.lineColor??"").style("stroke-width",`${r.lineWidth??0}px`),i.select(".line-subpath").attr("d",n).style("stroke",r.fillColor??"").style("stroke-width",`${.375*(r.lineWidth??0)}px`)}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",".node-group").attr("class",`${this._className}-group`)}};Ta.$inject=["d3polytree.definitions.link","canvas","eventBus","markers","elementBuilder","elementRegistry","drawingRegistry"];var Pa=class{constructor(t){this._markers=new Map,this._defs=t}getMarker(t,e,r){return this._markers.has(t)?this._updateMarker(t,e,r):this._createMarker(t,e,r),`${t}_markerEnd`}_createMarker(t,e,r){let n=this._defs.append("marker").attr("stroke",e??"").attr("id",`${t}_markerEnd`).attr("fill",r??"").attr("viewBox","-4 -8 15 15").attr("refX",5).attr("refY",0).attr("markerWidth",4).attr("markerHeight",4).attr("orient","auto").style("stroke-width",1.5);n.append("path").attr("d","M0,-5L8.67,0L0,5Z"),this._markers.set(t,n)}_updateMarker(t,e,r){this._markers.get(t).attr("stroke",e??"").attr("fill",r??"").attr("markerWidth",4).attr("markerHeight",4)}};Pa.$inject=["defs"];var La=class extends Yr{constructor(t,e,r,n,i,o,s){super("node",void 0,e,r,i,o,s),this._iconLoader=n,this._init(t)}_createElement(t,e){let r=e,n=r.type??"default",{x:i,y:o}=r.position;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`),t.select(".innerElement").append("svg").attr("width",r.size??0).attr("height",r.size??0).attr("viewBox",this._iconLoader.getViewBox(n)).attr("preserveAspectRatio","xMaxYMax meet").append("use").attr("href",this._iconLoader.symbolHref(n))}_updateElement(t,e){let r=e,n=r.type??"default",{x:i,y:o}=r.position;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`),t.select(".innerElement").select("svg").attr("width",r.size??0).attr("height",r.size??0).attr("viewBox",this._iconLoader.getViewBox(n)).select("use").attr("href",this._iconLoader.symbolHref(n))}_drawContainer(){this._elementsContainer&&this._elementsContainer.remove(),this._elementsContainer=this._canvas.getDrawingLayer().insert("g",".label-group").attr("class",`${this._className}-group`)}};La.$inject=["d3polytree.definitions.node","canvas","eventBus","iconLoader","elementBuilder","elementRegistry","drawingRegistry"];var Ba='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect rx="8" ry="8" width="100" height="100" fill="#888"/></svg>';function Ra(){return{default:Ba}}Ra.$inject=[];var Ep="http://www.w3.org/2000/svg",Na="http://www.w3.org/1999/xlink",Np=["clip-path","fill","stroke","mask","filter","marker-start","marker-mid","marker-end"];function Mp(t,e){let r=new Map;if(t.querySelectorAll("[id]").forEach(i=>{let o=i.getAttribute("id"),s=`${e}_${o}`;r.set(o,s),i.setAttribute("id",s)}),r.size===0)return;let n=i=>i.replace(/#([^\s)'"]+)/g,(o,s)=>r.has(s)?`#${r.get(s)}`:o);t.querySelectorAll("*").forEach(i=>{let o=i.getAttributeNS(Na,"href");o&&o.includes("#")&&i.setAttributeNS(Na,"href",n(o));let s=i.getAttribute("href");s&&s.includes("#")&&i.setAttribute("href",n(s)),Np.forEach(a=>{let l=i.getAttribute(a);l&&l.includes("#")&&i.setAttribute(a,n(l))})})}var $a=class{constructor(t,e){this._viewBoxes={},this._icons={...t},this._defs=e,this._init()}_init(){this._icons.default||(this._icons.default=Ba);let t=this._defs.node();t&&Object.entries(this._icons).forEach(([e,r])=>{let i=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;if(!i||i.nodeName.toLowerCase()!=="svg")return;let o=i.getAttribute("viewBox")??"",s=document.createElementNS(Ep,"symbol");s.setAttribute("id",`${e}_icon_def`),o&&s.setAttribute("viewBox",o),Array.from(i.childNodes).forEach(a=>s.appendChild(document.importNode(a,!0))),Mp(s,e),t.appendChild(s),this._viewBoxes[e]=o})}hasIcon(t){return Object.prototype.hasOwnProperty.call(this._viewBoxes,t)}getViewBox(t){return this._viewBoxes[t]??this._viewBoxes.default??""}symbolHref(t){return`#${this.hasIcon(t)?t:"default"}_icon_def`}};$a.$inject=["icons","defs"];function za(t){return t.getSVG().append("defs")}za.$inject=["canvas"];var oe={__init__:["drawingRegistry"],drawingRegistry:["type",wp]},Oa={__init__:["defs"],defs:["factory",za]},Sp={icons:["factory",Ra]},kp={__init__:["iconLoader"],iconLoader:["type",$a],__depends__:[Sp,Oa]},Ye={__init__:["labels"],labels:["type",Aa],__depends__:[oe]},Kr={__init__:["zones"],zones:["type",Ca],__depends__:[oe,Ye]},Ap={__init__:["markers"],markers:["type",Pa],__depends__:[Oa]},yi={__init__:["links"],links:["type",Ta],__depends__:[oe,Ap]},_i={__init__:["nodes"],nodes:["type",La],__depends__:[oe,kp,Ye,Kr]},Cp={};xp(Cp,{add:()=>Ia,indexOf:()=>Pp,remove:()=>Tp});function Tp(t,e){if(!t||!e)return-1;let r=t.indexOf(e);return r!==-1&&t.splice(r,1),r}function Ia(t,e,r=-1){if(!t||!e)return;let n=t.indexOf(e);if(n!==-1){if(n===r)return;if(r!==-1)t.splice(n,1);else return}r!==-1?t.splice(r,0,e):t.push(e)}function Pp(t,e){return!t||!e?-1:t.indexOf(e)}function ht(t){return t.$descriptor.ns.localName.toLowerCase()}var Lp=["mouseenter","mouseover","mousedown","mouseup","click","dblclick","mouseleave","mouseout","contextmenu"],Da=class{constructor(t){this._eventBus=t,this._init()}_addListeners(t,e,r){let n=r??ht(e);Lp.forEach(i=>{t.on(i,o=>{this._eventBus.emit(`${n}.${i}`,t,e,o)})})}_init(){["label","link","node","zone"].forEach(t=>{this._eventBus.on(`${t}.created`,this._addListeners,this)})}};Da.$inject=["eventBus"];var Fa=class{constructor(t){this._currentSelection=new Map,this._eventBus=t,this._init()}_snapshot(){return[...this._currentSelection.values()]}_unSelectElement(t,e,r){let n=this._snapshot();this._currentSelection.delete(e.id),t.classed("selected",!1),r&&this._eventBus.emit("selection.changed",n,this._snapshot())}_selectElement(t,e,r){(!r||!r.ctrlKey)&&this._unSelectAllElements(!0),t.classed("selected",!0);let n=this._snapshot();this._currentSelection.set(e.id,{element:t,definition:e}),this._eventBus.emit("selection.changed",n,this._snapshot())}_unSelectAllElements(t){this._snapshot().forEach(e=>{this._unSelectElement(e.element,e.definition,!t)})}deleteSelected(){this._snapshot().forEach(t=>{this._unSelectElement(t.element,t.definition),this._eventBus.emit(`${ht(t.definition)}.deleted`,t.element,t.definition)})}getSelectedElements(){return this._snapshot()}select(t,e,r){this._selectElement(t,e,r)}_init(){["label","link","node","zone"].forEach(t=>{this._eventBus.on(`${t}.click`,this._selectElement,this)}),this._eventBus.on("background.click",this._unSelectAllElements,this)}};Fa.$inject=["eventBus"];var Bp=[.1,15],pi=1.2,Rp=1800,ja=class{constructor(t,e,r,n){this._isZoomable=!1,this._canvas=e,this._eventBus=r,this._options=t,this._calculateCenter=n;let i=t.get("offset"),o=i.get("x"),s=i.get("y"),a=t.get("scale");this._init(),this.setZoomable(!0),this.setInitialZoom(o,s,a),this.setZoomable(!1)}setZoom(t,e,r){if(this._eventBus.emit("zoom.preZoom",t,e,r),this._isZoomable){let i=t===void 0||e===void 0||r===void 0?this._canvas.getTransform():null,o=t??i.e,s=e??i.f,a=r??i.a;this._canvas.getDrawingLayer().attr("transform",`translate(${o}, ${s}) scale(${a})`),this._options.scale=a,this._options.offset&&(this._options.offset.x=o,this._options.offset.y=s),this._eventBus.emit("canvas.zoomed")}}setZoomable(t){this._isZoomable=t}isZoomable(){return this._isZoomable}setInitialZoom(t,e,r,n){let o=this._canvas.getDrawingLayer().node().parentNode,s=U(o),a=Lt.translate(t,e).scale(r);n?s.transition().duration(n).call(this._zoom.transform,a):s.call(this._zoom.transform,a)}_init(){let t=this._canvas.getDrawingLayer();this._zoom=Hn().scaleExtent(Bp).extent(()=>{let{width:e,height:r}=this._canvas.getSize();return[[0,0],[e,r]]}).on("start",()=>this._eventBus.emit("zoom.start")).on("zoom",e=>{if(!this._isZoomable)return;let{x:r,y:n,k:i}=e.transform;this.setZoom(r,n,i)}).on("end",()=>this._eventBus.emit("zoom.end")),t.on("click",e=>{U(e.target).classed("element-outline")||this._eventBus.emit("background.click")}),t=t.call(this._zoom).append("g"),this._canvas.setDrawingLayer(t),this._eventBus.on("zoom.to.element",(e,r)=>{let n=this._isZoomable,i=ht(r),o=this._calculateCenter.getCenterPosition(),s={x:0,y:0};if(this.setZoomable(!0),i==="node"){let a=r.position,l=r.size??0;s.x=1.5+a.x+l/2,s.y=1.5+a.y+l/2}else if(i==="link"){let a=r.waypoint,l=a.length-1;l>=0&&(s.x=a[l].x,s.y=a[l].y)}this.setInitialZoom(o.x-s.x*pi,o.y-s.y*pi,pi,Rp),this.setZoomable(n)}),this._eventBus.emit("zoom.init")}};ja.$inject=["d3polytree.definitions.settings.zoom","canvas","eventBus","calculateCenter"];var Ha=class{constructor(t){t.setZoomable(!0)}};Ha.$inject=["zoom"];var qa=class{constructor(t,e,r){this._bgRect=null,this._canvas=t,this._settings=e,this._eventBus=r,this._init()}setColor(t){this._bgRect&&(this._settings.backgroundColor=t,this._refill())}_refill(){this._bgRect?.attr("fill",this._settings.backgroundColor??"")}_init(){this._bgRect=this._canvas.getRootLayer().insert("rect",":first-child").attr("width","100%").attr("height","100%").attr("fill",this._settings.backgroundColor??""),this._eventBus.on("canvas.resized",()=>this._refill())}};qa.$inject=["canvas","d3polytree.definitions.settings","eventBus"];var Va=class{constructor(t,e,r,n){this._svg=null,this._x=null,this._y=null,this._xAxis=null,this._yAxis=null,this._gX=null,this._gY=null,this._options=t,this._isVisible=t.show??!0,this._canvas=e,this._eventBus=r,this._zoom=n,this._init()}setVisible(t){this._svg&&(this._isVisible=t,this._svg.style("display",t?"inline":"none"))}toggleVisible(){this._svg&&this.setVisible(!this._isVisible)}_init(){let t=!1;this._eventBus.on("zoom.start",()=>{this._zoom&&!this._zoom.isZoomable()||(t=this._isVisible,this.setVisible(!1))}),this._eventBus.on("zoom.end",()=>{t&&(this.setVisible(!0),this._rescale())}),this._draw(),this._rescale(),this.setVisible(this._options.show??!0)}_rescale(){if(!this._x||!this._y||!this._xAxis||!this._yAxis||!this._gX||!this._gY)return;let{width:t,height:e}=this._canvas.getSize(),r=this._canvas.getTransform(),n=r.a,i=this._options.size??1,o=Lt.translate(r.e,r.f).scale(n);this._x.domain([-1,t-1]).range([-1,t-1]),this._y.domain([-1,e-1]).range([-1,e-1]),this._gX.call(this._xAxis.scale(o.rescaleX(this._x)).ticks(t/n/i).tickSize(e)),this._gY.call(this._yAxis.scale(o.rescaleY(this._y)).ticks(e/n/i).tickSize(t));for(let s of[this._gX,this._gY])s.selectAll("line, path").style("stroke-width",String(this._options.lineWidth??1)).style("stroke",this._options.lineColor??"").style("stroke-dasharray","2")}_draw(){this._svg&&this._svg.remove(),this._svg=this._canvas.getRootLayer().insert("g",":first-child").attr("class","axis");let{width:t,height:e}=this._canvas.getSize();this._x=ge().domain([-1,t-1]).range([-1,t-1]),this._y=ge().domain([-1,e-1]).range([-1,e-1]),this._xAxis=li(this._x).tickFormat(()=>"").tickSize(e),this._yAxis=ai(this._y).tickFormat(()=>"").tickSize(t),this._gX=this._svg.append("g").call(this._xAxis),this._gY=this._svg.append("g").call(this._yAxis)}};Va.$inject=["d3polytree.definitions.settings.grid","canvas","eventBus","zoom"];var Zr=6,Ga=class{constructor(t){this._eventBus=t,this._init()}_computeBox(t,e){let r=ht(e);if(r==="link"){let o=e.waypoint??[];if(o.length>0){let s=o[0],a=o[o.length-1];return{x:Math.min(s.x,a.x),y:Math.min(s.y,a.y),width:Math.abs(a.x-s.x),height:Math.abs(a.y-s.y)}}return{x:0,y:0,width:0,height:0}}if(r==="node"){let o=Number(e.size??0);return{x:0,y:0,width:o,height:o}}let n=t.select(".innerElement").node(),i=n&&typeof n.getBBox=="function"?n.getBBox():{width:0,height:0};return{x:0,y:0,width:i.width,height:i.height}}_createOutline(t,e){let r=this._computeBox(t,e),n=t.insert("rect",":first-child").attr("class","element-outline").attr("x",r.x).attr("y",r.y).attr("fill","none").attr("stroke","red").attr("stroke-width",0).attr("stroke-dasharray","3").attr("width",r.width+Zr).attr("height",r.height+Zr);this._eventBus.emit("outline.created",t,e,n)}_updateOutline(t,e){let r=this._computeBox(t,e),n=t.select(".element-outline").attr("x",r.x).attr("y",r.y).attr("width",r.width+Zr).attr("height",r.height+Zr);this._eventBus.emit("outline.updated",t,e,n)}_init(){["node","label","zone","link"].forEach(t=>{this._eventBus.on(`${t}.created`,this._createOutline,this),this._eventBus.on(`${t}.updated`,this._updateOutline,this)})}};Ga.$inject=["eventBus"];var Ua=class{constructor(t,e,r,n){this._canvas=t,this._eventBus=e,this._drawingRegistry=r,this._selection=n,this._init()}applyOffsetToSelected(t,e){this._selection.getSelectedElements().forEach(r=>{if(ht(r.definition)==="link")return;this._applyOffset(r.element,r.definition,t,e);let n=r.definition.label;if(n){let i=this._drawingRegistry.get(n.id);i&&this._applyOffset(i,n,t,e)}})}notifyMovedSelected(){this._selection.getSelectedElements().forEach(t=>{ht(t.definition)!=="link"&&this._eventBus.emit(`${ht(t.definition)}.moved`,t.element,t.definition)})}_applyOffset(t,e,r,n){let i=Number(t.attr("x"))+r,o=Number(t.attr("y"))+n;t.attr("x",i).attr("y",o).attr("transform",`translate(${i},${o})`);let s=e.position;s.x=i,s.y=o,e.get("status")!==1&&e.set("status",2),this._eventBus.emit(`${ht(e)}.moving`,t,e)}_setElemToDrag(t,e){t.call(Be().on("start",r=>{this._selection.select(t,e,r.sourceEvent),this._canvas.getRootLayer().classed("no-drag")||r.on("drag",n=>this.applyOffsetToSelected(n.dx,n.dy)).on("end",()=>this.notifyMovedSelected())}))}_init(){this._eventBus.on("outline.created",(t,e)=>{ht(e)!=="link"&&this._setElemToDrag(t,e)})}};Ua.$inject=["canvas","eventBus","drawingRegistry","selection"];function Ma(t){let e=new TextEncoder().encode(t),r="";return e.forEach(n=>{r+=String.fromCharCode(n)}),btoa(r)}var Xa=class{constructor(t,e){this._canvas=t,this._host=e,this._exporter=this._createExporter()}async trigger(t){let e;if(t==="pfdn")e=this._encodeXml(this._host.exportDiagram());else if(t==="svg")e=this._encodeXml(this._host.exportSVG());else if(t==="png")e=await this._svgToImage(this._host.exportSVG());else{console.error("Format not supported");return}this._exporter.setAttribute("href",e),this._exporter.setAttribute("download",`diagram.${t}`),this._exporter.click()}_encodeXml(t){return`data:application/xml;base64,${Ma(t)}`}_svgToImage(t){return new Promise(e=>{let r=`data:image/svg+xml;base64,${Ma(t)}`,n=document.createElement("canvas"),i=n.getContext("2d"),o=this._canvas.getSVG().node()?.parentNode,s=o?.offsetWidth??0,a=o?.offsetHeight??0;n.width=s,n.height=a;let l=new Image;l.onload=()=>{i?.clearRect(0,0,s,a),i?.drawImage(l,0,0,s,a),e(n.toDataURL("image/png"))},l.src=r})}_createExporter(){let t=document.createElement("a");Object.assign(t.style,{width:"1px",height:"1px",display:"none",overflow:"hidden"});let e=this._canvas.getContainer();return e.insertBefore(t,e.firstChild),t}};Xa.$inject=["canvas","d3polytree"];var Sa="diagram",Za=class{constructor(t,e){this._host=t,this._notifications=e}loadSaved(){let t=this._read()??this._host.initialDiagram;t&&this._host.importDiagram(t)}save(){this._write(this._host.exportDiagram()),this._notifications.success({title:"Success",text:"Diagram saved"})}_read(){try{return window.localStorage.getItem(Sa)}catch{return null}}_write(t){try{window.localStorage.setItem(Sa,t)}catch{this._notifications.error({title:"Error",text:"Could not save the diagram"})}}};Za.$inject=["d3polytree","notifications"];var Wa=class{constructor(t,e){this._host=e,this._fileInput=this._createInput(t)}openDialog(){this._fileInput.click()}_createInput(t){let e=document.createElement("input");e.type="file",Object.assign(e.style,{width:"1px",height:"1px",display:"none",overflow:"hidden"});let r=t.getContainer();return r.insertBefore(e,r.firstChild),e.addEventListener("change",n=>{let i=n.target.files?.[0];this._openFile(i)}),e}_openFile(t){if(typeof FileReader>"u"){window.alert("Your browser does not support file upload. Try a modern browser.");return}if(!t)return;let e=new FileReader;e.onload=r=>{let n=r.target?.result;typeof n=="string"&&this._host.importDiagram(n)},e.readAsText(t)}};Wa.$inject=["canvas","d3polytree"];var di=16,hi=2.5+3,Wr=6,Ya=class{constructor(t,e){this._eventBus=t,this._canvas=e,this._init()}_createCorners(t,e,r){let n=Number(r.attr("width")),i=U(r.node().parentNode).append("g").attr("class","resize-container"),o=i.append("rect"),s=mi(i,"resize-drag-ne",n-2.5,-2.5),a=mi(i,"resize-drag-sw",-2.5,n-2.5),l=mi(i,"resize-drag-se",n-2.5,n-2.5),u=()=>{this._eventBus.emit("element.updated",e.id,e)},c=f=>{t.select(".innerElement").select("svg").attr("width",f).attr("height",f)};this._setCornerToDrag(s,f=>{let p=Q(f,a.node()),m=Math.max(di,p[0],p[1]*-1)-hi,T=Number(e.size);c(m);let A=Number(t.attr("y"))+T-m,O=Number(t.attr("x"));t.attr("y",A).attr("transform",`translate(${O},${A})`),e.size=m,e.position.y=A,this._updateOutlineAndCorners(r,i,m+Wr)},u),this._setCornerToDrag(a,f=>{let p=Q(f,s.node()),m=Math.max(di,p[0]*-1,p[1])-hi,T=Number(e.size);c(m);let A=Number(t.attr("x"))+T-m,O=Number(t.attr("y"));t.attr("x",A).attr("transform",`translate(${A},${O})`),e.size=m,e.position.x=A,this._updateOutlineAndCorners(r,i,m+Wr)},u),this._setCornerToDrag(l,f=>{let p=Q(f,o.node()),m=Math.max(di,p[0],p[1])-hi;e.size=m,c(m),this._updateOutlineAndCorners(r,i,m+Wr)},u)}_updateOutlineAndCorners(t,e,r){t.attr("width",r).attr("height",r),e.select(".resize-drag-ne").attr("x",r-2.5),e.select(".resize-drag-sw").attr("y",r-2.5),e.select(".resize-drag-se").attr("x",r-2.5).attr("y",r-2.5)}_setCornerToDrag(t,e,r){t.call(Be().on("start",n=>{this._canvas.getRootLayer().classed("no-drag")||n.on("drag",e).on("end",r)}))}_init(){this._eventBus.on("outline.created",(t,e,r)=>{e.$instanceOf("pfdn:Node")&&this._createCorners(t,e,r)}),this._eventBus.on("outline.updated",(t,e,r)=>{if(e.$instanceOf("pfdn:Node")){let n=t.select(".resize-container");this._updateOutlineAndCorners(r,n,Wr+Number(e.size))}})}};Ya.$inject=["eventBus","canvas"];function mi(t,e,r,n){return t.append("rect").attr("fill","none").attr("x",r).attr("y",n).attr("width",5).attr("height",5).attr("class",e)}var $p='More info about this project in <a href="https://github.com/davcs86/d3-polytree" target="_blank" rel="noopener">https://github.com/davcs86/d3-polytree</a>',zp=class{constructor(t,e){let r=document.createElement("div");r.className="noticePopup",t.getContainer().appendChild(r),r.addEventListener("click",()=>{e.notify({title:"D3-Polytree",text:$p,html:!0},"info")})}};zp.$inject=["canvas","notifications"];var Op="http://www.w3.org/2000/svg",Ip={error:"error",info:"info",success:"success",warning:"warning"},Dp={error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#D8000C"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M153.663 134.653l-35.265-32.672 35.265-32.67-16.566-15.345-35.265 32.67-35.265-32.67L50 69.31l35.265 32.67L50 134.654 66.567 150l35.265-32.67L137.097 150"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#1F75FE"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M114.605 39.133c-5.14 0-9.307 4.167-9.307 9.307 0 5.14 4.167 9.307 9.307 9.307 5.14 0 9.307-4.167 9.307-9.307 0-5.14-4.167-9.307-9.307-9.307zM103.22 63.106c-6.1.304-12.586 3.594-18.03 8.227l-.583 7.063c5.145-2.234 10.427-2.245 12.008 3.075 3.848 12.943-9.362 35.627-12.963 47.49-9.77 32.19 13.684 35.91 30.413 22.645l.665-7.644c-9.102 3.16-15.607-.716-10.346-17.533 2.535-8.112 23.754-48.99 9.1-60.245-3.07-2.356-6.603-3.256-10.263-3.074z"/></svg>',success:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#4BB543"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M150.003 52.712c-1.95-1.952-5.15-1.952-7.102 0l-62.994 63c-1.952 1.952-5.15 1.952-7.103 0l-15.516-15.515c-1.952-1.952-5.15-1.952-7.102 0l-9.516 9.52c-1.953 1.953-1.953 5.152 0 7.104l32.133 32.13c1.952 1.95 5.15 1.95 7.103 0l79.614-79.62c1.952-1.952 1.952-5.15 0-7.102z"/></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><g fill="#F8CA00"><circle cx="100" cy="100" r="100" fill="#fff"/><circle cx="100" cy="100" r="95"/><circle cx="100" cy="100" r="90" fill="#fff"/><circle cx="100" cy="100" r="87"/></g><path fill="#fff" d="M102.506 40.44c-7.136 0-12.922 5.786-12.922 12.923l2.585 51.687c0 5.71 4.626 10.338 10.335 10.338 5.71 0 10.338-4.63 10.338-10.338l2.584-51.687c0-7.137-5.785-12.922-12.922-12.922zm0 87.87c-8.564 0-15.506 6.94-15.506 15.505 0 8.563 6.942 15.506 15.506 15.506s15.507-6.942 15.507-15.505c0-8.564-6.943-15.507-15.507-15.507z"/></svg>'},Fp=class{constructor(t,e,r){this._viewBoxes={},this._alerts={},this._defs=t,this._notifications=e,this._drawingRegistry=r,this._buildSymbols()}showAlert(t,e,r){let n=this._drawingRegistry.get(t);if(!n)return;let i=Ip[r]??"info",o=this.getAlert(t);this._alerts[t]=o?this._updateAlert(o,e,i):this._createAlert(n,e,i)}getAlert(t){return this._alerts[t]}removeAlert(t){let e=this.getAlert(t);e&&(this._clearAlert(e),delete this._alerts[t])}clear(){Object.values(this._alerts).forEach(t=>this._clearAlert(t)),this._alerts={}}_clearAlert(t){t.element.select(".innerElement").classed("blink",!1),t.selection.on("mousedown",null),t.selection.remove()}_createAlert(t,e,r){let n=t.select(".innerElement").append("svg").attr("class","alertIcon").attr("x",-2).attr("y",-2).attr("width",10).attr("height",10).attr("preserveAspectRatio","xMaxYMax meet");n.append("use");let i={element:t,selection:n,message:e,type:r};return this._updateAlert(i,e,r)}_updateAlert(t,e,r){return t.selection.attr("viewBox",this._viewBoxes[r]??"").select("use").attr("href",`#${r}_alerticon_def`),t.message=e.replace(/(<([^>]+)>)/gi,""),t.type=r,t.selection.on("mousedown",()=>{this._notifications.notify({title:t.type,text:t.message},t.type)}),t.element.select(".innerElement").classed("blink",!0),t}_buildSymbols(){let t=this._defs.node();t&&Object.entries(Dp).forEach(([e,r])=>{let i=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;if(!i||i.nodeName.toLowerCase()!=="svg")return;let o=i.getAttribute("viewBox")??"",s=document.createElementNS(Op,"symbol");s.setAttribute("id",`${e}_alerticon_def`),o&&s.setAttribute("viewBox",o),Array.from(i.childNodes).forEach(a=>s.appendChild(document.importNode(a,!0))),t.appendChild(s),this._viewBoxes[e]=o})}};Fp.$inject=["defs","notifications","drawingRegistry"];var jp=.8,Hp=class{constructor(t,e,r){this._tip=null,typeof t=="function"&&(this._tip=document.createElement("div"),this._tip.className="d3-tip",this._tip.style.position="absolute",this._tip.style.display="none",document.body.appendChild(this._tip),r.on("node.mouseover",(n,i,o)=>{e.getTransform().a<jp&&this._show(t(i),o)}),r.on("node.mouseout",()=>this._hide()))}_show(t,e){if(!this._tip)return;this._tip.innerHTML=t,this._tip.style.display="block";let r=e;this._tip.style.left=`${r.pageX}px`,this._tip.style.top=`${r.pageY-10}px`}_hide(){this._tip&&(this._tip.style.display="none")}};Hp.$inject=["d3polytree.options.tooltip","canvas","eventBus"];var Ka=class{constructor(t,e,r,n,i){this._className=t,this._drawingRegistry=e,this._selection=r,this._canvas=n,this._modelling=i}_getElemOfReference(){let t=this._drawingRegistry.getAll();return t.length>0?U(t[0].node()):this._canvas.getDrawingLayer()}_calculatePosition(){let t=this._getElemOfReference(),e=this._canvas.getContainer().getBoundingClientRect(),r=t.node().getBoundingClientRect(),n=this._canvas.getTransform(t),i=this._canvas.getTransform(),o=n.e,s=n.f,a=i.a||1;return{x:-1*(r.left-o*a-(e.left+e.width/2))/a,y:-1*(r.top-s*a-(e.top+e.height/2))/a}}_create(t){return this._modelling.doAction(this._className,"create",[t])}append(t={}){t.position=this._calculatePosition();let e=this._create(t),r=this._drawingRegistry.get(e.id);return r&&this._selection.select(r,e,{}),e}},Qa=class extends Ka{constructor(t,e,r,n){super("node",t,e,r,n)}};Qa.$inject=["drawingRegistry","selection","canvas","modelling"];var Ja=class extends Ka{constructor(t,e,r,n){super("label",t,e,r,n)}};Ja.$inject=["drawingRegistry","selection","canvas","modelling"];var tl=class{constructor(t,e,r){this.active=!1,this._selectedNodes=[],this._eventBus=t,this._canvas=e,this._modelling=r,this._fakeLink=this._canvas.getDrawingLayer().insert("path",".node-group").attr("class","fake-link").attr("d","M0,0L0,0").style("stroke","black").style("fill","none")}activate(){this.active=!0,this._selectedNodes=[],this._canvas.getRootLayer().classed("no-drag",!0).classed("cursor-add-link",!0),this._registerMouseMove(),this._registerNodeClick()}deactivate(){this.active=!1,this._canvas.getRootLayer().classed("no-drag",!1).classed("cursor-add-link",!1),this._resetFakeLink()}_registerNodeClick(){this._eventBus.once("node.click",(t,e,r)=>{if(!this.active)return;r.stopImmediatePropagation();let n=this._selectedNodes;(n.length===0||n.length===1&&n[0].element!==t)&&n.push({element:t,definition:e}),n.length===2?(this._appendLink(),this.deactivate()):(n.length===1&&this._showFakeLink(),this._registerNodeClick())})}_registerMouseMove(){this._canvas.getRootLayer().on("mousemove",t=>{if(!this.active||this._selectedNodes.length!==1)return;let e=this._selectedNodes[0].definition,r=e.position,n=e.size??0,i=this._canvas.getDrawingLayer().node(),[o,s]=Q(t,i),a=r.x+n/2,l=r.y+n/2;this._fakeLink.attr("d",`M${a},${l}L${o},${s}`)})}_showFakeLink(){let t=this._selectedNodes[0].definition.position;this._fakeLink.attr("d",`M${t.x},${t.y}L${t.x},${t.y}`)}_resetFakeLink(){this._fakeLink.attr("d","M0,0L0,0")}_appendLink(){this._modelling.doAction("link","create",[this._selectedNodes[0].definition,this._selectedNodes[1].definition])}};tl.$inject=["eventBus","canvas","modelling"];var el=class{constructor(t,e,r,n,i,o,s,a,l,u,c){this._host=t,this._localStorage=r,this._upload=n,this._exporting=i,this._axes=o,this._selection=s,this._addNodeHandler=a,this._addLabelHandler=l,this._notifications=c,this._tools={addLinkTool:u}}getPaletteTools(){return this._tools}getPaletteEntries(){return{new:{title:"New diagram",group:"file-ops",iconClassName:"icon-doc",action:{click:()=>{this._notifications.warning({title:"Are you sure?",text:"All current progress will be unrecoverable."},t=>{t&&this._host.createDiagram()})}}},save:{title:"Save diagram",group:"file-ops",iconClassName:"icon-floppy",action:{click:()=>this._localStorage.save()}},open:{title:"Open diagram",group:"file-ops",iconClassName:"icon-folder-open-empty",action:{click:()=>this._upload.openDialog()}},download:{title:"Download diagram",group:"file-ops",iconClassName:"icon-download",action:{click:()=>{this._exporting.trigger("pfdn")}}},"export-svg":{title:"Download as SVG image",group:"file-export",iconClassName:"icon-file-code",action:{click:()=>{this._exporting.trigger("svg")}}},"export-png":{title:"Download as PNG image",group:"file-export",iconClassName:"icon-image",action:{click:()=>{this._exporting.trigger("png")}}},"new-connection":{title:"New connection",group:"drawing",iconClassName:"icon-arrow",action:{click:()=>this._tools.addLinkTool.activate()}},"new-label":{title:"New label",group:"drawing",iconClassName:"icon-text",action:{click:()=>this._addLabelHandler.append()}},"new-node":{title:"New node",group:"drawing",iconClassName:"icon-check-empty",action:{click:()=>this._addNodeHandler.append()}},"delete-item":{title:"Delete selected item(s)",group:"utils",iconClassName:"icon-trash",action:{click:()=>this._selection.deleteSelected()}},"toggle-grid":{title:"Show/hide grid",group:"settings",iconClassName:"icon-grid",action:{click:()=>this._axes.toggleVisible()}}}}};el.$inject=["d3polytree","eventBus","localStorage","upload","exporting","axes","selection","addNodeHandler","addLabelHandler","addLinkTool","notifications"];function gi(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var vi=class rl{constructor(e,r){this._actions={},this._canvas=e,this._paletteProvider=r,this._init()}trigger(e,r,n){this._deactivateTools();let i=n??r.target.closest(".pfdjs-entry");if(!i)return;let o=this._actions[i.getAttribute("data-action")??""];if(!o)return;let s=o.action;typeof s=="function"?e==="click"&&s(r):s[e]?.(r)}getContainer(){return this._paletteContainer}_deactivateTools(){let e=this._paletteProvider.getPaletteTools();Object.values(e).forEach(r=>r.deactivate())}_drawContainer(){this._paletteContainer=gi(rl.HTML_MARKUP);let e=this._canvas.getContainer();e.insertBefore(this._paletteContainer,e.firstChild),this._entriesContainer=this._paletteContainer.querySelector(".pfdjs-entries")}_drawEntry(e,r){let n=e.group??"default",i=this._entriesContainer.querySelector(`[data-group="${n}"]`);i||(i=gi(`<div class="pfdjs-entries-group" data-group="${n}"></div>`),this._entriesContainer.appendChild(i));let o=gi(e.html??'<div class="pfdjs-entry"></div>');if(i.appendChild(o),o.setAttribute("data-action",r),e.title&&o.setAttribute("title",e.title),e.className&&o.classList.add(e.className),e.iconClassName){let s=document.createElement("span");s.className=e.iconClassName,o.appendChild(s)}}_drawEntries(){this._actions=this._paletteProvider.getPaletteEntries(),Object.entries(this._actions).forEach(([e,r])=>this._drawEntry(r,e))}_createDelegates(){this._paletteContainer.addEventListener("click",e=>{let r=e.target.closest(".pfdjs-entry");r&&(this.trigger("click",e,r),e.stopImmediatePropagation())}),this._paletteContainer.addEventListener("mousedown",()=>this._deactivateTools())}_init(){this._drawContainer(),this._drawEntries(),this._createDelegates()}};vi.$inject=["canvas","paletteProvider"];vi.HTML_MARKUP='<div class="pfdjs-palette"><div class="pfdjs-entries"></div></div>';var qp=vi,Vp=class{info(t,e){this.notify(t,"info",e)}success(t,e){this.notify(t,"success",e)}warning(t,e){this.notify(t,"warning",e)}error(t,e){this.notify(t,"error",e)}notify(t,e,r){let n=[e.toUpperCase(),t.title,t.text].filter(Boolean).join(": ");(e==="error"?console.error:e==="warning"?console.warn:console.info).call(console,n),r?.(!1)}},Ke={__init__:["notifications"],notifications:["type",Vp]},Qr=class{constructor(t,e,r,n,i){this._definitions=t,this._drawer=e,this._drawingRegistry=r,this._notifications=n,this._eventBus=i}reconcile(t,e){this._drawer.reconcile(t,e)}saveToModel(t,e){let r=ht(e);Ia(this._definitions.get(r),e)}delete(t,e){let r=ht(e);if(r==="label"&&e.isReadOnly===!0){this._notifications.error({title:"Not allowed!",text:"You can't delete an associated label, you should remove the main element"});return}let n=e.get("label");if(r!=="label"&&n&&n.$instanceOf("pfdn:Label")){n.isReadOnly=!1;let i=this._drawingRegistry.get(n.id);this._eventBus.emit("label.deleted",i,n)}e.set("status",3),this._drawer.reconcile(e.id,void 0)}},nl=class extends Qr{constructor(t,e,r,n,i,o){super(t,o,r,n,i),this._moddle=e}create(t={}){let e=t.position??{x:0,y:0},r=this._moddle.create("pfdn:Coordinates",{x:e.x,y:e.y}),n=this._moddle.create("pfdn:Label",{position:r,status:1});return this._drawer.reconcile(n.id,n),n.text=n.id,this._drawer.reconcile(n.id,n),n}};nl.$inject=["d3polytree.definitions","d3polytree.moddle","drawingRegistry","notifications","eventBus","labels"];var il=class extends Qr{constructor(t,e,r,n,i){super(t,i,e,r,n)}create(){return null}};il.$inject=["d3polytree.definitions","drawingRegistry","notifications","eventBus","zones"];var Gp=15,ol=class extends Qr{constructor(t,e,r,n,i,o,s){super(t,o,r,n,i),this._moddle=e,this._modellingLabels=s}create(t={}){let e=t.type??"default",r=t.position??{x:0,y:0},n=this._moddle.create("pfdn:Coordinates",{x:r.x,y:r.y}),i=this._moddle.create("pfdn:Node",{type:e,position:n,status:1});this._drawer.reconcile(i.id,i);let o=i.position,s=i.size??0,a=this._modellingLabels.create({position:{x:o.x,y:o.y+s+Gp}});return a.text=i.id,a.isReadOnly=!0,i.label=a,this._modellingLabels.reconcile(a.id,a),i}};ol.$inject=["d3polytree.definitions","d3polytree.moddle","drawingRegistry","notifications","eventBus","nodes","modellingLabels"];var jt=80,ka=20,sl=class extends Qr{constructor(t,e,r,n,i,o,s){super(t,r,i,o,n),this._routing=new Map,this._moddle=e,this._modellingLabels=s,this.init()}init(){this._eventBus.on("node.moved",this.updateNodeLinks,this),this._eventBus.on("node.updated",this.updateNodeLinks,this)}create(t,e){let r=t.position,n=e.position,i=t.size??0,o=e.size??0,s=r.x+i/2,a=r.y+i/2,l=n.x+o/2,u=n.y+o/2,c=this._createWaypoint(s,a),f=this._createWaypoint(l,u),p=this._moddle.create("pfdn:Link",{source:t,target:e,waypoint:[c,f],status:1});this._drawer.reconcile(p.id,p),this.updateNodeLinks(void 0,p.target),this.updateNodeLinks(void 0,p.source);let m=this._modellingLabels.create({position:{x:(c.x+f.x)/2,y:(c.y+f.y)/2}});return m.text=p.id,m.isReadOnly=!0,p.label=m,this._modellingLabels.reconcile(m.id,m),p}updateNodeLinks(t,e){let r=this._fillPredAndSuc(e);r.predecessors.forEach(n=>this._updateLink(n)),r.successors.forEach(n=>this._updateLink(n))}get _links(){return this._drawer}_createWaypoint(t,e){return this._moddle.create("pfdn:Coordinates",{x:t,y:e})}_calculateAngle(t,e){let r=t.x*e.x+t.y*e.y,n=Math.sqrt(t.x**2+t.y**2),i=Math.sqrt(e.x**2+e.y**2);return Math.acos(r/(n*i))}_sortSide(t,e,r){let n={x:1,y:1},i=1;return e===0?n.x=-1:e===1?i=-1:e===2?(n.y=-1,i=-1):e===3&&(n.x=-1,n.y=-1),[...t].sort((o,s)=>{let a=l=>{let u={x:l.pos.x-r.x,y:l.pos.y-r.y};return i*this._calculateAngle(n,u)};return a(o)-a(s)})}_setQuadrants(t,e,r,n,i){let o=!1,s=Math.abs(r.x-e.x),a=Math.abs(r.y-e.y);r.x>=e.x&&r.y>=e.y?s>=a?(o=3,i&&a>jt&&(o=0)):(o=0,i&&s>jt&&(o=3)):r.x<e.x&&r.y>=e.y?s>=a?(o=1,i&&a>jt&&(o=0)):(o=0,i&&s>jt&&(o=1)):r.x>=e.x&&r.y<e.y?s>=a?(o=3,i&&a>jt&&(o=2)):(o=2,i&&s>jt&&(o=3)):r.x<e.x&&r.y<e.y&&(s>=a?(o=1,i&&a>jt&&(o=2)):(o=2,i&&s>jt&&(o=1))),o!==!1&&(t[o].push({obj:n,pos:e}),t[o]=this._sortSide(t[o],o,r))}_setSideConnectors(t,e){let r=[[],[],[],[]];if(!this._drawingRegistry.get(t.id))return;let i=this._fillPredAndSuc(t),o=t.position;i.predecessors.forEach(s=>{let a=s.source;a&&this._setQuadrants(r,a.position,o,a.id,e)}),i.successors.forEach(s=>{let a=s.target;a&&this._setQuadrants(r,a.position,o,a.id,!1)}),i.sides=r}_updateLink(t){let e=t.source,r=t.target;if(!e||!r){console.error(`Link #${t.id} should have valid source and target.`);return}this._setSideConnectors(e,!1),this._setSideConnectors(r,!0);let n=this._routing.get(e.id),i=this._routing.get(r.id);if(!n||!i)return;let o=e.position,s=r.position,a={x:o.x,y:o.y},l={x:s.x,y:s.y},u={idx:0},c={idx:0},f=[],p=!1,m=!1;if(this._adjustSidePoint(a,n.sides,r.id,e.size??0,u),this._adjustSidePoint(l,i.sides,e.id,r.size??0,c),f.push(this._createWaypoint(a.x,a.y)),u.idx===1||u.idx===3){if(c.idx===0||c.idx===2)p={x:l.x,y:a.y};else if(Math.abs(a.y-l.y)>ka){let T={x:(l.x+a.x)/2,y:(l.y+a.y)/2};p={x:T.x,y:a.y},m={x:T.x,y:l.y}}}else if(c.idx===1||c.idx===3)p={x:a.x,y:l.y};else if(Math.abs(a.x-l.x)>ka){let T={x:(l.x+a.x)/2,y:(l.y+a.y)/2};p={x:a.x,y:T.y},m={x:l.x,y:T.y}}p!==!1&&f.push(this._createWaypoint(p.x,p.y)),m!==!1&&f.push(this._createWaypoint(m.x,m.y)),f.push(this._createWaypoint(l.x,l.y)),t.waypoint=f,this._links.reconcile(t.id,t)}_adjustSidePoint(t,e,r,n,i){let o=!1,s=n*1;e.forEach((a,l)=>{let u=a.length;if(o||u===0)return;let c=s*.8/(u+1),f=s/2-c*(u+1)/2;a.forEach(p=>{f+=c,p.obj===r&&(i.idx=l,l===0?(t.x+=f,t.y-=5):l===1?(t.x+=s+5,t.y+=f):l===2?(t.x+=f,t.y+=s+5):l===3&&(t.x-=5,t.y+=f),o=!0)})})}_fillPredAndSuc(t){let e=[],r=[];this._links.getAll().forEach(o=>{o.target===t&&e.push(o),o.source===t&&r.push(o)});let n=this._routing.get(t.id),i={predecessors:e,successors:r,sides:n?n.sides:[[],[],[],[]]};return this._routing.set(t.id,i),i}};sl.$inject=["d3polytree.definitions","d3polytree.moddle","links","eventBus","drawingRegistry","notifications","modellingLabels"];var al=class{constructor(t,e,r,n,i,o){this._eventBus=t,this._elements={label:n,node:r,zone:i,link:o},this._init()}doAction(t,e,r){let n=this._elements[t];if(n){let i=n[e];if(i)return i.apply(n,r)}return null}_init(){let t=(e,r,n)=>{this._eventBus.on(e,(...i)=>this.doAction(r,n,i))};t("label.created","label","saveToModel"),t("link.created","link","saveToModel"),t("node.created","node","saveToModel"),t("zone.created","zone","saveToModel"),t("label.deleted","label","delete"),t("link.deleted","link","delete"),t("node.deleted","node","delete"),t("zone.deleted","zone","delete"),this._eventBus.on("element.updated",(e,r)=>{let n=ht(r),i=this._elements[n];i&&i.reconcile(e,r)})}};al.$inject=["eventBus","d3polytree.definitions","modellingNodes","modellingLabels","modellingZones","modellingLinks"];var xi={__init__:["modellingLabels"],modellingLabels:["type",nl],__depends__:[Ye,Ke]},Up={__init__:["modellingZones"],modellingZones:["type",il],__depends__:[Kr,Ke]},Xp={__init__:["modellingNodes"],modellingNodes:["type",ol],__depends__:[_i,xi,Ke]},Zp={__init__:["modellingLinks"],modellingLinks:["type",sl],__depends__:[yi,xi,Ke]},Qe={__init__:["modelling"],modelling:["type",al],__depends__:[xi,Zp,Xp,Up]},ll=class{constructor(t){this._canvas=t}getCenterPosition(){let t=this._canvas.getSVG().node().getBoundingClientRect(),e=this._canvas.getTransform();return{x:t.width/2,y:t.height/2,s:e.a}}};ll.$inject=["canvas"];var Wp={__init__:["calculateCenter"],calculateCenter:["type",ll]},wi={__init__:["mouseEvents"],mouseEvents:["type",Da]},ye={__init__:["selection"],selection:["type",Fa],__depends__:[wi]},Jr={__init__:["zoom"],zoom:["type",ja],__depends__:[Wp]},ul={__init__:["zoomScroll"],zoomScroll:["type",Ha],__depends__:[Jr]},cl={__init__:["backgroundColor"],backgroundColor:["type",qa]},bi={__init__:["axes"],axes:["type",Va],__depends__:[Jr]},tn={__init__:["outline"],outline:["type",Ga]},fl={__init__:["drag"],drag:["type",Ua],__depends__:[tn,ye,oe]},Ei={__init__:["exporting"],exporting:["type",Xa]},Ni={__init__:["localStorage"],localStorage:["type",Za]},Mi={__init__:["upload"],upload:["type",Wa]},Yp={__init__:["addNodeHandler"],addNodeHandler:["type",Qa],__depends__:[oe,ye,Qe]},Kp={__init__:["addLabelHandler"],addLabelHandler:["type",Ja],__depends__:[oe,ye,Qe]},Qp={__init__:["addLinkTool"],addLinkTool:["type",tl],__depends__:[Qe]},Jp={__init__:["paletteProvider"],paletteProvider:["type",el],__depends__:[Yp,Kp,Qp,Ni,Mi,Ei,bi,ye,Ke]},pl={__init__:["palette"],palette:["type",qp],__depends__:[Jp]},dl={__init__:["resizeElement"],resizeElement:["type",Ya],__depends__:[tn]};function td(t){let e=[],r=[],n=o=>{e.includes(o)||((o.__depends__??[]).forEach(n),!e.includes(o)&&(e.push(o),(o.__init__??[]).forEach(s=>r.push(s))))};t.forEach(n);let i=new fi(e);return r.forEach(o=>i.get(o)),i}function ed(t){let r=[{config:["value",t]},Lo,...t.modules??[]];return td(r)}var hl=class{constructor(t={},e){this.injector=e??ed(t),this.get("eventBus").emit("d3canvas.init")}get(t,e){return this.injector.get(t,e)}destroy(){this.get("eventBus").emit("d3canvas.destroy")}clear(){this.get("eventBus").emit("d3canvas.clear")}};function ml(t,e){let r=t.settings;r||(r=e.create("pfdn:Settings",{}),t.settings=r);let n=r.zoom;return n?n.offset||(n.offset=e.create("pfdn:Coordinates",{x:0,y:0})):r.zoom=e.create("pfdn:Zoom",{offset:e.create("pfdn:Coordinates",{x:0,y:0}),scale:1}),r.grid||(r.grid=e.create("pfdn:Grid",{})),t}function gl(){let t=An();return{definitions:ml(t.create("pfdn:Diagram",{}),t),moddle:t}}async function yl(t){let e=An(),{rootElement:r}=await e.fromXML(t,"pfdn:Diagram");return{definitions:ml(r,e),moddle:e}}var _l=class vl{constructor(e={}){this.definitions=null,this.moddle=null,this._diagram=null,this._host=null,this.options=e}getModules(){return vl.modules}async importDiagram(e){this._boot(await yl(e))}createEmpty(){this._boot(gl())}getHost(){return this._host}exportDiagram(){if(!this.moddle||!this.definitions)throw new Error("no diagram loaded");return this.moddle.toXML(this.definitions)}exportSVG(){return this.get("canvas").getSVGStr()}get(e,r){if(!this._diagram)throw new Error("no diagram loaded");return this._diagram.get(e,r)}destroy(){this._diagram?.destroy(),this._diagram=null,this._host=null,this.definitions=null,this.moddle=null}_boot(e){this._diagram&&this.destroy(),this._host=e,this.definitions=e.definitions,this.moddle=e.moddle,this._diagram=new hl({container:this.options.container,modules:[...this.getModules(),...this.options.modules??[],{d3polytree:["value",this]}]})}};_l.modules=[Ye,Kr,yi,_i];var Je=_l;function Si(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var ki=class xl{constructor(e,r,n){this._actions=[],this._canvas=e,this._sideTabsProvider=r,this._eventBus=n,this._init()}trigger(e,r,n){let i=r?r.getAttribute("data-action")??void 0:n;if(i===void 0)return;let o=this._actions[Number(i)];if(!o)return;e==="click"?this._readjustTabs(i):e==="close"&&this._readjustTabs();let s=this._contentsEl.querySelector(`.pfdjs-st-content[data-action="${i}"] > .content-body`),a=o.action;typeof a=="function"?e==="click"&&a(s):a[e]?.(s)}_readjustTabs(e){e===void 0?this._container.classList.remove("open"):this._container.classList.add("open"),this._actions.forEach((r,n)=>{let i=this._tabsEl.querySelector(`[data-action="${n}"]`),o=this._contentsEl.querySelector(`.pfdjs-st-content[data-action="${n}"]`),s=String(n)===e;i?.classList.toggle("active",s),o?.classList.toggle("hidden",!s)})}_drawContainer(){this._container=Si(xl.HTML_MARKUP);let e=this._canvas.getContainer();e.insertBefore(this._container,e.firstChild),this._tabsEl=this._container.querySelector(".pfdjs-st-tabs"),this._contentsEl=this._container.querySelector(".pfdjs-st-contents")}_drawEntry(e,r){let n=Si('<div class="pfdjs-st-tab"></div>');if(this._tabsEl.appendChild(n),n.setAttribute("data-action",String(r)),e.title&&n.setAttribute("title",e.title),e.iconClassName){let o=document.createElement("span");o.className=e.iconClassName,n.appendChild(o)}let i=Si(`<div class="pfdjs-st-content hidden"><div class="content-title"><span class="content-title-span">${e.title??""}</span><span class="icon-cancel" title="Close"></span><span>&nbsp;</span></div><div class="content-body"></div></div>`);this._contentsEl.appendChild(i),i.setAttribute("data-action",String(r)),i.querySelector(".icon-cancel")?.setAttribute("data-action",String(r)),this.trigger("created",null,String(r))}_drawEntries(){this._actions=this._sideTabsProvider.getSideTabsEntries(),this._actions.forEach((e,r)=>this._drawEntry(e,r))}_update(){this._tabsEl&&(this._tabsEl.replaceChildren(),this._contentsEl.replaceChildren()),this._drawEntries()}_createDelegates(){this._tabsEl.addEventListener("click",e=>{let r=e.target.closest(".pfdjs-st-tab");r&&(this.trigger("click",r),e.stopImmediatePropagation())}),this._contentsEl.addEventListener("click",e=>{let r=e.target.closest(".icon-cancel");r&&(this.trigger("close",r),e.stopImmediatePropagation())})}_init(){this._drawContainer(),this._update(),this._eventBus.on("sidetab.registered",()=>this._update()),this._createDelegates()}};ki.$inject=["canvas","sideTabsProvider","eventBus"];ki.HTML_MARKUP='<div class="pfdjs-st-container"><div class="pfdjs-st-tabs"></div><div class="pfdjs-st-contents"></div></div>';var rd=ki,wl=class{constructor(t){this._registeredSideTabs=[],this._eventBus=t}registerSideTab(t,e){e===void 0?this._registeredSideTabs.push(t):this._registeredSideTabs.splice(e,0,t),this._eventBus.emit("sidetab.registered",t)}getSideTabsEntries(){return this._registeredSideTabs}};wl.$inject=["eventBus"];var nd={__init__:["sideTabs","sideTabsProvider"],sideTabs:["type",rd],sideTabsProvider:["type",wl]},bl=class{constructor(t,e){this._items=new Map,this._searchInput=null,this._listEl=null,this._eventBus=e,this._registerSideTab(t),this._init()}addOrUpdateItem(t){t.name&&(this._items.set(t.id,t),this._render())}removeItem(t){this._items.delete(t)&&this._render()}_init(){this._eventBus.on("node.created",(t,e)=>{this.addOrUpdateItem(this._toItem(t,e,"Node",e.type??""))}),this._eventBus.on("link.created",(t,e)=>{this.addOrUpdateItem(this._toItem(t,e,"Connection",""))}),this._eventBus.on("node.deleted",(t,e)=>{this.removeItem(e.id)}),this._eventBus.on("link.deleted",(t,e)=>{this.removeItem(e.id)})}_toItem(t,e,r,n){return{id:e.id,name:e.label?.text??"",elementType:r,elementSubType:n,element:t,definition:e}}_drawForm(t){if(!t)return;t.replaceChildren();let e=document.createElement("div");e.id="pfdjs-searchpanel",this._searchInput=document.createElement("input"),this._searchInput.className="search",this._searchInput.placeholder="Search",this._listEl=document.createElement("ul"),this._listEl.className="list",e.append(this._searchInput,this._listEl),t.appendChild(e),this._searchInput.addEventListener("input",()=>this._render()),this._listEl.addEventListener("click",r=>{let n=r.target.closest("li[data-id]");n&&(this._activate(n.getAttribute("data-id")??""),r.stopImmediatePropagation())}),this._render()}_activate(t){let e=this._items.get(t);if(!e)return;this._eventBus.emit("zoom.to.element",e.element,e.definition);let r=`${e.definition.$descriptor.ns.localName.toLowerCase()}.click`;this._eventBus.emit(r,e.element,e.definition,null)}_render(){if(!this._listEl)return;let t=(this._searchInput?.value??"").trim().toLowerCase(),e=[...this._items.values()].filter(r=>!t||r.name.toLowerCase().includes(t)).sort((r,n)=>r.name.localeCompare(n.name));this._listEl.replaceChildren();for(let r of e){let n=document.createElement("li");n.setAttribute("data-id",r.id),n.innerHTML='<h3 class="name"></h3><p><span class="elementType"></span>&nbsp;&nbsp;<span class="elementSubType"></span></p>',n.querySelector(".name").textContent=r.name,n.querySelector(".elementType").textContent=r.elementType,n.querySelector(".elementSubType").textContent=r.elementSubType,this._listEl.appendChild(n)}}_registerSideTab(t){t.registerSideTab({title:"Search element",iconClassName:"icon-glass",action:{created:e=>this._drawForm(e),click:()=>this._render()}},0)}};bl.$inject=["sideTabsProvider","eventBus"];var id={__init__:["searchPanel"],searchPanel:["type",bl]},El=class Nl extends Je{getModules(){return[...Nl.interactionModules,...Je.modules]}};El.interactionModules=[cl,Jr,ul,bi,wi,ye,tn,nd,id];var Ai=El;function ut(t,e){return t.$instanceOf(e)}function _e(t,e){return e.split(".").reduce((r,n)=>r?.[n],t)}function en(t,e,r){let n=e.split("."),i=t;for(let o=0;o<n.length-1;o+=1){let s=n[o];(i[s]==null||typeof i[s]!="object")&&(i[s]={}),i=i[s]}i[n[n.length-1]]=r}function Ml(t,e){let r;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>t(...n),e)}}function Sl(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([a-zA-Z])([0-9])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function kl(t){return typeof t=="string"&&/^#[0-9a-fA-F]{6}$/.test(t)}function Al(t){if(!t)throw new Error(`${t} must be set.`);return t}var ve=class{constructor(e){this._eventBus=e}setDefaultParameters(e){let r=this._eventBus;return{html:"",description:"",get:(s,a)=>{let l=Al(e.modelProperty),u=_e(s,l),c=a.querySelector("input");c&&(c.value=u==null?"":String(u))},set:(s,a)=>{let l=Al(e.modelProperty);return en(s,l,_e(a,l)),!0},validate:()=>({}),...e,triggerUpdate:(s,a)=>{r.emit("PropertiesPanel.propertyChanged",s,a)}}}textField(e){return od(this.setDefaultParameters(e))}selectBox(e){return sd(this.setDefaultParameters(e))}colorPicker(e){return ad(this.setDefaultParameters(e))}spreadsheet(e){return this.setDefaultParameters(e)}};ve.$inject=["eventBus"];function Ci(t,e){let r=t.label??t.id;return`<div class="pfdjs-pp-field-wrapper"><label for="pfdjs-${t.id}">${r}</label>${e}</div>`}function od(t){let e=t.type??"text";return t.html=Ci(t,`<input id="pfdjs-${t.id}" type="${e}" name="${t.modelProperty}" />`),t}function sd(t){let e=t.allowEmpty??!0,n=(Array.isArray(t.selectOptions)?t.selectOptions.concat(e?[{name:"",value:""}]:[]):[{name:"",value:""}]).map(i=>`<option value="${i.value}">${i.name}</option>`).join("");return t.html=Ci(t,`<select id="pfdjs-${t.id}" name="${t.modelProperty}">${n}</select>`),t.get=(i,o)=>{let s=i.get(t.modelProperty)??"default";o.querySelectorAll(`select#pfdjs-${t.id} > option`).forEach(a=>{a.selected=a.value===s})},t}function ad(t){return t.html=Ci(t,`<input id="pfdjs-${t.id}" type="color" name="${t.modelProperty}" />`),t.get=(e,r)=>{let n=r.querySelector("input[type=color]"),i=_e(e,t.modelProperty);n&&kl(i)&&(n.value=i)},t}var rn={__init__:["entryFactory"],entryFactory:["type",ve]};function ld(t,e,r){ut(e,"pfdn:Node")?(t.entries.push(r.textField({id:"name",label:"Name",modelProperty:"name"})),t.entries.push(r.textField({id:"tag",label:"Tag",modelProperty:"tag"})),t.entries.push(r.textField({id:"label.text",label:"Diagram label",modelProperty:"label.text"}))):ut(e,"pfdn:Settings")?(t.entries.push(r.textField({id:"name",label:"Diagram name",modelProperty:"name"})),t.entries.push(r.textField({id:"author",label:"Author's name",modelProperty:"author"}))):ut(e,"pfdn:Link")?t.entries.push(r.textField({id:"label.text",label:"Diagram label",modelProperty:"label.text"})):ut(e,"pfdn:Label")&&t.entries.push(r.textField({id:"text",label:"Label",modelProperty:"text"}))}function ud(t,e,r,n){if(!ut(e,"pfdn:Node"))return;let i=Object.keys(n).map(o=>({value:o,name:Sl(o)}));t.entries.push(r.selectBox({id:"type",label:"Icon",modelProperty:"type",allowEmpty:!1,selectOptions:i})),t.entries.push(r.textField({id:"size",label:"Size",modelProperty:"size",type:"number"}))}function cd(t,e,r){ut(e,"pfdn:Link")&&(t.entries.push(r.textField({id:"lineWidth",label:"Line width",modelProperty:"lineWidth",type:"number"})),t.entries.push(r.colorPicker({id:"lineColor",label:"Line color",modelProperty:"lineColor"})))}function fd(t,e,r){ut(e,"pfdn:Node")||ut(e,"pfdn:Link")?(t.entries.push(r.textField({id:"label.fontSize",label:"Font size",modelProperty:"label.fontSize",type:"number"})),t.entries.push(r.colorPicker({id:"label.color",label:"Color",modelProperty:"label.color"}))):ut(e,"pfdn:Label")&&(t.entries.push(r.textField({id:"fontSize",label:"Font size",modelProperty:"fontSize",type:"number"})),t.entries.push(r.colorPicker({id:"color",label:"Color",modelProperty:"color"})))}function pd(t,e,r){ut(e,"pfdn:Settings")&&(t.entries.push(r.colorPicker({id:"backgroundColor",label:"Background color",modelProperty:"backgroundColor"})),t.entries.push(r.colorPicker({id:"grid.lineColor",label:"Line color",modelProperty:"grid.lineColor"})),t.entries.push(r.textField({id:"grid.size",label:"Square size",modelProperty:"grid.size",type:"number"})),t.entries.push(r.textField({id:"grid.lineWidth",label:"Line width",modelProperty:"grid.lineWidth",type:"number"})))}var xe=class{constructor(e,r,n){this._icons=e,this._entryFactory=r,this._eventBus=n}updateDrawing(e){if(ut(e,"pfdn:Settings")){this._eventBus.emit("canvas.resized");return}if(this._eventBus.emit("element.updated",e.id,e),ut(e,"pfdn:Link")||ut(e,"pfdn:Node")){let r=e.label;r&&this._eventBus.emit("element.updated",r.id,r)}}getTabs(e){let r=this._entryFactory;return[this._propertiesTab(e,r),this._formatTab(e,r)]}_propertiesTab(e,r){let n={id:"general",label:"General",entries:[]};return ld(n,e,r),{id:"properties",label:"Properties",groups:[n]}}_formatTab(e,r){let n={id:"elementFormat",label:"Element format",entries:[]},i={id:"labelFormat",label:"Label format",entries:[]},o={id:"gridFormat",label:"Grid format",entries:[]};return ud(n,e,r,this._icons),cd(n,e,r),fd(i,e,r),pd(o,e,r),{id:"format",label:"Format",groups:[n,i,o]}}};xe.$inject=["icons","entryFactory","eventBus"];var nn={__init__:["propertiesProvider"],propertiesProvider:["type",xe]};function tr(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var dd=new Set(["INPUT","TEXTAREA","SELECT"]),er=class er{constructor(e,r,n,i){this._entries={};this._container=null;this._tabsEl=null;this._contentsEl=null;this._eventBus=r,this._propertiesProvider=n,this._diagramSettings=i,this._registerSideTab(e),this._registerSelectionListener()}_registerSideTab(e){e.registerSideTab({title:"Properties",iconClassName:"icon-sliders",action:{created:r=>this._drawPanel(r)}},1)}_registerSelectionListener(){this._eventBus.on("selection.changed",(e,r)=>{let n=this._diagramSettings;r.length===1&&(e.length!==1||e[0].definition.id!==r[0].definition.id)&&(n=r[0].definition),this._update(n)})}_drawPanel(e){e&&(this._drawContainer(e),this._update(this._diagramSettings))}_drawContainer(e){this._container=tr(er.HTML_MARKUP),e.insertBefore(this._container,e.firstChild),this._tabsEl=this._container.querySelector(".tab-sheets"),this._contentsEl=this._container.querySelector(".pfdjs-pp-contents"),this._container.addEventListener("click",r=>{let n=r.target.closest(".tab-sheet");n&&(this._selectTab(n.getAttribute("data-tab-target")),r.stopImmediatePropagation())}),this._registerInputChangeHandlers()}_registerInputChangeHandlers(){let e=this._container;if(!e)return;let r=Ml(n=>this._applyChange(n),300);e.addEventListener("input",n=>{let i=n.target;(i.tagName==="INPUT"||i.tagName==="TEXTAREA")&&r(i)}),e.addEventListener("change",n=>{let i=n.target;dd.has(i.tagName)&&this._applyChange(i)}),this._eventBus.on("PropertiesPanel.propertyChanged",(n,i)=>this._applyChangeByProperty(n,i))}_applyChange(e){let r=e.getAttribute("name");r&&this._commit(r,e.value)}_applyChangeByProperty(e,r){this._commit(e,_e(r,e))}_commit(e,r){let n=this._entries[e];if(!n)return;let i={};en(i,e,r),n.scope.set(n.definition,i),this._propertiesProvider.updateDrawing(n.definition)}_selectTab(e){this._tabsEl?.querySelectorAll(".tab-sheet").forEach(r=>{r.classList.toggle("tab-sheet-active",r.getAttribute("data-tab-target")===e)}),this._contentsEl?.querySelectorAll(".pfdjs-pp-content").forEach(r=>{r.classList.toggle("open",r.getAttribute("data-tab-target")===e)})}_update(e){this._tabsEl&&this._contentsEl&&(this._tabsEl.replaceChildren(),this._contentsEl.replaceChildren()),e&&this._drawEntries(e)}_drawEntries(e){if(!this._tabsEl||!this._contentsEl)return;let r=this._propertiesProvider.getTabs(e),n=[];this._entries={};for(let o of r){let s=tr(`<div class="pfdjs-pp-content" data-tab-target="${o.id}"></div>`),a=!1;for(let l of o.groups){if(l.entries.length===0)continue;let u=tr(`<div class="pfdjs-pp-content-group" data-group-target="${l.id}"><div class="tab-content-group-title">${l.label}</div></div>`);for(let c of l.entries){let f=tr(`<div>${c.html}</div>`);u.appendChild(f),this._entries[c.id]={scope:c,definition:e,formNode:f}}s.appendChild(u),a=!0}a&&(this._contentsEl.appendChild(s),n.push({id:o.id,label:o.label}))}Object.values(this._entries).forEach(o=>o.scope.get(o.definition,o.formNode));let i=null;for(let o of n)i??(i=o.id),this._tabsEl.appendChild(tr(`<li class="tab-sheet" data-tab-target="${o.id}"><a href="#">${o.label}</a></li>`));this._selectTab(i)}};er.$inject=["sideTabsProvider","eventBus","propertiesProvider","d3polytree.definitions.settings"],er.HTML_MARKUP='<div id="pfdjs-pp-container"><div class="pfdjs-pp-tabs"><ul class="tab-sheets"></ul></div><div class="pfdjs-pp-contents"></div></div>';var we=er;var Ti={__init__:["propertiesPanel"],propertiesPanel:["type",we]};var hd='<?xml version="1.0" encoding="UTF-8"?><pfdn:diagram xmlns:pfdn="http://pfdn" xmlns="http://pfdn"><settings author="No Author" name="No Name Diagram" status="1"><zoom><offset x="0" y="0" /><scale>1</scale></zoom><grid /></settings><node id="node_1" label="label_1" status="1"><position x="20" y="100" /></node><label id="label_1" fontSize="12" isReadOnly="true" status="1"><position x="33" y="140" /><text>Node 1</text></label></pfdn:diagram>',sn=class sn extends Ai{constructor(){super(...arguments);this.initialDiagram=hd}createDiagram(){return this.importDiagram(this.initialDiagram)}getModules(){return[...Ai.interactionModules,...sn.editionModules,...Je.modules]}createNode(r={}){return this.get("modellingNodes").create(r)}select(r){let n=this.get("drawingRegistry").get(r.id);n&&this.get("selection").select(n,r)}deleteSelected(){this.get("selection").deleteSelected()}};sn.editionModules=[fl,Qe,Ei,Ni,Mi,pl,dl,rn,nn,Ti];var on=sn,md=on;return Ol(gd);})();
7
7
  //# sourceMappingURL=editor.umd.js.map