@linkurious/ogma-annotations 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function(T,et){typeof exports=="object"&&typeof module<"u"?et(exports):typeof define=="function"&&define.amd?define(["exports"],et):(T=typeof globalThis<"u"?globalThis:T||self,et(T["@linkurious/ogma-annotations"]={}))})(this,function(T){"use strict";var Xn=Object.defineProperty;var Gn=(T,et,ht)=>et in T?Xn(T,et,{enumerable:!0,configurable:!0,writable:!0,value:ht}):T[et]=ht;var v=(T,et,ht)=>(Gn(T,typeof et!="symbol"?et+"":et,ht),ht);var et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ht(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var we={exports:{}};(function(u){(function(h,t){u.exports=t()})("Vector",function(){var h=function(){var t=Math.PI*2,r=180/Math.PI,a=Math.PI/180;function c(s){return Math.round(s*1e8)/1e8}function p(s,d){var m=d.x-s.x,k=d.y-s.y;return Math.sqrt(m*m+k*k)}function y(s,d,m){var k=d.y-s.y,_=d.x-s.x,E=Math.atan2(k,_);if(m)for(;E<0;)E+=t;return E}function f(s,d){this.x=s!==void 0?s:0,this.y=d!==void 0?d:0}return f.fromRadians=function(s){var d=Math.cos(s),m=Math.sin(s);return new f(d,m)},f.fromDegrees=function(s){var d=s*(Math.PI/180);return f.fromRadians(d)},f.fromString=function(s){var d=s.split(",");return new f(parseFloat(d[0]),parseFloat(d[1]))},f.fromArray=function(s){return new f(s[0],s[1])},f.prototype={version:"2.0.1",clone:function(){return new f(this.x,this.y)},equals:function(s){return this.prototype===s.prototype&&this.x===s.x&&this.y===s.y},copy:function(s){return this.x=s.x,this.y=s.y,this},copyX:function(s){return this.x=s.x,this},copyY:function(s){return this.y=s.y,this},toDict:function(){return{x:this.x,y:this.y}},toArray:function(){return[this.x,this.y]},set:function(s,d){return s!==void 0&&(this.x=s),d!==void 0&&(this.y=d),this},flipXY:function(){return new f(this.y,this.x)},flipXYSelf:function(){return this.y=[this.x,this.x=this.y][0],this},invert:function(){return this.mulScalar(-1)},invertSelf:function(){return this.mulScalarSelf(-1),this},distanceFrom:function(s){return p(this,s)},radiansTo:function(s){return y(this,s,!0)},degreesTo:function(s){return y(this,s,!0)*r},toRadians:function(s){return y(f.zero,this,!0)},toDegrees:function(s){return this.toRadians()*r},rotateDegreesSelf:function(s){return this.rotateRadiansSelf(s*a)},rotateDegrees:function(s){return this.clone().rotateDegreesSelf(s)},rotateRadiansSelf:function(s){var d=Math.cos(s),m=Math.sin(s),k=this.x*d-this.y*m,_=this.x*m+this.y*d;return this.x=c(k),this.y=c(_),this},rotateRadians:function(s){return this.clone().rotateRadiansSelf(s)},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalizeSelf:function(){var s=Math.sqrt(this.x*this.x+this.y*this.y);return s===0?this:(this.x/=s,this.y/=s,this)},normalize:function(){return this.clone().normalizeSelf()},addSelf:function(s){return typeof s=="number"?this.addScalarSelf(s):(this.x+=s.x,this.y+=s.y,this)},subSelf:function(s){return typeof s=="number"?this.subScalarSelf(s):(this.x-=s.x,this.y-=s.y,this)},divSelf:function(s){return typeof s=="number"?this.divScalarSelf(s):(this.x/=s.x,this.y/=s.y,this)},mulSelf:function(s){return typeof s=="number"?this.mulScalarSelf(s):(this.x*=s.x,this.y*=s.y,this)},addScalarSelf:function(s){return this.x+=s,this.y+=s,this},subScalarSelf:function(s){return this.x-=s,this.y-=s,this},divScalarSelf:function(s){return this.x/=s,this.y/=s,this},mulScalarSelf:function(s){return this.x*=s,this.y*=s,this},add:function(s){return this.clone().addSelf(s)},sub:function(s){return this.clone().subSelf(s)},mul:function(s){return this.clone().mulSelf(s)},div:function(s){return this.clone().divSelf(s)},addScalar:function(s){return this.clone().addScalarSelf(s)},subScalar:function(s){return this.clone().subScalarSelf(s)},mulScalar:function(s){return this.clone().mulScalarSelf(s)},divScalar:function(s){return this.clone().divScalarSelf(s)},clampSelf:function(s,d){return this.x<s.x&&(this.x=s.x),this.y<s.y&&(this.y=s.y),this.x>d.x&&(this.x=d.x),this.y>d.y&&(this.y=d.y),this},clamp:function(s,d){return this.clone().clampSelf(s,d)},applySelf:function(s){return this.x=s(this.x),this.y=s(this.y),this},apply:function(s){return this.clone().applySelf(s)},absSelf:function(){return this.applySelf(Math.abs)},abs:function(){return this.clone().absSelf()},roundSelf:function(){return this.applySelf(Math.round)},round:function(){return this.clone().roundSelf()},dot:function(s){return this.x*s.x+this.y*s.y},cross:function(s){return this.x*s.y-this.y*s.x},repairSelf:function(s,d){return(typeof this.x!="number"||isNaN(this.x+1))&&(this.x=s||0),(typeof this.y!="number"||isNaN(this.y+1))&&(this.y=d||0),this},repair:function(s,d){return this.clone().repairSelf(s,d)},toString:function(){return this.x+","+this.y},format:function(s){return s=s||"%x,%y",s=s.replace(new RegExp("%x","g"),this.x),s=s.replace(new RegExp("%y","g"),this.y),s}},f}();return h.zero=new h(0,0),h.one=new h(1,1),h.up=new h(0,-1),h.down=new h(0,1),h.left=new h(-1,0),h.right=new h(1,0),h.upLeft=new h(-1,-1),h.downLeft=new h(-1,1),h.upRight=new h(1,-1),h.downRight=new h(1,1),h.prototype.magnitude=h.prototype.length,Object.freeze&&(Object.freeze(h.zero),Object.freeze(h.one),Object.freeze(h.up),Object.freeze(h.down),Object.freeze(h.left),Object.freeze(h.right),Object.freeze(h.upLeft),Object.freeze(h.downLeft),Object.freeze(h.upRight),Object.freeze(h.downRight)),h})})(we);var Qe=we.exports;const rt=ht(Qe);let $t=(u=21)=>crypto.getRandomValues(new Uint8Array(u)).reduce((h,t)=>(t&=63,t<36?h+=t.toString(36):t<62?h+=(t-26).toString(36).toUpperCase():t>62?h+="-":h+="_",h),"");const At={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},Gt={id:0,type:"Feature",properties:{type:"arrow",style:{...At}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},be=(u=0,h=0,t=0,r=0,a={...At})=>({id:$t(),type:"Feature",properties:{type:"arrow",style:{...At,...a}},geometry:{type:"LineString",coordinates:[[u,h],[t,r]]}}),tn="http://www.w3.org/2000/svg";function St(u){return document.createElementNS(tn,u)}function Zt(u){return u.geometry.bbox||Ae(u),u.geometry.bbox}function ct(u){const h=Zt(u);return{width:h[2]-h[0],height:h[3]-h[1]}}function pt(u){const h=Zt(u);return{x:h[0],y:h[1]}}function Ae(u){const[h,t]=u.geometry.coordinates[0][0],[r,a]=u.geometry.coordinates[0][2];u.geometry.bbox=[h,t,r,a]}function Se(u,h,t,r,a){u.geometry.bbox=[h,t,h+r,t+a],u.geometry.coordinates=[[[h,t],[h+r,t],[h+r,t+a],[h,t+a],[h,t]]]}function Et(u){const[h,t]=u.geometry.coordinates[0];return{x:h,y:t}}function Ht(u,h){const[t,r]=u.geometry.coordinates[h==="start"?0:1];return{x:t,y:r}}function _t(u){const[h,t]=u.geometry.coordinates[1];return{x:h,y:t}}function Wt(u,h,t){u.geometry.coordinates[0]=[h,t]}function Kt(u,h,t){u.geometry.coordinates[1]=[h,t]}function Ot(u){return{start:Et(u),end:_t(u)}}function Dt(u,h,t,r){h==="start"?Wt(u,t,r):Kt(u,t,r)}const Jt=u=>parseInt(u.getAttribute("data-handle-id")||"-1");function en(u){return jt(u).reduce((h,t)=>(h[0]=Math.min(t[0],h[0]),h[1]=Math.min(t[1],h[1]),h[2]=Math.max(t[0],h[2]),h[3]=Math.max(t[1],h[3]),h),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function jt(u){let h=[];return u.type=="Point"?h=[u.coordinates]:u.type=="LineString"||u.type=="MultiPoint"?h=u.coordinates:u.type=="Polygon"||u.type=="MultiLineString"?h=u.coordinates.reduce(function(t,r){return t.concat(r)},[]):u.type=="MultiPolygon"?h=u.coordinates.reduce((t,r)=>t.concat(r.reduce((a,c)=>a.concat(c),[])),[]):u.type=="Feature"?h=jt(u.geometry):u.type=="GeometryCollection"?h=u.geometries.reduce((t,r)=>t.concat(jt(r)),[]):u.type=="FeatureCollection"&&(h=u.features.reduce((t,r)=>t.concat(jt(r)),[])),h}function Rt(u,h,t){const r=Math.atan2(u.y-h.y,u.x-h.x);return{x:h.x+t*Math.cos(r),y:h.y+t*Math.sin(r)}}function Ee(u,h=5,t=30){var s;const{start:r,end:a}=Ot(u),c=new rt(r.x,r.y),y=new rt(a.x,a.y).sub(c),f=u.properties.style&&u.properties.style.strokeWidth?(s=u.properties.style)==null?void 0:s.strokeWidth:0;return Math.min(t,Math.max(3*f,y.length()*.1,h))}function ke(u,h,t,r){const a=h.clone().normalize().invert().mul(r);if(!t||t==="none")return"";const c=u.clone().add(a.rotateRadians(Math.PI/8)),p=u.clone().add(a.rotateRadians(-Math.PI/8)),y=`${u.x} ${u.y}`;return`M ${c.x} ${c.y} L ${y} ${p.x} ${p.y} ${t==="arrow"?"":`${c.x} ${c.y}`}`}function nn(u,h,t,r,a){const{start:c,end:p}=Ot(u),{tail:y,head:f,strokeColor:s,strokeWidth:d}=u.properties.style||t,m=new rt(c.x,c.y),k=new rt(p.x,p.y),_=k.clone().sub(m),E=Ee(u,r,a),P=St("path");P.setAttribute("data-annotation",`${u.id}`),P.setAttribute("data-annotation-type","arrow");const S=f==="arrow-plain"||y==="arrow";P.setAttribute("stroke",s||"none"),P.setAttribute("stroke-width",`${d}`),P.setAttribute("fill",S?s||"":"none"),P.setAttribute("stroke-linecap","round"),P.setAttribute("stroke-linejoin","round");const Y=ke(m,_.clone().invert(),y,E),$=ke(k,_,f,E),L=Y+`M ${m.x} ${m.y} ${k.x} ${k.y}`+$;P.setAttribute("d",L),h.appendChild(P)}const q=-1,Qt="dragging",te="dragstart",Mt="dragend",ee="select",ne="unselect",rn="hover",sn="unhover",ie="remove",re="add",on="cancelDrawing",se="update",an="link";var Te={exports:{}};(function(u){var h=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function a(f,s,d){this.fn=f,this.context=s,this.once=d||!1}function c(f,s,d,m,k){if(typeof d!="function")throw new TypeError("The listener must be a function");var _=new a(d,m||f,k),E=t?t+s:s;return f._events[E]?f._events[E].fn?f._events[E]=[f._events[E],_]:f._events[E].push(_):(f._events[E]=_,f._eventsCount++),f}function p(f,s){--f._eventsCount===0?f._events=new r:delete f._events[s]}function y(){this._events=new r,this._eventsCount=0}y.prototype.eventNames=function(){var s=[],d,m;if(this._eventsCount===0)return s;for(m in d=this._events)h.call(d,m)&&s.push(t?m.slice(1):m);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(d)):s},y.prototype.listeners=function(s){var d=t?t+s:s,m=this._events[d];if(!m)return[];if(m.fn)return[m.fn];for(var k=0,_=m.length,E=new Array(_);k<_;k++)E[k]=m[k].fn;return E},y.prototype.listenerCount=function(s){var d=t?t+s:s,m=this._events[d];return m?m.fn?1:m.length:0},y.prototype.emit=function(s,d,m,k,_,E){var P=t?t+s:s;if(!this._events[P])return!1;var S=this._events[P],Y=arguments.length,$,L;if(S.fn){switch(S.once&&this.removeListener(s,S.fn,void 0,!0),Y){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,d),!0;case 3:return S.fn.call(S.context,d,m),!0;case 4:return S.fn.call(S.context,d,m,k),!0;case 5:return S.fn.call(S.context,d,m,k,_),!0;case 6:return S.fn.call(S.context,d,m,k,_,E),!0}for(L=1,$=new Array(Y-1);L<Y;L++)$[L-1]=arguments[L];S.fn.apply(S.context,$)}else{var W=S.length,st;for(L=0;L<W;L++)switch(S[L].once&&this.removeListener(s,S[L].fn,void 0,!0),Y){case 1:S[L].fn.call(S[L].context);break;case 2:S[L].fn.call(S[L].context,d);break;case 3:S[L].fn.call(S[L].context,d,m);break;case 4:S[L].fn.call(S[L].context,d,m,k);break;default:if(!$)for(st=1,$=new Array(Y-1);st<Y;st++)$[st-1]=arguments[st];S[L].fn.apply(S[L].context,$)}}return!0},y.prototype.on=function(s,d,m){return c(this,s,d,m,!1)},y.prototype.once=function(s,d,m){return c(this,s,d,m,!0)},y.prototype.removeListener=function(s,d,m,k){var _=t?t+s:s;if(!this._events[_])return this;if(!d)return p(this,_),this;var E=this._events[_];if(E.fn)E.fn===d&&(!k||E.once)&&(!m||E.context===m)&&p(this,_);else{for(var P=0,S=[],Y=E.length;P<Y;P++)(E[P].fn!==d||k&&!E[P].once||m&&E[P].context!==m)&&S.push(E[P]);S.length?this._events[_]=S.length===1?S[0]:S:p(this,_)}return this},y.prototype.removeAllListeners=function(s){var d;return s?(d=t?t+s:s,this._events[d]&&p(this,d)):(this._events=new r,this._eventsCount=0),this},y.prototype.off=y.prototype.removeListener,y.prototype.addListener=y.prototype.on,y.prefixed=t,y.EventEmitter=y,u.exports=y})(Te);var ln=Te.exports;const Ie=ht(ln);class _e extends Ie{constructor(t,r){super();v(this,"ogma");v(this,"elements");v(this,"layer");v(this,"editor");v(this,"selectedId",q);v(this,"hoveredId",q);v(this,"ogmaOptions");v(this,"shouldDetect");v(this,"isDragging");v(this,"maxHandleScale",1.5);v(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==q?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==q&&this._canRemove()&&this.remove(this.selectedId)});v(this,"_onClickMouseMove",t=>{if(!t.domEvent||this.isDragging||!this.shouldDetect)return;const r=this.ogma.view.screenToGraphCoordinates(t),a=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(r,0):void 0;t.domEvent.type==="mousemove"?a?this.hover(a.id):this.hoveredId!==q&&this.unhover():a?this.select(a.id):this.selectedId!==q&&this.unselect()});this.ogma=t,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.ogmaOptions=t.getOptions(),t.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("newFrame",()=>{this.refreshEditor()}),this.layer=t.layers.addSVGLayer({draw:a=>this.draw(a)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(r),this.editor.hide()}_canRemove(){return!0}add(t){const r=this.getDefaultOptions(),a=Object.assign(t,{id:t.id===void 0?$t():t.id,type:t.type,properties:{...r.properties,...t.properties||{},style:{...r.properties.style,...t.properties.style||{}}},geometry:{...r.geometry,...t.geometry}});return this.elements.push(a),this.layer.refresh(),this.emit(re,a),a}updateStyle(t,r){this.updateAnnotation(t,{properties:{style:r}})}updateGeometry(t,r){this.updateAnnotation(t,{geometry:r})}update(t,r){const a=this.getById(t);this.updateAnnotation(a,r)}updateAnnotation(t,r){if(!t)return;const a=t.id;Object.keys(r).forEach(c=>{if(c!=="id")if(c==="properties"){const p=r.properties||{style:{}};t.properties={...t.properties||{},...p||{},style:{...t.properties.style||{},...p.style||{}}}}else c==="geometry"?t.geometry={...t.geometry,...r.geometry}:t[c]=r[c]}),a===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){for(let r=0;r<this.elements.length;r++){const a=this.elements[r];if(a.id===t)return a}}select(t){const r=this.getById(t);r&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(ee,r))}hover(t){const r=this.getById(t);r&&(this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(rn,r))}getSelectedFeature(){return this.selectedId===q?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(ne,t),this.selectedId=q,this.hoveredId===q&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(sn,t),this.hoveredId=q,this.selectedId===q&&this.editor.hide(),this.layer.refresh(),this}remove(t){const r=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(a=>a.id!==t),r&&this.emit(ie,r),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const Oe="handle-line",De="handle-start",Me="handle-end";class ze extends _e{constructor(t,r={}){super(t,`
1
+ (function(I,it){typeof exports=="object"&&typeof module<"u"?it(exports):typeof define=="function"&&define.amd?define(["exports"],it):(I=typeof globalThis<"u"?globalThis:I||self,it(I["@linkurious/ogma-annotations"]={}))})(this,function(I){"use strict";var Xn=Object.defineProperty;var Gn=(I,it,ct)=>it in I?Xn(I,it,{enumerable:!0,configurable:!0,writable:!0,value:ct}):I[it]=ct;var v=(I,it,ct)=>(Gn(I,typeof it!="symbol"?it+"":it,ct),ct);var it=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ct(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var xe={exports:{}};(function(u){(function(l,t){u.exports=t()})("Vector",function(){var l=function(){var t=Math.PI*2,r=180/Math.PI,a=Math.PI/180;function c(s){return Math.round(s*1e8)/1e8}function f(s,d){var m=d.x-s.x,A=d.y-s.y;return Math.sqrt(m*m+A*A)}function g(s,d,m){var A=d.y-s.y,T=d.x-s.x,S=Math.atan2(A,T);if(m)for(;S<0;)S+=t;return S}function p(s,d){this.x=s!==void 0?s:0,this.y=d!==void 0?d:0}return p.fromRadians=function(s){var d=Math.cos(s),m=Math.sin(s);return new p(d,m)},p.fromDegrees=function(s){var d=s*(Math.PI/180);return p.fromRadians(d)},p.fromString=function(s){var d=s.split(",");return new p(parseFloat(d[0]),parseFloat(d[1]))},p.fromArray=function(s){return new p(s[0],s[1])},p.prototype={version:"2.0.1",clone:function(){return new p(this.x,this.y)},equals:function(s){return this.prototype===s.prototype&&this.x===s.x&&this.y===s.y},copy:function(s){return this.x=s.x,this.y=s.y,this},copyX:function(s){return this.x=s.x,this},copyY:function(s){return this.y=s.y,this},toDict:function(){return{x:this.x,y:this.y}},toArray:function(){return[this.x,this.y]},set:function(s,d){return s!==void 0&&(this.x=s),d!==void 0&&(this.y=d),this},flipXY:function(){return new p(this.y,this.x)},flipXYSelf:function(){return this.y=[this.x,this.x=this.y][0],this},invert:function(){return this.mulScalar(-1)},invertSelf:function(){return this.mulScalarSelf(-1),this},distanceFrom:function(s){return f(this,s)},radiansTo:function(s){return g(this,s,!0)},degreesTo:function(s){return g(this,s,!0)*r},toRadians:function(s){return g(p.zero,this,!0)},toDegrees:function(s){return this.toRadians()*r},rotateDegreesSelf:function(s){return this.rotateRadiansSelf(s*a)},rotateDegrees:function(s){return this.clone().rotateDegreesSelf(s)},rotateRadiansSelf:function(s){var d=Math.cos(s),m=Math.sin(s),A=this.x*d-this.y*m,T=this.x*m+this.y*d;return this.x=c(A),this.y=c(T),this},rotateRadians:function(s){return this.clone().rotateRadiansSelf(s)},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalizeSelf:function(){var s=Math.sqrt(this.x*this.x+this.y*this.y);return s===0?this:(this.x/=s,this.y/=s,this)},normalize:function(){return this.clone().normalizeSelf()},addSelf:function(s){return typeof s=="number"?this.addScalarSelf(s):(this.x+=s.x,this.y+=s.y,this)},subSelf:function(s){return typeof s=="number"?this.subScalarSelf(s):(this.x-=s.x,this.y-=s.y,this)},divSelf:function(s){return typeof s=="number"?this.divScalarSelf(s):(this.x/=s.x,this.y/=s.y,this)},mulSelf:function(s){return typeof s=="number"?this.mulScalarSelf(s):(this.x*=s.x,this.y*=s.y,this)},addScalarSelf:function(s){return this.x+=s,this.y+=s,this},subScalarSelf:function(s){return this.x-=s,this.y-=s,this},divScalarSelf:function(s){return this.x/=s,this.y/=s,this},mulScalarSelf:function(s){return this.x*=s,this.y*=s,this},add:function(s){return this.clone().addSelf(s)},sub:function(s){return this.clone().subSelf(s)},mul:function(s){return this.clone().mulSelf(s)},div:function(s){return this.clone().divSelf(s)},addScalar:function(s){return this.clone().addScalarSelf(s)},subScalar:function(s){return this.clone().subScalarSelf(s)},mulScalar:function(s){return this.clone().mulScalarSelf(s)},divScalar:function(s){return this.clone().divScalarSelf(s)},clampSelf:function(s,d){return this.x<s.x&&(this.x=s.x),this.y<s.y&&(this.y=s.y),this.x>d.x&&(this.x=d.x),this.y>d.y&&(this.y=d.y),this},clamp:function(s,d){return this.clone().clampSelf(s,d)},applySelf:function(s){return this.x=s(this.x),this.y=s(this.y),this},apply:function(s){return this.clone().applySelf(s)},absSelf:function(){return this.applySelf(Math.abs)},abs:function(){return this.clone().absSelf()},roundSelf:function(){return this.applySelf(Math.round)},round:function(){return this.clone().roundSelf()},dot:function(s){return this.x*s.x+this.y*s.y},cross:function(s){return this.x*s.y-this.y*s.x},repairSelf:function(s,d){return(typeof this.x!="number"||isNaN(this.x+1))&&(this.x=s||0),(typeof this.y!="number"||isNaN(this.y+1))&&(this.y=d||0),this},repair:function(s,d){return this.clone().repairSelf(s,d)},toString:function(){return this.x+","+this.y},format:function(s){return s=s||"%x,%y",s=s.replace(new RegExp("%x","g"),this.x),s=s.replace(new RegExp("%y","g"),this.y),s}},p}();return l.zero=new l(0,0),l.one=new l(1,1),l.up=new l(0,-1),l.down=new l(0,1),l.left=new l(-1,0),l.right=new l(1,0),l.upLeft=new l(-1,-1),l.downLeft=new l(-1,1),l.upRight=new l(1,-1),l.downRight=new l(1,1),l.prototype.magnitude=l.prototype.length,Object.freeze&&(Object.freeze(l.zero),Object.freeze(l.one),Object.freeze(l.up),Object.freeze(l.down),Object.freeze(l.left),Object.freeze(l.right),Object.freeze(l.upLeft),Object.freeze(l.downLeft),Object.freeze(l.upRight),Object.freeze(l.downRight)),l})})(xe);var Qe=xe.exports;const X=ct(Qe);let Rt=(u=21)=>crypto.getRandomValues(new Uint8Array(u)).reduce((l,t)=>(t&=63,t<36?l+=t.toString(36):t<62?l+=(t-26).toString(36).toUpperCase():t>62?l+="-":l+="_",l),"");const St={strokeType:"plain",strokeColor:"black",strokeWidth:1,head:"none",tail:"none"},Wt={id:0,type:"Feature",properties:{type:"arrow",style:{...St}},geometry:{type:"LineString",coordinates:[[0,0],[100,100]]}},be=(u=0,l=0,t=0,r=0,a={...St})=>({id:Rt(),type:"Feature",properties:{type:"arrow",style:{...St,...a}},geometry:{type:"LineString",coordinates:[[u,l],[t,r]]}}),tn="http://www.w3.org/2000/svg";function Et(u){return document.createElementNS(tn,u)}function Kt(u){return u.geometry.bbox||Ae(u),u.geometry.bbox}function at(u){const l=Kt(u);return{width:l[2]-l[0],height:l[3]-l[1]}}function ut(u){const l=Kt(u);return{x:l[0],y:l[1]}}function Ae(u){const[l,t]=u.geometry.coordinates[0][0],[r,a]=u.geometry.coordinates[0][2];u.geometry.bbox=[l,t,r,a]}function Se(u,l,t,r,a){u.geometry.bbox=[l,t,l+r,t+a],u.geometry.coordinates=[[[l,t],[l+r,t],[l+r,t+a],[l,t+a],[l,t]]]}function kt(u){const[l,t]=u.geometry.coordinates[0];return{x:l,y:t}}function Dt(u,l){const[t,r]=u.geometry.coordinates[l==="start"?0:1];return{x:t,y:r}}function Mt(u){const[l,t]=u.geometry.coordinates[1];return{x:l,y:t}}function Jt(u,l,t){u.geometry.coordinates[0]=[l,t]}function Qt(u,l,t){u.geometry.coordinates[1]=[l,t]}function zt(u){return{start:kt(u),end:Mt(u)}}function mt(u,l,t,r){l==="start"?Jt(u,t,r):Qt(u,t,r)}const te=u=>parseInt(u.getAttribute("data-handle-id")||"-1");function en(u){return jt(u).reduce((l,t)=>(l[0]=Math.min(t[0],l[0]),l[1]=Math.min(t[1],l[1]),l[2]=Math.max(t[0],l[2]),l[3]=Math.max(t[1],l[3]),l),[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY])}function jt(u){let l=[];return u.type=="Point"?l=[u.coordinates]:u.type=="LineString"||u.type=="MultiPoint"?l=u.coordinates:u.type=="Polygon"||u.type=="MultiLineString"?l=u.coordinates.reduce(function(t,r){return t.concat(r)},[]):u.type=="MultiPolygon"?l=u.coordinates.reduce((t,r)=>t.concat(r.reduce((a,c)=>a.concat(c),[])),[]):u.type=="Feature"?l=jt(u.geometry):u.type=="GeometryCollection"?l=u.geometries.reduce((t,r)=>t.concat(jt(r)),[]):u.type=="FeatureCollection"&&(l=u.features.reduce((t,r)=>t.concat(jt(r)),[])),l}function Lt(u,l,t){const r=Math.atan2(u.y-l.y,u.x-l.x);return{x:l.x+t*Math.cos(r),y:l.y+t*Math.sin(r)}}function Ee(u,l=5,t=30){var s;const{start:r,end:a}=zt(u),c=new X(r.x,r.y),g=new X(a.x,a.y).sub(c),p=u.properties.style&&u.properties.style.strokeWidth?(s=u.properties.style)==null?void 0:s.strokeWidth:0;return Math.min(t,Math.max(3*p,g.length()*.1,l))}function ke(u,l,t,r){const a=l.clone().normalize().invert().mul(r);if(!t||t==="none")return"";const c=u.clone().add(a.rotateRadians(Math.PI/8)),f=u.clone().add(a.rotateRadians(-Math.PI/8)),g=`${u.x} ${u.y}`;return`M ${c.x} ${c.y} L ${g} ${f.x} ${f.y} ${t==="arrow"?"":`${c.x} ${c.y}`}`}function nn(u,l,t,r,a){const{start:c,end:f}=zt(u),{tail:g,head:p,strokeColor:s,strokeWidth:d}=u.properties.style||t,m=new X(c.x,c.y),A=new X(f.x,f.y),T=A.clone().sub(m),S=Ee(u,r,a),P=Et("path");P.setAttribute("data-annotation",`${u.id}`),P.setAttribute("data-annotation-type","arrow");const k=p==="arrow-plain"||g==="arrow";P.setAttribute("stroke",s||"none"),P.setAttribute("stroke-width",`${d}`),P.setAttribute("fill",k?s||"":"none"),P.setAttribute("stroke-linecap","round"),P.setAttribute("stroke-linejoin","round");const q=ke(m,T.clone().invert(),g,S),G=ke(A,T,p,S),D=q+`M ${m.x} ${m.y} ${A.x} ${A.y}`+G;P.setAttribute("d",D),l.appendChild(P)}const B=-1,Ft="dragging",Bt="dragstart",Tt="dragend",ee="select",ne="unselect",rn="hover",sn="unhover",ie="remove",re="add",on="cancelDrawing",se="update",an="link";var Te={exports:{}};(function(u){var l=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function a(p,s,d){this.fn=p,this.context=s,this.once=d||!1}function c(p,s,d,m,A){if(typeof d!="function")throw new TypeError("The listener must be a function");var T=new a(d,m||p,A),S=t?t+s:s;return p._events[S]?p._events[S].fn?p._events[S]=[p._events[S],T]:p._events[S].push(T):(p._events[S]=T,p._eventsCount++),p}function f(p,s){--p._eventsCount===0?p._events=new r:delete p._events[s]}function g(){this._events=new r,this._eventsCount=0}g.prototype.eventNames=function(){var s=[],d,m;if(this._eventsCount===0)return s;for(m in d=this._events)l.call(d,m)&&s.push(t?m.slice(1):m);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(d)):s},g.prototype.listeners=function(s){var d=t?t+s:s,m=this._events[d];if(!m)return[];if(m.fn)return[m.fn];for(var A=0,T=m.length,S=new Array(T);A<T;A++)S[A]=m[A].fn;return S},g.prototype.listenerCount=function(s){var d=t?t+s:s,m=this._events[d];return m?m.fn?1:m.length:0},g.prototype.emit=function(s,d,m,A,T,S){var P=t?t+s:s;if(!this._events[P])return!1;var k=this._events[P],q=arguments.length,G,D;if(k.fn){switch(k.once&&this.removeListener(s,k.fn,void 0,!0),q){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,d),!0;case 3:return k.fn.call(k.context,d,m),!0;case 4:return k.fn.call(k.context,d,m,A),!0;case 5:return k.fn.call(k.context,d,m,A,T),!0;case 6:return k.fn.call(k.context,d,m,A,T,S),!0}for(D=1,G=new Array(q-1);D<q;D++)G[D-1]=arguments[D];k.fn.apply(k.context,G)}else{var Y=k.length,Z;for(D=0;D<Y;D++)switch(k[D].once&&this.removeListener(s,k[D].fn,void 0,!0),q){case 1:k[D].fn.call(k[D].context);break;case 2:k[D].fn.call(k[D].context,d);break;case 3:k[D].fn.call(k[D].context,d,m);break;case 4:k[D].fn.call(k[D].context,d,m,A);break;default:if(!G)for(Z=1,G=new Array(q-1);Z<q;Z++)G[Z-1]=arguments[Z];k[D].fn.apply(k[D].context,G)}}return!0},g.prototype.on=function(s,d,m){return c(this,s,d,m,!1)},g.prototype.once=function(s,d,m){return c(this,s,d,m,!0)},g.prototype.removeListener=function(s,d,m,A){var T=t?t+s:s;if(!this._events[T])return this;if(!d)return f(this,T),this;var S=this._events[T];if(S.fn)S.fn===d&&(!A||S.once)&&(!m||S.context===m)&&f(this,T);else{for(var P=0,k=[],q=S.length;P<q;P++)(S[P].fn!==d||A&&!S[P].once||m&&S[P].context!==m)&&k.push(S[P]);k.length?this._events[T]=k.length===1?k[0]:k:f(this,T)}return this},g.prototype.removeAllListeners=function(s){var d;return s?(d=t?t+s:s,this._events[d]&&f(this,d)):(this._events=new r,this._eventsCount=0),this},g.prototype.off=g.prototype.removeListener,g.prototype.addListener=g.prototype.on,g.prefixed=t,g.EventEmitter=g,u.exports=g})(Te);var ln=Te.exports;const Ie=ct(ln);class _e extends Ie{constructor(t,r){super();v(this,"ogma");v(this,"elements");v(this,"layer");v(this,"editor");v(this,"selectedId",B);v(this,"hoveredId",B);v(this,"ogmaOptions");v(this,"shouldDetect");v(this,"isDragging");v(this,"showeditorOnHover");v(this,"maxHandleScale",1.5);v(this,"_onKeyUp",t=>{t.code===27&&this.selectedId!==B?this.unselect():(t.code===46||t.code===8)&&this.selectedId!==B&&this._canRemove()&&this.remove(this.selectedId)});v(this,"_onClickMouseMove",t=>{if(!t.domEvent||this.isDragging||!this.shouldDetect)return;const r=this.ogma.view.screenToGraphCoordinates(t),a=this.shouldDetect||!this.shouldDetect&&+this.selectedId>-1?this.detect(r,0):void 0;t.domEvent.type==="mousemove"?a?this.hover(a.id):this.hoveredId!==B&&this.unhover():a?this.select(a.id):this.selectedId!==B&&this.unselect()});this.ogma=t,this.elements=[],this.shouldDetect=!0,this.isDragging=!1,this.showeditorOnHover=!0,this.ogmaOptions=t.getOptions(),t.events.on(["click","mousemove"],this._onClickMouseMove).on("keyup",this._onKeyUp).on("newFrame",()=>{this.refreshEditor(),this.refreshDrawing()}),this.layer=t.layers.addSVGLayer({draw:a=>this.draw(a)}),this.layer.moveToTop(),this.editor=t.layers.addLayer(r),this.editor.hide()}_canRemove(){return!0}add(t){const r=this.getDefaultOptions(),a=Object.assign(t,{id:t.id===void 0?Rt():t.id,type:t.type,properties:{...r.properties,...t.properties||{},style:{...r.properties.style,...t.properties.style||{}}},geometry:{...r.geometry,...t.geometry}});return this.elements.push(a),this.layer.refresh(),this.emit(re,a),a}updateStyle(t,r){this.updateAnnotation(t,{properties:{style:r}})}updateGeometry(t,r){this.updateAnnotation(t,{geometry:r})}update(t,r){const a=this.getById(t);this.updateAnnotation(a,r)}updateAnnotation(t,r){if(!t)return;const a=t.id;Object.keys(r).forEach(c=>{if(c!=="id")if(c==="properties"){const f=r.properties||{style:{}};t.properties={...t.properties||{},...f||{},style:{...t.properties.style||{},...f.style||{}}}}else c==="geometry"?t.geometry={...t.geometry,...r.geometry}:t[c]=r[c]}),a===this.selectedId&&this.refreshEditor(),this.layer.refresh()}getById(t){for(let r=0;r<this.elements.length;r++){const a=this.elements[r];if(a.id===t)return a}}select(t){const r=this.getById(t);r&&(this.editor.show(),this.selectedId=t,this.refreshEditor(),this.layer.refresh(),this.emit(ee,r))}hover(t){const r=this.getById(t);r&&(this.showeditorOnHover&&this.editor.show(),this.hoveredId=t,this.refreshEditor(),this.layer.refresh(),this.emit(rn,r))}getSelectedFeature(){return this.selectedId===B?null:this.getById(this.selectedId)}unselect(){const t=this.getById(this.selectedId);return t&&this.emit(ne,t),this.selectedId=B,this.hoveredId===B&&this.editor.hide(),this.layer.refresh(),this}unhover(){const t=this.getById(this.hoveredId);return this.emit(sn,t),this.hoveredId=B,this.selectedId===B&&this.editor.hide(),this.layer.refresh(),this}remove(t){const r=this.getById(t);t===this.hoveredId&&this.unhover(),t===this.selectedId&&this.unselect(),this.elements=this.elements.filter(a=>a.id!==t),r&&this.emit(ie,r),this.layer.refresh()}disableDragging(){this.ogma.setOptions({interactions:{drag:{enabled:!1},pan:{enabled:!1}},detect:{nodes:!1,edges:!1,nodeTexts:!1,edgeTexts:!1}})}restoreDragging(){this.ogma.setOptions(this.ogmaOptions)}enableDetection(){this.shouldDetect=!0}disableDetection(){this.shouldDetect=!1}refreshLayer(){this.layer.refresh()}refreshDrawing(){}getElements(){return[...this.elements]}destroy(){this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp),this.layer.destroy()}}const Oe="handle-line",De="handle-start",Me="handle-end";class ze extends _e{constructor(t,r={}){super(t,`
2
2
  <div class="arrow-handle">
3
3
  <div id="${Oe}" data-handle-id="0" class="handle line"></div>
4
4
  <div id="${De}" data-handle-id="1" class="handle"></div>
5
5
  <div id="${Me}" data-handle-id="2" class="handle"></div>
6
6
  </div>
7
- `);v(this,"draggedHandle",q);v(this,"start",{x:0,y:0});v(this,"end",{x:0,y:0});v(this,"arrow",{...Gt});v(this,"startX",0);v(this,"startY",0);v(this,"minArrowHeight",0);v(this,"maxArrowHeight",0);v(this,"handles",[]);v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=Jt(t.target))});v(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=q,this.emit(Mt,this.arrow))});v(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===q)return;const r=this.handles[this.draggedHandle],a=this.ogma.view.getZoom(),c=(t.clientX-this.startX)/a,p=(t.clientY-this.startY)/a,y=r.id===Oe,f=r.id===De,s=r.id===Me;(y||f)&&Wt(this.arrow,this.start.x+c,this.start.y+p),(y||s)&&Kt(this.arrow,this.end.x+c,this.end.y+p),this.emit(Qt,this.arrow,y?"line":f?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=r.minArrowHeight||0,this.maxArrowHeight=r.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(a=>a.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,r,a=be(t,r,t,r,At)){var y;this.add(a),this.hoveredId=a.id;const c=this.ogma.view.graphToScreenCoordinates({x:t,y:r}),p=((y=this.ogma.getContainer())==null?void 0:y.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(a.id),c.x+(p==null?void 0:p.left),c.y+p.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Mt,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=q)}startDragging(t,r,a){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=r,this.startY=a,this.start=Et(this.arrow),this.end=_t(this.arrow),this.disableDragging(),this.emit(te,this.arrow),this.isDragging=!0}detect(t,r=0){return this.elements.find(a=>{const{start:c,end:p}=Ot(a),y=new rt(t.x,t.y).sub(new rt((c.x+p.x)/2,(c.y+p.y)/2)),f=new rt(p.x,p.y).sub(new rt(c.x,c.y)),s=f.length(),d=f.normalize(),m=Ee(a);return Math.abs(d.dot(y))<s/2+r&&Math.abs(d.rotateRadians(Math.PI/2).dot(y))<m/2+r})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==q?this.getById(this.selectedId):this.getById(this.hoveredId),r=Ot(t),a=this.ogma.view.graphToScreenCoordinates(r.start),c=this.ogma.view.graphToScreenCoordinates(r.end),p=Math.min(this.ogma.view.getZoom(),this.maxHandleScale),[y,f,s]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));f.style.transform=`translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${p})`,s.style.transform=`translate(${c.x}px, ${c.y}px) translate(-50%, -50%) scale(${p}`;const d={x:(c.x+a.x)/2,y:(c.y+a.y)/2},m=new rt(c.x-a.x,c.y-a.y),k=m.mul(1/m.length()),_=Math.atan2(k.y,k.x);y.style.width=`${m.length()}px`,y.style.left=`${d.x}px`,y.style.top=`${d.y}px`,y.style.transform=`translate(-50%, -50%) rotate(${_}rad)`}getDefaultOptions(){return Gt}draw(t){t.innerHTML="";const r=St("g");this.elements.forEach(a=>nn(a,r,At,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(r)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const mt={font:"sans-serif",fontSize:"12",color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},Ft={id:0,type:"Feature",properties:{type:"text",content:"",style:{...mt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},oe={handleSize:3.5,placeholder:"Your text..."},Le=(u=0,h=0,t=100,r=50,a="",c={...mt})=>({id:$t(),type:"Feature",properties:{type:"text",content:a,style:{...mt,...c}},geometry:{type:"Polygon",coordinates:[[[u,h],[u+t,h],[u+t,h+r],[u,h+r],[u,h]]]}});var Ce={exports:{}};(function(u,h){(function(t,r){u.exports=r()})(et,()=>(()=>{var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function a(e){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},a(e)}t.d(r,{default:()=>Un});var c=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,p=/\bsmall-caps\b/,y=/\b(?:italic|oblique)\b/,f=/\bbold(?:er)?\b/,s=13.3333333,d={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function m(e){var n="",o=this;return o.style&&o.style!=="normal"&&(n+=o.style),o.variant&&o.variant!=="normal"&&(n+=(n?" ":"")+o.variant),o.weight&&o.weight!=="normal"&&(n+=(n?" ":"")+o.weight),o.size&&(n+=(n?" ":"")+o.size+"px",o.height!==o.size&&(n+="/"+o.height+"px")),o.family&&(n+=(n?" ":"")+o.family),e&&(n+="::"+o.baseline),e&&(n+="::"+o.color),n}var k={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:m,valueOf:m};function _(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=c.exec(e);n.family=(o[6]||"").trim();var i=d[o[2]]||parseFloat(o[2]);o[3]==="%"?i*=.16:o[3]==="em"?i*=16:o[3]==="pt"&&(i*=s),n.size=i;var l=parseFloat(o[4]);if(l!=="normal"&&l!=="inherit"&&l?o[5]&&o[5]!=="em"?o[5]==="pt"?n.height=l*s:o[5]==="%"?n.height=.01*i:n.height=l:n.height=l*i:n.height=Math.round(i*(7/6)),p.test(o[1])&&(n.variant="small-caps"),y.test(o[1])&&(n.style="italic"),f.test(o[1]))n.weight="bold";else{var g=parseInt(/\b(\d+)\b/.exec(o[1]),10);g>=100&&g!==400&&(n.weight=g)}return n}function E(){var e,n,o,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=14,w=12,x=null,b=null,A="";if(i&&i.nodeType){var D=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),M=D.getComputedStyle(i,null);e=M.getPropertyValue("font-family")||"",w=parseFloat(M.getPropertyValue("font-size")),g=M.getPropertyValue("line-height"),x=M.getPropertyValue("font-weight"),b=M.getPropertyValue("font-style"),A=M.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var I=_(i);e=I.family,w=I.size,g=I.height,A=I.variant,b=I.style,x=I.weight}else a(i)==="object"&&(e=i.family,w=i.size,g=i.height,A=i.variant,x=i.weight,b=i.style,n=i.baseline,o=i.color);l.size&&l.size<3&&(w*=l.size),g=g!=="normal"&&g?parseFloat(g):w*(7/6),l.height&&l.height<3&&(g*=l.height);var z=Object.create(k);return z.family=l.family||e||"sans-serif",z.height=g??14,z.size=w??12,z.variant=l.variant||A||"",z.style=l.style||b||"",z.weight=l.weight||x||"",z.baseline=n||0,l.baseline!=null&&(z.baseline=l.baseline),z.color=l.color||o||"",z.id=m.call(z,!0),z}const P={"\n":.28,"\r":.28," ":.28," ":.28," ":.28,"᠎":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"​":0," ":.16," ":.22," ":1,"\uFEFF":0};var S,Y=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var o=n.getContext("2d");if(o&&typeof o.measureText=="function")return function(i,l){return o.font=String(l),o.measureText(i).width}}}(typeof document<"u"?document:null)||(S={},function(e,n){if(!S[n]){var o=E(n);S[n]=o,/\bmonospace\b/.test(o.family)?o.size*=.6:(o.size*=.45,o.weight&&(o.size*=1.18))}return e.length*S[n].size}),$={},L={trim:!0,collapse:!0};function W(e,n,o){var i=Object.assign({},L,o),l=String(e);if(!l)return 0;if(l in P){var g=n.id+"/"+l;return g in $||($[g]=Y("_".concat(l,"_"),n)-Y("__",n)),$[g]}return i.trim&&i.collapse?i.trim?l=l.trim():i.collapse&&(l=l.replace(/\s+/g," ")):l=l.replace(/\n/g," "),Y(l,n)+n.size*(e.tracking||0)}function st(e){return st=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},st(e)}function le(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&he(e,n)}function he(e,n){return he=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,i){return o.__proto__=i,o},he(e,n)}function ce(e){var n=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var o,i=Bt(e);if(n){var l=Bt(this).constructor;o=Reflect.construct(i,arguments,l)}else o=i.apply(this,arguments);return pn(this,o)}}function pn(e,n){if(n&&(st(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}(e)}function Bt(e){return Bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Bt(e)}function qt(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function Re(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(l=function(g,w){if(st(g)!=="object"||g===null)return g;var x=g[Symbol.toPrimitive];if(x!==void 0){var b=x.call(g,w);if(st(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),st(l)==="symbol"?l:String(l)),i)}var l}function Vt(e,n,o){return n&&Re(e.prototype,n),o&&Re(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}var j=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";qt(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return Vt(e,[{key:"clone",value:function(){var n=new e(this.value);return n.value=this.value,n.weight=this.weight,n.style=this.style,n.font=this.font,n.href=this.href,n.sub=this.sub,n.sup=this.sup,n}},{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}}]),e}(),zt=function(e){le(o,e);var n=ce(o);function o(){return qt(this,o),n.apply(this,arguments)}return Vt(o)}(j),nt=function(e){le(o,e);var n=ce(o);function o(){return qt(this,o),n.apply(this,arguments)}return Vt(o)}(j),xt=function(e){le(o,e);var n=ce(o);function o(){return qt(this,o),n.apply(this,arguments)}return Vt(o)}(j),ue=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,gn=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Fe=/^[\xA0\u2011\u202F\u2060\uFEFF]/,yn=/^(?:[;\xAD%?…]|,(?!\d))/,mn=/^[´±°¢£¤$¥\u2212]/;function Ut(e,n){n!==!1&&(e=e.trim());for(var o,i,l=[],g=e.charAt(0),w=0,x=1,b=e.length;x<b;x++){o=e.charAt(x),i=e.charAt(x+1);var A=ue.test(g),D=ue.test(o),M=D||A,I=void 0;if((mn.test(o)&&!Fe.test(g)||yn.test(g+i)&&!Fe.test(o))&&(M=!0),g!=="-"&&g!=="‐"&&g!=="–"&&g!=="—"||((I=ue.test(e.charAt(x-2)))&&!D&&(M=!1),!I&&gn.test(o+i)&&(M=!0)),M){var z=e.slice(w,x);/\u00AD$/.test(z)?(l.push(new j(z.slice(0,-1))),l.push(new xt)):(l.push(new j(z)),l.push(new zt)),w=x}g=o}return l.push(new j(e.slice(w))),l}const Be={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"⊥",or:"⊦",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›"};var vn=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,xn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,wn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,bn=/^<!--(.+?)-->/,An=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,qe={b:function(e){e.weight="bold"},strong:function(e){e.weight="bold"},i:function(e){e.style="italic"},em:function(e){e.style="italic"},dfn:function(e){e.style="italic"},cite:function(e){e.style="italic"},code:function(e){e.family="monospace"},kbd:function(e){e.family="monospace"},samp:function(e){e.family="monospace"},var:function(e){e.family="monospace"},tt:function(e){e.family="monospace"},sub:function(e){e.sub=!0},sup:function(e){e.sup=!0}},Sn={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function Ve(e){return e.replace(An,function(n,o,i,l){if(o||i){var g=o?10:16;return String.fromCharCode(parseInt(o||i,g))}return l in Be?Be[l]:n})}function En(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var kn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Tn(e){var n,o={};if(e){do if(n=kn.exec(e)){var i=Ve(En(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(o[n[1]]=i,(e=e.slice(n[0].length)).length&&/^\S/.test(e[0]))throw new Error("Attribute error")}while(n&&e.length);if(/\S/.test(e))throw new Error("Attribute error")}return o}const Ue={copyright:"©",textcopyright:"©",dag:"†",textdagger:"†",ddag:"‡",textdaggerdbl:"‡",guillemotleft:"«",guillemotright:"»",guilsinglleft:"‹",guilsinglright:"›",ldots:"…",dots:"…",textellipsis:"…",lq:"‘",P:"¶",textparagraph:"¶",pounds:"£",textsterling:"£",quotedblbase:"„",quotesinglbase:"‚",rq:"’",S:"§",sim:"~",textasciicircum:"^",textasciitilde:"˜",texttildelow:"~",textasteriskcentered:"*",textbackslash:"'",textbar:"|",textbardbl:"╎",textbigcircle:"◯",textbraceleft:"{",textbraceright:"}",textbullet:"•",textdollar:"$",textemdash:"—",textendash:"—",texteuro:"€",eurosym:"€",euro:"€",textexclamdown:"¡",textgreater:">",textless:"<",textordfeminine:"ª",textordmasculine:"º",textperiodcentered:"·",cdot:"·",textquestiondown:"¿",textquotedblleft:"“",textquotedblright:"”",textquoteleft:"‘",textquoteright:"’",textquotestraightbase:"‚",textquotestraightdblbase:"„",textregistered:"®",textthreequartersemdash:"-",texttrademark:"™",texttwelveudash:"-",textunderscore:"_",textvisiblespace:"␣",gets:"←",textleftarrow:"←",to:"→",textrightarrow:"→",textdegree:"°",infty:"∞",triangle:"△",triangledown:"▽",blacktriangle:"▲",blacktriangledown:"▼",angle:"∠",sphericalangle:"∢",aleph:"ℵ",hbar:"ħ",imath:"𝚤",jmath:"𝚥",ell:"ℓ",wp:"℘",Re:"ℜ",Im:"ℑ",mho:"℧",prime:"′",emptyset:"∅",nabla:"∇",surd:"√",partial:"∂",top:"⟙",bot:"⟂",vdash:"⟝",dashv:"⟞",forall:"∀",exists:"∃",nexists:"∄",neg:"¬",lnot:"¬",flat:"♭",natural:"♮",sharp:"♯",backslash:"\\",Box:"□",Diamond:"♢",clubsuit:"♣",diamondsuit:"♦",heartsuit:"♥",spadesuit:"♠",Join:"⨝",blacksquare:"■",bigstar:"★",diagdown:"╲",diagup:"╱",blacklozenge:"⧫",rfloor:"⌋",lfloor:"⌊",rceil:"⌉",lceil:"⌈",rangle:"⟩",langle:"⟨",sum:"∑",int:"∫",oint:"∮",prod:"∏",coprod:"∏",bigcap:"∩",bigcup:"∪",bigsqcup:"⊔",bigvee:"∨",bigwedge:"∧",bigodot:"⊙",bigotimes:"⊗",bigoplus:"⊕",biguplus:"⊎",alpha:"α",beta:"β",chi:"χ",delta:"δ",epsilon:"ε",eta:"η",gamma:"γ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",omega:"ω",phi:"φ",pi:"π",psi:"ψ",rho:"ρ",sigma:"σ",tau:"τ",theta:"θ",upsilon:"υ",xi:"ξ",zeta:"ζ",Alpha:"Α",Beta:"Β",Chi:"Χ",Delta:"Δ",Epsilon:"Ε",Eta:"Η",Gamma:"Γ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Omega:"Ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Theta:"Θ",Upsilon:"Υ",Xi:"Ξ",Zeta:"Ζ",aa:"å",AA:"Å",ae:"æ",AE:"Æ",dh:"ð",DH:"Ð",dj:"đ",DJ:"Đ",ij:"ij",IJ:"IJ",l:"ł",L:"Ł",ng:"ŋ",NG:"Ŋ",o:"ø",O:"Ø",oe:"œ",OE:"Œ",ss:"ß",SS:"SS",th:"þ",TH:"Þ"};var In=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,_n=/^%[^\n]+(?:\n|$)/,On=/^[^#$%&~_^\\{}]+/,Dn=/^\\([&{}$%#_])/,Mn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,zn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},U={bf:function(e){e.weight="bold"},it:function(e){e.style="italic"},sl:function(e){e.style="italic"},color:function(e,n){e.color=n},href:function(e,n){e.href=n},"^":function(e){e.sup=!0},_:function(e){e.sub=!0},par:function(e){this.tokens.push(new nt,new nt)},newline:function(e){this.tokens.push(new nt)},url:function(e,n){this.open_context().href=n,this.add_token(new j(n)),this.close_context()}};U.textsuperscript=U["^"],U.textsubscript=U._,U.textsl=U.sl,U.mathbf=U.bf,U.mathit=U.it,U.textbf=U.bf,U.textit=U.it,U.textcolor=U.color;var Ln=/[\r\n\xA0]+/g;function Cn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var o=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(o=E(n,e)),o}function Ye(e,n,o){for(var i,l,g=e.width;g+o.width>n&&e.length;)l=(i=e[e.length-1]).width,i.width>o.width?(i.value=i.value.slice(0,-1),i.width=W(i,i.font),g+=i.width):e.pop(),g-=l;e[e.length-1]instanceof xt&&e.pop(),i=e[e.length-1]||i||{},o.font=E(o.font,i.bold,i.italic,""),o.href=e.length?i.href:null,o.rel=e.length?i.rel:null,o.target=e.length?i.target:null,e.push(o)}function kt(e){return Math.round(1e6*e)/1e6}function Xe(e){return function(n){if(Array.isArray(n))return de(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,o){if(n){if(typeof n=="string")return de(n,o);var i=Object.prototype.toString.call(n).slice(8,-1);return i==="Object"&&n.constructor&&(i=n.constructor.name),i==="Map"||i==="Set"?Array.from(n):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?de(n,o):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function de(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}var Pn={center:"middle",right:"end"},Nn={middle:.5,center:.5,bottom:1,end:1},fe=function(e,n){return!e&&!n||e===n};function $n(e,n){var o=[],i=n.font(),l=i.size,g=i.family,w=n.align(),x=n.createElement();if(e.length){var b=i.height,A=n.valign(),D=n.height()(),M=n.width()(0),I=!isFinite(M)&&e.length===1,z=I?null:n.x(),R=kt(b/l),J=I?null:kt(b/(1.15*l+(b-l)/2));if(Nn[A]&&isFinite(D)){var N=A==="bottom"?1:.5;J+=(D*N-b*e.length*N)/l}var C=w==="justify",F=0;w==="right"?F=M:w==="center"&&(F=M/2);for(var H=[],Q="tspan",X=null,B="",O=function(){if(B){var wt=x(Q,X,B);H.push(wt)}Q="tspan",X=null,B=""},it=0,tt=e.length;it<tt;it++){var ut="",gt="",lt=0,dt=e[it];if(dt.length){H=[];for(var Tt=0,Pt=0,ft=void 0,G=0,Yt=dt.length;G<Yt;G++){var V=dt[G],Z=V.font;V.whitespace&&Tt++,Pt+=V.width,G&&!V.tracking&&!lt&&fe(Z.id,ut)&&fe(V.class,gt)&&fe(ft,V.href)?B+=V.value:(O(),B=V.value,X={fontFamily:Z.family!==g?Z.family:null,fontSize:Z.size!==l?Z.size:null,fontWeight:Z.weight||null,fontStyle:Z.style||null,fontVariant:Z.variant!=="normal"&&Z.variant||null,fill:Z.color||null,baselineShift:Z.baseline?100*Z.baseline+"%":null,className:V.class||null},lt&&(X.dx=kt(lt),lt=0),V.tracking&&(lt=Z.size*V.tracking),V.href&&!ft?(ft=V.href,Q="a",X.href=ft,X.rel=V.rel,X.target=V.target):ft=null,ut=Z.id,gt=V.class)}if(O(),I)o.push.apply(o,Xe(H));else{var Xt=null,Nt=it===tt-1||dt[dt.length-1]instanceof nt;C&&dt.length>1&&!Nt&&(Xt=kt((M-Pt)/Tt)),o.push(x.apply(void 0,["tspan",{wordSpacing:Xt,x:z(it)+F,dy:kt(it?R:J)+"em"}].concat(Xe(H))))}}else o.push(x("tspan",{x:z(it),dy:kt(it?R:J)+"em"}," "))}}return x.apply(void 0,["text",{fontFamily:g,fontSize:l,textAnchor:Pn[w]||"start"}].concat(o))}var Hn={middle:.5,center:.5,bottom:1,end:1};function jn(e,n,o){if(e.length){o.textBaseline="middle";var i=n.font(),l=i.height,g=i.size,w=n.valign(),x=n.height()(),b=n.width()(0),A=n.align(),D=A==="justify",M=.5*l,I=Hn[w];if(I&&isFinite(x)){var z=e.length*l;M+=x*I-z*I}e.forEach(function(R,J){var N=n.x()(J),C=J*l+M,F=0,H=0;R.forEach(function(B){B.whitespace&&F++,H+=B.width});var Q=0,X=J===e.length-1||R[R.length-1]instanceof nt;D&&R.length>1&&!X&&(Q=(b-H)/F),R.forEach(function(B){o.font=B.font;var O=B.font,it=O.baseline?g*-O.baseline+.15*g:0;o.fillStyle=function(gt,lt){return gt.color?gt.color:lt.href?"#00C":"#000"}(O,B);var tt=0;if(A==="right"?tt+=b-H:A==="center"?tt+=b/2-H/2:A==="justify"&&(B.whitespace||B instanceof nt)&&(N+=Q),o.fillText(B.value,N+tt,C+it),B.href){o.beginPath(),o.strokeStyle=o.fillStyle;var ut=Math.floor(C+.45*g)+.5;o.moveTo(N+tt,ut),o.lineTo(N+tt+B.width,ut),o.stroke()}N+=B.width})})}}function pe(e){return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},pe(e)}function Ge(e){for(var n={},o=0;o<e.length;o++){var i=e[o];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:pe(i)==="object"&&i._groups?n.d3=i:i&&i.nodeType&&i.getContext?n.ctx=i.getContext("2d"):i&&i.fillText&&i.beginPath?n.ctx=i:i&&(n.text=i))}return n}function Lt(e){return Lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Lt(e)}function Rn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(l=function(g,w){if(Lt(g)!=="object"||g===null)return g;var x=g[Symbol.toPrimitive];if(x!==void 0){var b=x.call(g,w);if(Lt(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Lt(l)==="symbol"?l:String(l)),i)}var l}var Fn=E(),ge=function(e){return typeof e=="function"?e:function(){return e}},ot=function(){function e(i){if(function(g,w){if(!(g instanceof w))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={overflow:"ellipsis",lineclamp:null,align:"left",wordBreak:null,valign:"top",width:function(){return 1/0},height:function(){return 1/0},x:function(){return 0},font:null,tAnchor:0,parser:e.defaultparser},i)for(var l in i)typeof this[l]=="function"&&this[l](i[l])}var n,o;return n=e,o=[{key:"linebreak",value:function(i){var l=this,g=this.props.parser(String(i)),w=this.font(),x=function(b,A,D){if(!b.length)return[];var M=A.height(),I=A.width(),z=A.overflowLine(),R=A.overflowWrap(),J=E(D,!0,!1),N=isFinite(M())?Math.floor(M()/D.height):1/0;if(!M()&&!I(0)||!N)return[];for(var C=0,F=0,H=0,Q=[],X=[],B=!1;C<b.length&&F<N;){var O=b[C],it=Cn(O,D);if(O.width=W(O,it),O.font=it,O.line=F,O.whitespace=O.value in P,O.value&&(O.value=O.value.replace(Ln," ")),!(!H&&O.whitespace||B&&O.whitespace))if(O instanceof nt)H=0,X=[],Q.push(C+1),F++;else if(O instanceof zt||O instanceof xt)X.push({index:C,width:H});else if(O.whitespace||H+O.width<I(F))H+=O.width;else if(X.length){var tt=void 0,ut=void 0;do{ut=!0,tt=X.pop();var gt=b[tt.index],lt=void 0;gt instanceof xt&&(lt=W("-",gt.font),tt.width+lt>I(F)&&(ut=!X.length))}while(!ut);Q.push(tt.index+1),H=0,F++,C=tt.index,X=[]}else if(R==="break-word"){var dt=I(F);if(H+O.width>dt){var Tt=O.clone();do O.value=O.value.slice(0,-1),O.width=W(O,O.font),H+=O.width;while(O.value&&O.width>dt);Tt.value=Tt.value.slice(O.value.length),b.splice(C+1,0,new zt,Tt)}Q.push(C+1),H=0,F++}else H+=O.width;C++,B=O.whitespace}C!==Q[Q.length-1]&&Q.push(C);var Pt=0,ft=0,G=Q.map(function(wt){for(var K,bt=Pt;(K=b[bt])&&(K.whitespace||!K.value);)bt++;for(var yt=wt,ve=null;yt>bt&&(K=b[yt-1])&&(K.whitespace||!(K.value||K instanceof xt));)K instanceof nt&&(ve=K),yt--;K instanceof xt&&(K.value="-",K.width=W("-",K.font)),Pt=wt;var It=b.slice(bt,yt).filter(function(xe){return xe.value});return ve&&It.push(ve),It.width=It.reduce(function(xe,Yn){return xe+Yn.width},0),It.width>ft&&(ft=It.width),It});if(G.hasLineOverflow=!1,z){var Yt=z==="ellipsis"?"…":z;G.forEach(function(wt,K){var bt=I(K);if(wt.width>bt){var yt=new j(Yt);yt.font=D,yt.width=W(Yt,J),Ye(wt,bt,yt),G.hasLineOverflow=!0}})}var V=A.overflow()==="ellipsis"?"…":A.overflow();if(V&&C!==b.length){var Z=I(G.length-1),Xt=G[G.length-1],Nt=new j(V);Nt.font=D,Nt.width=W(V,J),Ye(Xt,Z,Nt),G.hasOverflow=!0}else G.hasOverflow=!1;return G.font=D,G.width=ft,G}(g,this,w);return x.height=x.length*w.height,x.render=function(b){return l.render(x,b)},x.svg=x.render,x.draw=x.render,x}},{key:"font",value:function(i){return arguments.length?(this.props.font=E(i),this):this.props.font||E(Fn)}},{key:"overflow",value:function(i){return arguments.length?(this.props.overflow=String(i),this):this.props.overflow}},{key:"overflowLine",value:function(i){return arguments.length?(this.props.lineclamp=String(i),this):this.props.lineclamp}},{key:"valign",value:function(i){return arguments.length?(this.props.valign=i,this):this.props.valign}},{key:"align",value:function(i){if(!arguments.length)return this.props.align;var l=String(i).toLowerCase();return l==="left"||l==="start"?(this.props.align="left",this.props.tAnchor=0):l==="center"||l==="middle"?(this.props.align="center",this.props.tAnchor=-.5):l==="end"||l==="right"?(this.props.align="right",this.props.tAnchor=-1):l==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var l=String(i).toLowerCase();return l==="break-word"?this.props.overflowWrap="break-word":l!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=ge(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=ge(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=ge(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var l=e[i]||e[i+"parser"];typeof l=="function"&&(i=l)}if(typeof i!="function")throw new Error("Unknown parser: "+i);return this.props.parser=i,this}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var i=Ge(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?jn(i.text,this,i.ctx):$n(i.text,this)}}],o&&Rn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function Ct(e){return Ct=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ct(e)}function ye(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}function Bn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(l=function(g,w){if(Ct(g)!=="object"||g===null)return g;var x=g[Symbol.toPrimitive];if(x!==void 0){var b=x.call(g,w);if(Ct(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}(i.key,"string"),Ct(l)==="symbol"?l:String(l)),i)}var l}var Ze=function(e){return typeof e=="function"?e:function(){return e}},We=function(){function e(i){if(function(g,w){if(!(g instanceof w))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},i)for(var l in i)typeof this[l]=="function"&&this[l](i[l]);this.render=this.render.bind(this)}var n,o;return n=e,o=[{key:"anchor",value:function(i){var l=this.props,g=l.hAnchor,w=l.vAnchor,x=l.width,b=l.height;if(!arguments.length)return[g*x(0),w*b(0)];if(typeof i=="string"){var A=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(D){D==="top"&&(A.vAnchor=-0),D==="middle"&&(A.vAnchor=-.5),D==="bottom"&&(A.vAnchor=-1),D==="left"&&(A.hAnchor=-0),D==="center"&&(A.hAnchor=-.5),D==="right"&&(A.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=Ze(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=Ze(i),this):this.props.height}},{key:"rotate",value:function(i){return arguments.length?(this.props.rotation=i,this):this.props.rotation}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(i,l){var g,w=i.getContext?i.getContext("2d"):i;return w.save(),w.rotate(this.rotate()*Math.PI/180),w.translate.apply(w,function(x){if(Array.isArray(x))return ye(x)}(g=this.anchor())||function(x){if(typeof Symbol<"u"&&x[Symbol.iterator]!=null||x["@@iterator"]!=null)return Array.from(x)}(g)||function(x,b){if(x){if(typeof x=="string")return ye(x,b);var A=Object.prototype.toString.call(x).slice(8,-1);return A==="Object"&&x.constructor&&(A=x.constructor.name),A==="Map"||A==="Set"?Array.from(x):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?ye(x,b):void 0}}(g)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),l(w),w.restore(),w}},{key:"render",value:function(){var i=Ge(arguments);if(i.d3)return i.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(i.ctx)return this.canvas(i.ctx,i.fn);if(i.text){var l=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},l)}}}],o&&Bn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}(),qn=Object.prototype.hasOwnProperty,me={};function Vn(e){return me[e]||(me[e]=e.replace(/([a-z])([A-Z])/g,function(n,o,i){return o+"-"+i.toLowerCase()})),me[e]}function Ke(e,n){if(Array.isArray(n))return n.forEach(function(o){return Ke(e,o)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function Je(e,n){if(typeof document<"u"){var o=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&o.setAttribute)for(var i in n)qn.call(n,i)&&n[i]!=null&&o.setAttribute(i==="className"?"class":Vn(i),n[i]);for(var l=arguments.length,g=new Array(l>2?l-2:0),w=2;w<l;w++)g[w-2]=arguments[w];return g!=null&&g.length&&g.forEach(function(x){Ke(o,x)}),o}}ot.createElement=Je,ot.textparser=Ut,ot.defaultparser=Ut,ot.htmlparser=function(e){e=String(e||"").trim();for(var n,o,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},l=[],g=[],w=function(M){for(var I in i)i[I]&&(M[I]=i[I]);l.push(M)},x=function(M){var I=l.length,z=Sn[M];if(I&&z){for(var R=I-1;l[R]&&(l[R]instanceof zt||vn.test(l[R].value));)R--;for(;z&&l[R]&&l[R]instanceof nt;)R--,z--;for(;z-- >0;)l.push(new nt)}};e.length;){if(n=/^[^<]+/.exec(e))Ut(Ve(n[0]),!1).forEach(w);else if(!(n=bn.exec(e)))if(n=xn.exec(e))g.length&&(i=g.pop()),x(n[1]);else if(n=wn.exec(e)){var b=n[1];x(b),g.push(i),i=Object.create(i),qe[b]&&qe[b](i,"");var A=Tn(n[2]);b==="a"&&(A.href&&(i.href=A.href),A.rel&&(i.rel=A.rel),A.target&&(i.target=A.target)),A.class&&(i.class=i.class?i.class+" "+A.class:A.class),A.style&&(o=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(A.style))&&o[1]&&(i.color=o[1]),b==="br"&&l.push(new nt)}else n=[e.slice(0,1)],w(new j(n[0]));e=e.slice(n[0].length)}for(var D=l[l.length-1];D instanceof nt;)l.pop(),D=l[l.length-1];return l},ot.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function(N,C){return n.push(C),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(Mn,function(N,C,F){return F.charAt(C-1)==="\\"?N:zn[N]}).replace(/\n\s+/g,function(N){return/\n/.test(N.slice(1))?"\\par ":N}).replace(/\\symbol\{(\d+)\}/,function(N,C,F,H){return H.charAt(F-1)==="\\"?N:String.fromCharCode(1*C)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function(N,C,F,H){return C+F+"{"+H+"}"}).replace(/\\verb,(.*?),/,function(N,C){return"\\verb,".concat(n[+C],",")});for(var o,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},l=[],g=[],w=function(N){for(var C in i)i[C]&&(N[C]=i[C]);return l.push(N),N},x=function(){g.push(i),i=Object.create(i)},b=function(){if(!g.length)throw new Error("Unexpected }");i=g.pop()},A={tokens:l,open_context:x,close_context:b,add_token:w};e.length;){if(o=On.exec(e))Ut(o[0],!1).forEach(w);else if(o=Dn.exec(e))w(new j(o[1]));else if(!(o=_n.exec(e))){if(o=/^\{/.exec(e))x();else if(o=/^\}/.exec(e))b();else if(!(o=/^\$/.exec(e)))if(o=/^\\verb,([^,]+),/.exec(e))w(new j(o[1]));else if(o=In.exec(e)){var D=o[1].slice(1)||o[1],M=!!o[2];if(/^(La)?TeX$/i.test(D)){x(),i.family="serif";var I=void 0;D==="LaTeX"&&((I=w(new j("L"))).tracking=-.25,(I=w(new j("A"))).size=.7,I.baseline=.3,I.tracking=-.1),(I=w(new j("T"))).tracking=-.17,(I=w(new j("E"))).baseline=-.22,I.tracking=-.13,I=w(new j("X")),b()}else if(D in Ue)w(new j(Ue[D])),M&&x();else if(D in U){var z=[],R=U[D].length-1,J=void 0;if(R){for(M=!1,e=e.slice(o[0].length-1);R--;){if(!(J=/^\{([^}]+)\}/.exec(e)))throw new Error(D+" is missing an argument");z.push(J[1]),e=e.slice(J[0].length)}o[0]=/^\{/.exec(e)?"{":"",M=!!o[0]}M&&x(),U[D].apply(A,[i].concat(z))}else console.warn("unknown latex command",D),w(new j(o[1])),M&&x()}else o=[e.slice(0,1)],w(new j(o[0]))}e=e.slice(o[0].length)}return l},ot.measureText=function(e,n,o){return W(e,E(n),o)},ot.Token=j,ot.Break=zt,ot.LineBreak=nt,ot.SoftHyphen=xt,ot.Rotator=We,We.createElement=Je;const Un=ot;return r.default})())})(Ce);var hn=Ce.exports;const Pe=ht(hn);function cn(u,h){const t=ct(u),{fontSize:r,font:a,padding:c=0}=u.properties.style||{};if(t.width===t.height&&t.width===0)return;const f=new Pe({font:`${r}px/${r}px ${a}`.replace(/(px)+/g,"px"),width:t.width-c*2,height:t.height-c*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Pe.createElement}).linebreak(u.properties.content.replaceAll(`
10
- `,"<br>")).render();f.setAttribute("transform",`translate(${c}, ${c})`),h.appendChild(f)}const Ne=20;class $e extends _e{constructor(t,r={}){super(t,`
7
+ `);v(this,"draggedHandle",B);v(this,"start",{x:0,y:0});v(this,"end",{x:0,y:0});v(this,"arrow",{...Wt});v(this,"startX",0);v(this,"startY",0);v(this,"minArrowHeight",0);v(this,"maxArrowHeight",0);v(this,"handles",[]);v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=te(t.target))});v(this,"onMouseUp",()=>{this.draggedHandle!==-1&&(this.restoreDragging(),this.isDragging=!1,this.draggedHandle=B,this.emit(Tt,this.arrow))});v(this,"onMouseMove",t=>{if(!this.isDragging||this.draggedHandle===B)return;const r=this.handles[this.draggedHandle],a=this.ogma.view.getAngle(),{x:c,y:f}=new X(t.clientX-this.startX,t.clientY-this.startY).divScalar(this.ogma.view.getZoom()).rotateRadians(a),g=r.id===Oe,p=r.id===De,s=r.id===Me;(g||p)&&Jt(this.arrow,this.start.x+c,this.start.y+f),(g||s)&&Qt(this.arrow,this.end.x+c,this.end.y+f),this.emit(Ft,this.arrow,g?"line":p?"start":"end"),this.refreshEditor(),this.layer.refresh()});this.minArrowHeight=r.minArrowHeight||0,this.maxArrowHeight=r.maxArrowHeight||1e6,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".arrow-handle>.handle")),this.handles.forEach(a=>a.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseup",this.onMouseUp)}startDrawing(t,r,a=be(t,r,t,r,St)){var g;this.add(a),this.hoveredId=a.id;const c=this.ogma.view.graphToScreenCoordinates({x:t,y:r}),f=((g=this.ogma.getContainer())==null?void 0:g.getBoundingClientRect())||{left:0,top:0};this.startDragging(this.getById(a.id),c.x+(f==null?void 0:f.left),c.y+f.top),this.draggedHandle=2}cancelDrawing(){this.isDragging&&(this.remove(this.arrow.id),this.emit(Tt,this.arrow),this.restoreDragging(),this.isDragging=!1,this.draggedHandle=B)}startDragging(t,r,a){this.selectedId!==t.id&&this.select(this.hoveredId),this.arrow=t,this.startX=r,this.startY=a,this.start=kt(this.arrow),this.end=Mt(this.arrow),this.disableDragging(),this.emit(Bt,this.arrow),this.isDragging=!0}detect(t,r=0){return this.elements.find(a=>{const{start:c,end:f}=zt(a),g=new X(t.x,t.y).sub(new X((c.x+f.x)/2,(c.y+f.y)/2)),p=new X(f.x,f.y).sub(new X(c.x,c.y)),s=p.length(),d=p.normalize(),m=Ee(a);return Math.abs(d.dot(g))<s/2+r&&Math.abs(d.rotateRadians(Math.PI/2).dot(g))<m/2+r})}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.selectedId!==B?this.getById(this.selectedId):this.getById(this.hoveredId),r=zt(t),a=this.ogma.view.graphToScreenCoordinates(r.start),c=this.ogma.view.graphToScreenCoordinates(r.end),f=Math.min(this.ogma.view.getZoom(),this.maxHandleScale),[g,p,s]=Array.prototype.slice.call(this.editor.element.querySelectorAll(".handle"));p.style.transform=`translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${f})`,s.style.transform=`translate(${c.x}px, ${c.y}px) translate(-50%, -50%) scale(${f}`;const d={x:(c.x+a.x)/2,y:(c.y+a.y)/2},m=new X(c.x-a.x,c.y-a.y),A=m.mul(1/m.length()),T=Math.atan2(A.y,A.x);g.style.width=`${m.length()}px`,g.style.left=`${d.x}px`,g.style.top=`${d.y}px`,g.style.transform=`translate(-50%, -50%) rotate(${T}rad)`}getDefaultOptions(){return Wt}draw(t){t.innerHTML="";const r=Et("g");this.elements.forEach(a=>nn(a,r,St,this.minArrowHeight,this.maxArrowHeight)),t.appendChild(r)}destroy(){super.destroy(),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseup",this.onMouseUp)}}const vt={font:"sans-serif",fontSize:12,color:"black",background:"",strokeWidth:1,strokeColor:"#000",strokeType:"plain"},qt={id:0,type:"Feature",properties:{type:"text",content:"",style:{...vt}},geometry:{type:"Polygon",coordinates:[[[0,0],[100,0],[100,50],[0,50],[0,0]]]}},oe={handleSize:3.5,placeholder:"Your text..."},Le=(u=0,l=0,t=100,r=50,a="",c={...vt})=>({id:Rt(),type:"Feature",properties:{type:"text",content:a,style:{...vt,...c}},geometry:{type:"Polygon",coordinates:[[[u,l],[u+t,l],[u+t,l+r],[u,l+r],[u,l]]]}});var Ce={exports:{}};(function(u,l){(function(t,r){u.exports=r()})(it,()=>(()=>{var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},r={};function a(e){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},a(e)}t.d(r,{default:()=>Un});var c=/^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/,f=/\bsmall-caps\b/,g=/\b(?:italic|oblique)\b/,p=/\bbold(?:er)?\b/,s=13.3333333,d={"xx-small":9,"x-small":10,smaller:13.3333,small:13,medium:16,large:18,larger:19.2,"x-large":24,"xx-large":32};function m(e){var n="",o=this;return o.style&&o.style!=="normal"&&(n+=o.style),o.variant&&o.variant!=="normal"&&(n+=(n?" ":"")+o.variant),o.weight&&o.weight!=="normal"&&(n+=(n?" ":"")+o.weight),o.size&&(n+=(n?" ":"")+o.size+"px",o.height!==o.size&&(n+="/"+o.height+"px")),o.family&&(n+=(n?" ":"")+o.family),e&&(n+="::"+o.baseline),e&&(n+="::"+o.color),n}var A={id:"",family:"sans-serif",height:14,size:12,variant:"",style:"",weight:"",baseline:"",color:null,toString:m,valueOf:m};function T(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=c.exec(e);n.family=(o[6]||"").trim();var i=d[o[2]]||parseFloat(o[2]);o[3]==="%"?i*=.16:o[3]==="em"?i*=16:o[3]==="pt"&&(i*=s),n.size=i;var h=parseFloat(o[4]);if(h!=="normal"&&h!=="inherit"&&h?o[5]&&o[5]!=="em"?o[5]==="pt"?n.height=h*s:o[5]==="%"?n.height=.01*i:n.height=h:n.height=h*i:n.height=Math.round(i*(7/6)),f.test(o[1])&&(n.variant="small-caps"),g.test(o[1])&&(n.style="italic"),p.test(o[1]))n.weight="bold";else{var y=parseInt(/\b(\d+)\b/.exec(o[1]),10);y>=100&&y!==400&&(n.weight=y)}return n}function S(){var e,n,o,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"12px/14px sans-serif",h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=14,x=12,w=null,b=null,E="";if(i&&i.nodeType){var M=i&&(i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView),z=M.getComputedStyle(i,null);e=z.getPropertyValue("font-family")||"",x=parseFloat(z.getPropertyValue("font-size")),y=z.getPropertyValue("line-height"),w=z.getPropertyValue("font-weight"),b=z.getPropertyValue("font-style"),E=z.getPropertyValue("font-variant")||""}else if(typeof i=="string"){var _=T(i);e=_.family,x=_.size,y=_.height,E=_.variant,b=_.style,w=_.weight}else a(i)==="object"&&(e=i.family,x=i.size,y=i.height,E=i.variant,w=i.weight,b=i.style,n=i.baseline,o=i.color);h.size&&h.size<3&&(x*=h.size),y=y!=="normal"&&y?parseFloat(y):x*(7/6),h.height&&h.height<3&&(y*=h.height);var L=Object.create(A);return L.family=h.family||e||"sans-serif",L.height=y??14,L.size=x??12,L.variant=h.variant||E||"",L.style=h.style||b||"",L.weight=h.weight||w||"",L.baseline=n||0,h.baseline!=null&&(L.baseline=h.baseline),L.color=h.color||o||"",L.id=m.call(L,!0),L}const P={"\n":.28,"\r":.28," ":.28," ":.28," ":.28,"᠎":0," ":.5," ":1," ":.5," ":1," ":.33," ":.25," ":.16," ":.56," ":.28," ":.2," ":.15,"​":0," ":.16," ":.22," ":1,"\uFEFF":0};var k,q=function(e){var n=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(100,100)||e&&e.createElement("canvas");if(n&&n.getContext){var o=n.getContext("2d");if(o&&typeof o.measureText=="function")return function(i,h){return o.font=String(h),o.measureText(i).width}}}(typeof document<"u"?document:null)||(k={},function(e,n){if(!k[n]){var o=S(n);k[n]=o,/\bmonospace\b/.test(o.family)?o.size*=.6:(o.size*=.45,o.weight&&(o.size*=1.18))}return e.length*k[n].size}),G={},D={trim:!0,collapse:!0};function Y(e,n,o){var i=Object.assign({},D,o),h=String(e);if(!h)return 0;if(h in P){var y=n.id+"/"+h;return y in G||(G[y]=q("_".concat(h,"_"),n)-q("__",n)),G[y]}return i.trim&&i.collapse?i.trim?h=h.trim():i.collapse&&(h=h.replace(/\s+/g," ")):h=h.replace(/\n/g," "),q(h,n)+n.size*(e.tracking||0)}function Z(e){return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Z(e)}function le(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&he(e,n)}function he(e,n){return he=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,i){return o.__proto__=i,o},he(e,n)}function ce(e){var n=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var o,i=Vt(e);if(n){var h=Vt(this).constructor;o=Reflect.construct(i,arguments,h)}else o=i.apply(this,arguments);return pn(this,o)}}function pn(e,n){if(n&&(Z(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}(e)}function Vt(e){return Vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Vt(e)}function Ut(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function je(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(h=function(y,x){if(Z(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var b=w.call(y,x);if(Z(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),Z(h)==="symbol"?h:String(h)),i)}var h}function Yt(e,n,o){return n&&je(e.prototype,n),o&&je(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}var H=function(){function e(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";Ut(this,e),this.value=n,this.weight=null,this.style=null,this.font=null,this.href=null,this.sub=!1,this.sup=!1}return Yt(e,[{key:"clone",value:function(){var n=new e(this.value);return n.value=this.value,n.weight=this.weight,n.style=this.style,n.font=this.font,n.href=this.href,n.sub=this.sub,n.sup=this.sup,n}},{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}}]),e}(),Ct=function(e){le(o,e);var n=ce(o);function o(){return Ut(this,o),n.apply(this,arguments)}return Yt(o)}(H),rt=function(e){le(o,e);var n=ce(o);function o(){return Ut(this,o),n.apply(this,arguments)}return Yt(o)}(H),xt=function(e){le(o,e);var n=ce(o);function o(){return Ut(this,o),n.apply(this,arguments)}return Yt(o)}(H),ue=/^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/,gn=/^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/,Fe=/^[\xA0\u2011\u202F\u2060\uFEFF]/,yn=/^(?:[;\xAD%?…]|,(?!\d))/,mn=/^[´±°¢£¤$¥\u2212]/;function Xt(e,n){n!==!1&&(e=e.trim());for(var o,i,h=[],y=e.charAt(0),x=0,w=1,b=e.length;w<b;w++){o=e.charAt(w),i=e.charAt(w+1);var E=ue.test(y),M=ue.test(o),z=M||E,_=void 0;if((mn.test(o)&&!Fe.test(y)||yn.test(y+i)&&!Fe.test(o))&&(z=!0),y!=="-"&&y!=="‐"&&y!=="–"&&y!=="—"||((_=ue.test(e.charAt(w-2)))&&!M&&(z=!1),!_&&gn.test(o+i)&&(z=!0)),z){var L=e.slice(x,w);/\u00AD$/.test(L)?(h.push(new H(L.slice(0,-1))),h.push(new xt)):(h.push(new H(L)),h.push(new Ct)),x=w}y=o}return h.push(new H(e.slice(x))),h}const Be={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"⊥",or:"⊦",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›"};var vn=/^[\n\r\x20\u2000-\u200B\u205F\u3000]/,wn=/^<\/([a-zA-Z0-9]+)([^>]*)>/,xn=/^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/,bn=/^<!--(.+?)-->/,An=/&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g,qe={b:function(e){e.weight="bold"},strong:function(e){e.weight="bold"},i:function(e){e.style="italic"},em:function(e){e.style="italic"},dfn:function(e){e.style="italic"},cite:function(e){e.style="italic"},code:function(e){e.family="monospace"},kbd:function(e){e.family="monospace"},samp:function(e){e.family="monospace"},var:function(e){e.family="monospace"},tt:function(e){e.family="monospace"},sub:function(e){e.sub=!0},sup:function(e){e.sup=!0}},Sn={div:1,li:1,blockquote:2,h1:2,h2:2,h3:2,h4:2,h5:2,h6:2,ul:2,ol:2,hr:2,p:2};function Ve(e){return e.replace(An,function(n,o,i,h){if(o||i){var y=o?10:16;return String.fromCharCode(parseInt(o||i,y))}return h in Be?Be[h]:n})}function En(e){return e&&e.length>1&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.slice(1,-1):e}var kn=/^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;function Tn(e){var n,o={};if(e){do if(n=kn.exec(e)){var i=Ve(En(n[2]||"")).replace(/[ \r\n\t]+/g," ").trim();if(o[n[1]]=i,(e=e.slice(n[0].length)).length&&/^\S/.test(e[0]))throw new Error("Attribute error")}while(n&&e.length);if(/\S/.test(e))throw new Error("Attribute error")}return o}const Ue={copyright:"©",textcopyright:"©",dag:"†",textdagger:"†",ddag:"‡",textdaggerdbl:"‡",guillemotleft:"«",guillemotright:"»",guilsinglleft:"‹",guilsinglright:"›",ldots:"…",dots:"…",textellipsis:"…",lq:"‘",P:"¶",textparagraph:"¶",pounds:"£",textsterling:"£",quotedblbase:"„",quotesinglbase:"‚",rq:"’",S:"§",sim:"~",textasciicircum:"^",textasciitilde:"˜",texttildelow:"~",textasteriskcentered:"*",textbackslash:"'",textbar:"|",textbardbl:"╎",textbigcircle:"◯",textbraceleft:"{",textbraceright:"}",textbullet:"•",textdollar:"$",textemdash:"—",textendash:"—",texteuro:"€",eurosym:"€",euro:"€",textexclamdown:"¡",textgreater:">",textless:"<",textordfeminine:"ª",textordmasculine:"º",textperiodcentered:"·",cdot:"·",textquestiondown:"¿",textquotedblleft:"“",textquotedblright:"”",textquoteleft:"‘",textquoteright:"’",textquotestraightbase:"‚",textquotestraightdblbase:"„",textregistered:"®",textthreequartersemdash:"-",texttrademark:"™",texttwelveudash:"-",textunderscore:"_",textvisiblespace:"␣",gets:"←",textleftarrow:"←",to:"→",textrightarrow:"→",textdegree:"°",infty:"∞",triangle:"△",triangledown:"▽",blacktriangle:"▲",blacktriangledown:"▼",angle:"∠",sphericalangle:"∢",aleph:"ℵ",hbar:"ħ",imath:"𝚤",jmath:"𝚥",ell:"ℓ",wp:"℘",Re:"ℜ",Im:"ℑ",mho:"℧",prime:"′",emptyset:"∅",nabla:"∇",surd:"√",partial:"∂",top:"⟙",bot:"⟂",vdash:"⟝",dashv:"⟞",forall:"∀",exists:"∃",nexists:"∄",neg:"¬",lnot:"¬",flat:"♭",natural:"♮",sharp:"♯",backslash:"\\",Box:"□",Diamond:"♢",clubsuit:"♣",diamondsuit:"♦",heartsuit:"♥",spadesuit:"♠",Join:"⨝",blacksquare:"■",bigstar:"★",diagdown:"╲",diagup:"╱",blacklozenge:"⧫",rfloor:"⌋",lfloor:"⌊",rceil:"⌉",lceil:"⌈",rangle:"⟩",langle:"⟨",sum:"∑",int:"∫",oint:"∮",prod:"∏",coprod:"∏",bigcap:"∩",bigcup:"∪",bigsqcup:"⊔",bigvee:"∨",bigwedge:"∧",bigodot:"⊙",bigotimes:"⊗",bigoplus:"⊕",biguplus:"⊎",alpha:"α",beta:"β",chi:"χ",delta:"δ",epsilon:"ε",eta:"η",gamma:"γ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",omega:"ω",phi:"φ",pi:"π",psi:"ψ",rho:"ρ",sigma:"σ",tau:"τ",theta:"θ",upsilon:"υ",xi:"ξ",zeta:"ζ",Alpha:"Α",Beta:"Β",Chi:"Χ",Delta:"Δ",Epsilon:"Ε",Eta:"Η",Gamma:"Γ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Omega:"Ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Theta:"Θ",Upsilon:"Υ",Xi:"Ξ",Zeta:"Ζ",aa:"å",AA:"Å",ae:"æ",AE:"Æ",dh:"ð",DH:"Ð",dj:"đ",DJ:"Đ",ij:"ij",IJ:"IJ",l:"ł",L:"Ł",ng:"ŋ",NG:"Ŋ",o:"ø",O:"Ø",oe:"œ",OE:"Œ",ss:"ß",SS:"SS",th:"þ",TH:"Þ"};var In=/^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/,_n=/^%[^\n]+(?:\n|$)/,On=/^[^#$%&~_^\\{}]+/,Dn=/^\\([&{}$%#_])/,Mn=/(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g,zn={"---":"—","--":"–","!`":"¡","?`":"¿","``":"“",",,":"„","''":"”","`":"‘","'":"’","<<":"«",">>":"»","~":" ","\\-":"­","\\,":" ","\\;":" ","\\:":" ","\\!":" ","\\@":"\uFEFF","\\\\":"\\newline{}"},U={bf:function(e){e.weight="bold"},it:function(e){e.style="italic"},sl:function(e){e.style="italic"},color:function(e,n){e.color=n},href:function(e,n){e.href=n},"^":function(e){e.sup=!0},_:function(e){e.sub=!0},par:function(e){this.tokens.push(new rt,new rt)},newline:function(e){this.tokens.push(new rt)},url:function(e,n){this.open_context().href=n,this.add_token(new H(n)),this.close_context()}};U.textsuperscript=U["^"],U.textsubscript=U._,U.textsl=U.sl,U.mathbf=U.bf,U.mathit=U.it,U.textbf=U.bf,U.textit=U.it,U.textcolor=U.color;var Ln=/[\r\n\xA0]+/g;function Cn(e,n){e.sup&&(e.baseline=.45,e.size=.7),e.sub&&(e.baseline=-.3,e.size=.7);var o=n;return(e.style||e.weight||e.baseline||e.color||e.size||e.family)&&(o=S(n,e)),o}function Ye(e,n,o){for(var i,h,y=e.width;y+o.width>n&&e.length;)h=(i=e[e.length-1]).width,i.width>o.width?(i.value=i.value.slice(0,-1),i.width=Y(i,i.font),y+=i.width):e.pop(),y-=h;e[e.length-1]instanceof xt&&e.pop(),i=e[e.length-1]||i||{},o.font=S(o.font,i.bold,i.italic,""),o.href=e.length?i.href:null,o.rel=e.length?i.rel:null,o.target=e.length?i.target:null,e.push(o)}function It(e){return Math.round(1e6*e)/1e6}function Xe(e){return function(n){if(Array.isArray(n))return de(n)}(e)||function(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}(e)||function(n,o){if(n){if(typeof n=="string")return de(n,o);var i=Object.prototype.toString.call(n).slice(8,-1);return i==="Object"&&n.constructor&&(i=n.constructor.name),i==="Map"||i==="Set"?Array.from(n):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?de(n,o):void 0}}(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function de(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}var Pn={center:"middle",right:"end"},$n={middle:.5,center:.5,bottom:1,end:1},fe=function(e,n){return!e&&!n||e===n};function Nn(e,n){var o=[],i=n.font(),h=i.size,y=i.family,x=n.align(),w=n.createElement();if(e.length){var b=i.height,E=n.valign(),M=n.height()(),z=n.width()(0),_=!isFinite(z)&&e.length===1,L=_?null:n.x(),R=It(b/h),tt=_?null:It(b/(1.15*h+(b-h)/2));if($n[E]&&isFinite(M)){var $=E==="bottom"?1:.5;tt+=(M*$-b*e.length*$)/h}var C=x==="justify",j=0;x==="right"?j=z:x==="center"&&(j=z/2);for(var N=[],et="tspan",W=null,F="",O=function(){if(F){var bt=w(et,W,F);N.push(bt)}et="tspan",W=null,F=""},st=0,nt=e.length;st<nt;st++){var dt="",gt="",ht=0,ft=e[st];if(ft.length){N=[];for(var _t=0,Nt=0,pt=void 0,K=0,Gt=ft.length;K<Gt;K++){var V=ft[K],J=V.font;V.whitespace&&_t++,Nt+=V.width,K&&!V.tracking&&!ht&&fe(J.id,dt)&&fe(V.class,gt)&&fe(pt,V.href)?F+=V.value:(O(),F=V.value,W={fontFamily:J.family!==y?J.family:null,fontSize:J.size!==h?J.size:null,fontWeight:J.weight||null,fontStyle:J.style||null,fontVariant:J.variant!=="normal"&&J.variant||null,fill:J.color||null,baselineShift:J.baseline?100*J.baseline+"%":null,className:V.class||null},ht&&(W.dx=It(ht),ht=0),V.tracking&&(ht=J.size*V.tracking),V.href&&!pt?(pt=V.href,et="a",W.href=pt,W.rel=V.rel,W.target=V.target):pt=null,dt=J.id,gt=V.class)}if(O(),_)o.push.apply(o,Xe(N));else{var Zt=null,Ht=st===nt-1||ft[ft.length-1]instanceof rt;C&&ft.length>1&&!Ht&&(Zt=It((z-Nt)/_t)),o.push(w.apply(void 0,["tspan",{wordSpacing:Zt,x:L(st)+j,dy:It(st?R:tt)+"em"}].concat(Xe(N))))}}else o.push(w("tspan",{x:L(st),dy:It(st?R:tt)+"em"}," "))}}return w.apply(void 0,["text",{fontFamily:y,fontSize:h,textAnchor:Pn[x]||"start"}].concat(o))}var Hn={middle:.5,center:.5,bottom:1,end:1};function Rn(e,n,o){if(e.length){o.textBaseline="middle";var i=n.font(),h=i.height,y=i.size,x=n.valign(),w=n.height()(),b=n.width()(0),E=n.align(),M=E==="justify",z=.5*h,_=Hn[x];if(_&&isFinite(w)){var L=e.length*h;z+=w*_-L*_}e.forEach(function(R,tt){var $=n.x()(tt),C=tt*h+z,j=0,N=0;R.forEach(function(F){F.whitespace&&j++,N+=F.width});var et=0,W=tt===e.length-1||R[R.length-1]instanceof rt;M&&R.length>1&&!W&&(et=(b-N)/j),R.forEach(function(F){o.font=F.font;var O=F.font,st=O.baseline?y*-O.baseline+.15*y:0;o.fillStyle=function(gt,ht){return gt.color?gt.color:ht.href?"#00C":"#000"}(O,F);var nt=0;if(E==="right"?nt+=b-N:E==="center"?nt+=b/2-N/2:E==="justify"&&(F.whitespace||F instanceof rt)&&($+=et),o.fillText(F.value,$+nt,C+st),F.href){o.beginPath(),o.strokeStyle=o.fillStyle;var dt=Math.floor(C+.45*y)+.5;o.moveTo($+nt,dt),o.lineTo($+nt+F.width,dt),o.stroke()}$+=F.width})})}}function pe(e){return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},pe(e)}function Ge(e){for(var n={},o=0;o<e.length;o++){var i=e[o];typeof i!="number"&&i!=null&&(typeof i=="string"?n.text=i:typeof i=="function"?n.fn=i:pe(i)==="object"&&i._groups?n.d3=i:i&&i.nodeType&&i.getContext?n.ctx=i.getContext("2d"):i&&i.fillText&&i.beginPath?n.ctx=i:i&&(n.text=i))}return n}function Pt(e){return Pt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Pt(e)}function jn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(h=function(y,x){if(Pt(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var b=w.call(y,x);if(Pt(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),Pt(h)==="symbol"?h:String(h)),i)}var h}var Fn=S(),ge=function(e){return typeof e=="function"?e:function(){return e}},ot=function(){function e(i){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={overflow:"ellipsis",lineclamp:null,align:"left",wordBreak:null,valign:"top",width:function(){return 1/0},height:function(){return 1/0},x:function(){return 0},font:null,tAnchor:0,parser:e.defaultparser},i)for(var h in i)typeof this[h]=="function"&&this[h](i[h])}var n,o;return n=e,o=[{key:"linebreak",value:function(i){var h=this,y=this.props.parser(String(i)),x=this.font(),w=function(b,E,M){if(!b.length)return[];var z=E.height(),_=E.width(),L=E.overflowLine(),R=E.overflowWrap(),tt=S(M,!0,!1),$=isFinite(z())?Math.floor(z()/M.height):1/0;if(!z()&&!_(0)||!$)return[];for(var C=0,j=0,N=0,et=[],W=[],F=!1;C<b.length&&j<$;){var O=b[C],st=Cn(O,M);if(O.width=Y(O,st),O.font=st,O.line=j,O.whitespace=O.value in P,O.value&&(O.value=O.value.replace(Ln," ")),!(!N&&O.whitespace||F&&O.whitespace))if(O instanceof rt)N=0,W=[],et.push(C+1),j++;else if(O instanceof Ct||O instanceof xt)W.push({index:C,width:N});else if(O.whitespace||N+O.width<_(j))N+=O.width;else if(W.length){var nt=void 0,dt=void 0;do{dt=!0,nt=W.pop();var gt=b[nt.index],ht=void 0;gt instanceof xt&&(ht=Y("-",gt.font),nt.width+ht>_(j)&&(dt=!W.length))}while(!dt);et.push(nt.index+1),N=0,j++,C=nt.index,W=[]}else if(R==="break-word"){var ft=_(j);if(N+O.width>ft){var _t=O.clone();do O.value=O.value.slice(0,-1),O.width=Y(O,O.font),N+=O.width;while(O.value&&O.width>ft);_t.value=_t.value.slice(O.value.length),b.splice(C+1,0,new Ct,_t)}et.push(C+1),N=0,j++}else N+=O.width;C++,F=O.whitespace}C!==et[et.length-1]&&et.push(C);var Nt=0,pt=0,K=et.map(function(bt){for(var Q,At=Nt;(Q=b[At])&&(Q.whitespace||!Q.value);)At++;for(var yt=bt,ve=null;yt>At&&(Q=b[yt-1])&&(Q.whitespace||!(Q.value||Q instanceof xt));)Q instanceof rt&&(ve=Q),yt--;Q instanceof xt&&(Q.value="-",Q.width=Y("-",Q.font)),Nt=bt;var Ot=b.slice(At,yt).filter(function(we){return we.value});return ve&&Ot.push(ve),Ot.width=Ot.reduce(function(we,Yn){return we+Yn.width},0),Ot.width>pt&&(pt=Ot.width),Ot});if(K.hasLineOverflow=!1,L){var Gt=L==="ellipsis"?"…":L;K.forEach(function(bt,Q){var At=_(Q);if(bt.width>At){var yt=new H(Gt);yt.font=M,yt.width=Y(Gt,tt),Ye(bt,At,yt),K.hasLineOverflow=!0}})}var V=E.overflow()==="ellipsis"?"…":E.overflow();if(V&&C!==b.length){var J=_(K.length-1),Zt=K[K.length-1],Ht=new H(V);Ht.font=M,Ht.width=Y(V,tt),Ye(Zt,J,Ht),K.hasOverflow=!0}else K.hasOverflow=!1;return K.font=M,K.width=pt,K}(y,this,x);return w.height=w.length*x.height,w.render=function(b){return h.render(w,b)},w.svg=w.render,w.draw=w.render,w}},{key:"font",value:function(i){return arguments.length?(this.props.font=S(i),this):this.props.font||S(Fn)}},{key:"overflow",value:function(i){return arguments.length?(this.props.overflow=String(i),this):this.props.overflow}},{key:"overflowLine",value:function(i){return arguments.length?(this.props.lineclamp=String(i),this):this.props.lineclamp}},{key:"valign",value:function(i){return arguments.length?(this.props.valign=i,this):this.props.valign}},{key:"align",value:function(i){if(!arguments.length)return this.props.align;var h=String(i).toLowerCase();return h==="left"||h==="start"?(this.props.align="left",this.props.tAnchor=0):h==="center"||h==="middle"?(this.props.align="center",this.props.tAnchor=-.5):h==="end"||h==="right"?(this.props.align="right",this.props.tAnchor=-1):h==="justify"&&(this.props.align=i,this.props.tAnchor=0),this}},{key:"overflowWrap",value:function(i){if(!arguments.length)return this.props.overflowWrap||"normal";var h=String(i).toLowerCase();return h==="break-word"?this.props.overflowWrap="break-word":h!=="normal"&&i!=null||(this.props.overflowWrap=null),this}},{key:"width",value:function(i){return arguments.length?(this.props.width=ge(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=ge(i),this):this.props.height}},{key:"x",value:function(i){return arguments.length?(this.props.x=ge(i),this):this.props.x}},{key:"parser",value:function(i){if(!arguments.length)return this.props.parser;if(typeof i=="string"){var h=e[i]||e[i+"parser"];typeof h=="function"&&(i=h)}if(typeof i!="function")throw new Error("Unknown parser: "+i);return this.props.parser=i,this}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"render",value:function(){var i=Ge(arguments);return typeof i.text=="string"&&(i.text=this.linebreak(i.text)),i.ctx?Rn(i.text,this,i.ctx):Nn(i.text,this)}}],o&&jn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function $t(e){return $t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},$t(e)}function ye(e,n){(n==null||n>e.length)&&(n=e.length);for(var o=0,i=new Array(n);o<n;o++)i[o]=e[o];return i}function Bn(e,n){for(var o=0;o<n.length;o++){var i=n[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(h=function(y,x){if($t(y)!=="object"||y===null)return y;var w=y[Symbol.toPrimitive];if(w!==void 0){var b=w.call(y,x);if($t(b)!=="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}(i.key,"string"),$t(h)==="symbol"?h:String(h)),i)}var h}var Ze=function(e){return typeof e=="function"?e:function(){return e}},We=function(){function e(i){if(function(y,x){if(!(y instanceof x))throw new TypeError("Cannot call a class as a function")}(this,e),this.props={width:function(){return 1/0},height:function(){return 1/0},rotation:0,vAnchor:0,hAnchor:0},i)for(var h in i)typeof this[h]=="function"&&this[h](i[h]);this.render=this.render.bind(this)}var n,o;return n=e,o=[{key:"anchor",value:function(i){var h=this.props,y=h.hAnchor,x=h.vAnchor,w=h.width,b=h.height;if(!arguments.length)return[y*w(0),x*b(0)];if(typeof i=="string"){var E=this.props;i.toLowerCase().trim().split(/\s+/).forEach(function(M){M==="top"&&(E.vAnchor=-0),M==="middle"&&(E.vAnchor=-.5),M==="bottom"&&(E.vAnchor=-1),M==="left"&&(E.hAnchor=-0),M==="center"&&(E.hAnchor=-.5),M==="right"&&(E.hAnchor=-1)})}return this}},{key:"width",value:function(i){return arguments.length?(this.props.width=Ze(i),this):this.props.width}},{key:"height",value:function(i){return arguments.length?(this.props.height=Ze(i),this):this.props.height}},{key:"rotate",value:function(i){return arguments.length?(this.props.rotation=i,this):this.props.rotation}},{key:"createElement",value:function(i){return arguments.length?(this.props.createElement=i,this):this.props.createElement||e.createElement}},{key:"canvas",value:function(i,h){var y,x=i.getContext?i.getContext("2d"):i;return x.save(),x.rotate(this.rotate()*Math.PI/180),x.translate.apply(x,function(w){if(Array.isArray(w))return ye(w)}(y=this.anchor())||function(w){if(typeof Symbol<"u"&&w[Symbol.iterator]!=null||w["@@iterator"]!=null)return Array.from(w)}(y)||function(w,b){if(w){if(typeof w=="string")return ye(w,b);var E=Object.prototype.toString.call(w).slice(8,-1);return E==="Object"&&w.constructor&&(E=w.constructor.name),E==="Map"||E==="Set"?Array.from(w):E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E)?ye(w,b):void 0}}(y)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()),h(x),x.restore(),x}},{key:"render",value:function(){var i=Ge(arguments);if(i.d3)return i.d3.attr("transform","rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")"));if(i.ctx)return this.canvas(i.ctx,i.fn);if(i.text){var h=typeof i.text.render=="function"?i.text.render():i.text;return this.createElement()("g",{transform:"rotate(".concat(this.rotate(),") translate(").concat(this.anchor(),")")},h)}}}],o&&Bn(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}(),qn=Object.prototype.hasOwnProperty,me={};function Vn(e){return me[e]||(me[e]=e.replace(/([a-z])([A-Z])/g,function(n,o,i){return o+"-"+i.toLowerCase()})),me[e]}function Ke(e,n){if(Array.isArray(n))return n.forEach(function(o){return Ke(e,o)});typeof n=="string"&&(n=document.createTextNode(n)),e.appendChild(n)}function Je(e,n){if(typeof document<"u"){var o=typeof e=="string"?document.createElementNS("http://www.w3.org/2000/svg",e):e;if(n&&o.setAttribute)for(var i in n)qn.call(n,i)&&n[i]!=null&&o.setAttribute(i==="className"?"class":Vn(i),n[i]);for(var h=arguments.length,y=new Array(h>2?h-2:0),x=2;x<h;x++)y[x-2]=arguments[x];return y!=null&&y.length&&y.forEach(function(w){Ke(o,w)}),o}}ot.createElement=Je,ot.textparser=Xt,ot.defaultparser=Xt,ot.htmlparser=function(e){e=String(e||"").trim();for(var n,o,i={weight:null,style:null,sub:!1,sup:!1,href:null,color:null,rel:null,target:null},h=[],y=[],x=function(z){for(var _ in i)i[_]&&(z[_]=i[_]);h.push(z)},w=function(z){var _=h.length,L=Sn[z];if(_&&L){for(var R=_-1;h[R]&&(h[R]instanceof Ct||vn.test(h[R].value));)R--;for(;L&&h[R]&&h[R]instanceof rt;)R--,L--;for(;L-- >0;)h.push(new rt)}};e.length;){if(n=/^[^<]+/.exec(e))Xt(Ve(n[0]),!1).forEach(x);else if(!(n=bn.exec(e)))if(n=wn.exec(e))y.length&&(i=y.pop()),w(n[1]);else if(n=xn.exec(e)){var b=n[1];w(b),y.push(i),i=Object.create(i),qe[b]&&qe[b](i,"");var E=Tn(n[2]);b==="a"&&(E.href&&(i.href=E.href),E.rel&&(i.rel=E.rel),E.target&&(i.target=E.target)),E.class&&(i.class=i.class?i.class+" "+E.class:E.class),E.style&&(o=/(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(E.style))&&o[1]&&(i.color=o[1]),b==="br"&&h.push(new rt)}else n=[e.slice(0,1)],x(new H(n[0]));e=e.slice(n[0].length)}for(var M=h[h.length-1];M instanceof rt;)h.pop(),M=h[h.length-1];return h},ot.latexparser=function(e){e=String(e||"").trim();var n=[0];e=e.replace(/\\verb,(.*?),/,function($,C){return n.push(C),"\\verb,"+(n.length-1)+","}).replace(/\\\\\n/g,function(){return"\\\\"}).replace(Mn,function($,C,j){return j.charAt(C-1)==="\\"?$:zn[$]}).replace(/\n\s+/g,function($){return/\n/.test($.slice(1))?"\\par ":$}).replace(/\\symbol\{(\d+)\}/,function($,C,j,N){return N.charAt(j-1)==="\\"?$:String.fromCharCode(1*C)}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g,function($,C,j,N){return C+j+"{"+N+"}"}).replace(/\\verb,(.*?),/,function($,C){return"\\verb,".concat(n[+C],",")});for(var o,i={weight:null,italic:null,variant:null,sub:!1,sup:!1,href:null},h=[],y=[],x=function($){for(var C in i)i[C]&&($[C]=i[C]);return h.push($),$},w=function(){y.push(i),i=Object.create(i)},b=function(){if(!y.length)throw new Error("Unexpected }");i=y.pop()},E={tokens:h,open_context:w,close_context:b,add_token:x};e.length;){if(o=On.exec(e))Xt(o[0],!1).forEach(x);else if(o=Dn.exec(e))x(new H(o[1]));else if(!(o=_n.exec(e))){if(o=/^\{/.exec(e))w();else if(o=/^\}/.exec(e))b();else if(!(o=/^\$/.exec(e)))if(o=/^\\verb,([^,]+),/.exec(e))x(new H(o[1]));else if(o=In.exec(e)){var M=o[1].slice(1)||o[1],z=!!o[2];if(/^(La)?TeX$/i.test(M)){w(),i.family="serif";var _=void 0;M==="LaTeX"&&((_=x(new H("L"))).tracking=-.25,(_=x(new H("A"))).size=.7,_.baseline=.3,_.tracking=-.1),(_=x(new H("T"))).tracking=-.17,(_=x(new H("E"))).baseline=-.22,_.tracking=-.13,_=x(new H("X")),b()}else if(M in Ue)x(new H(Ue[M])),z&&w();else if(M in U){var L=[],R=U[M].length-1,tt=void 0;if(R){for(z=!1,e=e.slice(o[0].length-1);R--;){if(!(tt=/^\{([^}]+)\}/.exec(e)))throw new Error(M+" is missing an argument");L.push(tt[1]),e=e.slice(tt[0].length)}o[0]=/^\{/.exec(e)?"{":"",z=!!o[0]}z&&w(),U[M].apply(E,[i].concat(L))}else console.warn("unknown latex command",M),x(new H(o[1])),z&&w()}else o=[e.slice(0,1)],x(new H(o[0]))}e=e.slice(o[0].length)}return h},ot.measureText=function(e,n,o){return Y(e,S(n),o)},ot.Token=H,ot.Break=Ct,ot.LineBreak=rt,ot.SoftHyphen=xt,ot.Rotator=We,We.createElement=Je;const Un=ot;return r.default})())})(Ce);var hn=Ce.exports;const Pe=ct(hn);function cn(u,l){const t=at(u),{fontSize:r,font:a,padding:c=0}=u.properties.style||{};if(t.width===t.height&&t.width===0)return;const p=new Pe({font:`${r}px/${r}px ${a}`.replace(/(px)+/g,"px"),width:t.width-c*2,height:t.height-c*2,align:"left",valign:"top",x:0,overflow:"ellipsis",parser:"html",createElement:Pe.createElement}).linebreak(u.properties.content.replaceAll(`
10
+ `,"<br>")).render();p.setAttribute("transform",`translate(${c}, ${c})`),l.appendChild(p)}const $e=20;class Ne extends _e{constructor(t,r={}){super(t,`
11
11
  <div class="annotation-text-handle">
12
12
  <span class="handle line-handle top" data-handle-id="0"></span>
13
13
  <span class="handle line-handle bottom" data-handle-id="1"></span>
@@ -19,5 +19,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
19
19
  <span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
20
20
  <textarea wrap="off"></textarea>
21
21
  </div>
22
- `);v(this,"textArea");v(this,"handleSize");v(this,"rect",{x:0,y:0,width:0,height:0});v(this,"annotation",{...Ft});v(this,"startX",0);v(this,"startY",0);v(this,"handles",[]);v(this,"draggedHandle",q);v(this,"isFocused",!1);v(this,"placeholder","Type your text here...");v(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0});v(this,"_onBlur",()=>{this.isFocused=!1});v(this,"startDrawing",(t,r,a=Le(t,r,0,0,"",mt))=>{this.add(a);const c=this.ogma.view.graphToScreenCoordinates({x:t,y:r});this.select(a.id),this.startDragging(this.getById(a.id),c.x,c.y),this.draggedHandle=6});v(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...Ft},this.draggedHandle=q,this.isDragging=!1,this.emit(Mt,this.annotation))});v(this,"startDragging",(t,r,a)=>{this.annotation=t;const c=pt(this.annotation),p=ct(this.annotation);this.rect.x=c.x,this.rect.y=c.y,this.rect.width=p.width,this.rect.height=p.height,this.startX=r,this.startY=a,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(te,this.annotation),this.isDragging=!0});v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.selectedId!==r.id&&this.select(this.hoveredId),this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=Jt(t.target))});v(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});v(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const r=this.handles[this.draggedHandle],a=r.classList.contains("top"),c=r.classList.contains("left"),p=r.classList.contains("right"),y=r.classList.contains("bottom"),f=r.classList.contains("line-handle"),s=this.ogma.view.getZoom(),d=(t.clientX-this.startX)/s,m=(t.clientY-this.startY)/s,k=c||f?this.rect.x+d:this.rect.x,_=a||f?this.rect.y+m:this.rect.y,E=Math.max(this.rect.width+d*(f?0:c?-1:p?1:0),Ne),P=Math.max(this.rect.height+m*(f?0:a?-1:y?1:0),Ne);Se(this.annotation,k,_,E,P),this.emit(Qt,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});v(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===q||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Mt,this.annotation),this.isDragging=!1,this.draggedHandle=q)});v(this,"onViewChanged",()=>{const t=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/t}`)});v(this,"_onInput",()=>{const t=this.getById(this.selectedId);t&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),t.properties.content=this.textArea.value,this.emit(se,t),this.layer.refresh())});this.handleSize=oe.handleSize||r.textHandleSize,this.placeholder=oe.placeholder||r.textPlaceholder||"";const a=this.textArea=this.editor.element.querySelector("textarea");a.addEventListener("input",this._onInput),a.addEventListener("focus",this._onFocus),a.addEventListener("blur",this._onBlur),a.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(c=>c.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),t.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:t,y:r},a=0){return this.elements.find(c=>{const{x:p,y}=pt(c),{width:f,height:s}=ct(c);return p-a<t&&y-a<r&&p+f+a>t&&y+s+a>r})}draw(t){t.innerHTML="";const r="";this.elements.forEach((c,p)=>{const y=`class${p}`,f=ct(c),s=pt(c),d=c.id,{color:m,fontSize:k,font:_,strokeColor:E,strokeWidth:P,strokeType:S,background:Y}=c.properties.style||mt;if(d===this.selectedId||this.selectedId===-1&&d===this.hoveredId)return;const $=St("g");$.setAttribute("fill",`${m}`),$.setAttribute("font-size",`${k}`),$.setAttribute("font-family",`${_}`);const L=St("rect");let W=!1;S&&S!=="none"&&(W=!0,L.setAttribute("stroke",E||"black"),L.setAttribute("stroke-width",`${P}`),S==="dashed"&&L.setAttribute("stroke-dasharray","5,5")),(Y&&Y.length||W)&&(W=!0,L.setAttribute("fill",Y||"transparent")),W&&(L.setAttribute("width",`${f.width}`),L.setAttribute("height",`${f.height}`)),$.appendChild(L),cn(c,$),$.setAttribute("transform",`translate(${s.x},${s.y})`),$.classList.add(y),$.setAttribute("data-annotation",`${c.id}`),$.setAttribute("data-annotation-type","text"),t.appendChild($)});const a=St("style");a.innerHTML=r,t.firstChild&&t.insertBefore(a,t.firstChild)}getDefaultOptions(){return Ft}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),r=ct(t),a=this.ogma.view.graphToScreenCoordinates(pt(t)),c=this.ogma.view.getZoom(),{font:p,fontSize:y,color:f,background:s,padding:d=0}=t.properties.style||mt,m=+y*c;this.textArea.value=t.properties.content,this.editor.element.style.transform=`translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width/2*c}px, ${r.height/2*c}px)`,this.editor.element.style.width=`${r.width*c}px`,this.editor.element.style.height=`${r.height*c}px`,this.textArea.style.font=`${m} ${p}`,this.textArea.style.fontFamily=p||"sans-serif",this.textArea.style.fontSize=`${m}px`,this.textArea.style.padding=`${d}px`,this.textArea.style.lineHeight=`${m}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=f||"black",this.textArea.style.background=s||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class un{constructor(){v(this,"links",{});v(this,"linksByTargetId",{});v(this,"linksByArrowId",{})}add(h,t,r,a,c){const p=$t(),y=h.id,f={id:p,arrow:y,target:r,targetType:a,connectionPoint:c,side:t};return this.links[p]=f,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(p),this.linksByArrowId[y]||(this.linksByArrowId[y]={}),this.linksByArrowId[y][t]=p,h.properties.link=h.properties.link||{},h.properties.link[t]={id:r,side:t,type:a,magnet:c},this}arrowIsLinked(h,t){var r;return!!((r=this.linksByArrowId[h])!=null&&r[t])}remove(h,t){var y,f;const r=h.id,a=(y=this.linksByArrowId[r])==null?void 0:y[t];if((f=h.properties.link)==null||delete f[t],!a)return this;const c=this.links[a];delete this.links[a];const p=this.linksByTargetId[c.target];for(let s=0;s<p.length;s++)if(p[s]===a){p.splice(s,1);break}return delete this.linksByArrowId[r][t],this}getArrowLink(h,t){var a;const r=(a=this.linksByArrowId[h])==null?void 0:a[t];return r?this.links[r]:null}getTargetLinks(h){var t;return((t=this.linksByTargetId[h])==null?void 0:t.map(r=>this.links[r]))??[]}}const at=u=>u.properties.type==="arrow",vt=u=>u.properties.type==="text",ae=u=>u.type==="FeatureCollection",dn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},He=["start","end"],je=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:0,y:.5},{x:1,y:.5},{x:0,y:1},{x:.5,y:1},{x:1,y:1}];class fn extends Ie{constructor(t,r={}){super();v(this,"arrows");v(this,"texts");v(this,"links",new un);v(this,"layer");v(this,"annotations");v(this,"ogma");v(this,"options");v(this,"selected",null);v(this,"updateTimeout",0);v(this,"hoveredNode",null);v(this,"dragged",null);v(this,"textToMagnet");v(this,"activeLinks",[]);v(this,"_render",t=>{if(!this.dragged||this.textToMagnet===void 0)return;t.beginPath(),t.fillStyle="green";const r=this.ogma.view.getZoom();je.forEach(a=>{if(!this.textToMagnet)return;const c=ct(this.textToMagnet),p=pt(this.textToMagnet),{x:y,y:f}=new rt(a.x,a.y).mul({x:c.width,y:c.height}).add(p);t.moveTo(y,f),t.arc(y,f,this.options.magnetHandleRadius/r,0,Math.PI*2)}),t.fill(),t.closePath()});v(this,"_onFeatureDrag",(t,r)=>{const a=r;if(at(t)&&a==="line")["start","end"].find(c=>{const p=c==="start"?Et(t):_t(t);return this._snapToText(t,a,p)||this._findAndSnapToNode(t,c,p)});else if(at(t)&&a!=="line"){const c=a==="start"?Et(t):_t(t);this._snapToText(t,a,c)||this._findAndSnapToNode(t,a,c)}else vt(t)&&(this.activeLinks.forEach(({arrow:c,side:p,connectionPoint:y})=>{const f=this.getAnnotation(c),s=ct(t),d=pt(t),m=new rt(y.x,y.y).mul({x:s.width,y:s.height}).add(d);f.geometry.coordinates[p==="start"?0:1]=[m.x,m.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh()});v(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&at(t)&&Et(this.dragged)&&He.forEach(r=>{this.links.getArrowLink(t.id,r)&&this.emit(an,{arrow:t,link:this.links.getArrowLink(t.id,r)})}),(vt(t)||at(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(r=>r.enableDetection()),this.layer.refresh()});v(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,at(t)?this.dragged=t:vt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id)),this.annotations.forEach(r=>{const a=r.getSelectedFeature();a&&a!==t&&r.unhover().unselect(),r.disableDetection()})});v(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});v(this,"_onNodesDrag",t=>{const{dx:r,dy:a}=t;this._moveNodes(t.nodes,r,a)});v(this,"_onLayoutEnd",t=>{t.ids.forEach((r,a)=>{this.links.getTargetLinks(r).forEach(p=>{const y=this.getAnnotation(p.arrow),f=p.side,s=Ht(y,f==="start"?"end":"start"),d=t.positions.current[a],m=this.ogma.getNode(r).getAttribute("radius"),k=Rt(s,d,+m);Dt(y,f,k.x,k.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});v(this,"_onAdded",t=>{this.emit(re,t)});v(this,"_onRemoved",t=>{this.emit(ie,t)});v(this,"_onUnselect",t=>{this.selected=null,this.emit(ne,t)});v(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(ee,this.selected))});v(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});v(this,"_onUpdate",t=>{this.emit(se,t)});this.options=this.setOptions({...dn,...r}),this.ogma=t,this.arrows=new ze(t,this.options),this.texts=new $e(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(a=>{a.on(te,this._onFeatureDragStart).on(Qt,this._onFeatureDrag).on(Mt,this._onFeatureDragEnd).on(se,this.onUpdate).on(ne,this._onUnselect).on(ee,this._onSelect).on(re,this._onAdded).on(ie,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,r,a){t.forEach(c=>{const p=this.links.getTargetLinks(c.getId()),y=c.getPosition();p.forEach(f=>{const s=this.getAnnotation(f.arrow),d=f.side,m=Ht(s,d==="start"?"end":"start");let k=y;const _=+c.getAttribute("radius"),E=1e-6;(f.connectionPoint.x-(y.x-r)>E||f.connectionPoint.y-(y.y-a)>E)&&(k=Rt(m,y,_)),Dt(s,d,k.x,k.y)})}),this.arrows.refreshLayer()}_snapToText(t,r,a){const c=this.texts.detect(a,this.options.detectMargin);if(this.links.remove(t,r),!c)return!1;this.textToMagnet=c;const p=this.findMagnetPoint(je,c,a);return p?(Dt(t,r,p.point.x,p.point.y),this.links.add(t,r,c.id,"text",p.magnet),!0):!1}_findAndSnapToNode(t,r,a){const c=this.ogma.view.graphToScreenCoordinates(a),p=this.ogma.view.getElementAt(c);this.links.remove(t,r),p&&p.isNode?(this.hoveredNode=p,this.hoveredNode.setSelected(!0),this._snapToNode(t,r,p,c)):(this.hoveredNode&&this.hoveredNode.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,r,a,c){const p=a.getPositionOnScreen(),y=+a.getAttribute("radius"),f=y*this.ogma.view.getZoom(),s=c.x-p.x,d=c.y-p.y,m=Math.sqrt(s*s+d*d),k=a.getPosition();if(m<f+this.options.detectMargin){let _=k;if(m>f/2){const E=Ht(t,r==="end"?"start":"end");_=Rt(E,_,y)}Dt(t,r,_.x,_.y),this.links.add(t,r,a.getId(),"node",_)}}getSelected(){return this.selected}findMagnetPoint(t,r,a){let c;for(const p of t){const y=ct(r),f=pt(r),s=new rt(p.x,p.y).mul({x:y.width,y:y.height}).add(f),d=s.sub(a).length(),m=this.options.magnetRadius*this.ogma.view.getZoom();if(d<Math.max(m,this.options.magnetHandleRadius)){c={point:s,magnet:p};break}}return c}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const r=this.getAnnotations().features.find(a=>a.id===t);return r?(at(r)?this.arrows.select(r.id):vt(r)&&this.texts.select(r.id),this):this}unselect(){return this.selected?(at(this.selected)?this.arrows.unselect():vt(this.selected)&&this.texts.unselect(),this):this}add(t){if(ae(t))return t.features.forEach(r=>this.add(r)),this;switch(t.properties.type){case"text":this.texts.add(t);break;default:this.arrows.add(t),this.loadLink(t);break}return this}remove(t){return ae(t)?(t.features.forEach(r=>this.remove(r)),this):(at(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const r of He){const a=t.properties.link[r];if(!a)continue;if(this.getAnnotation(a.id))this.links.add(t,r,a.id,a.type,a.magnet);else{if(!this.ogma.getNode(a.id))continue;this.links.add(t,r,a.id,a.type,a.magnet)}}}startArrow(t,r,a){this.cancelDrawing(),this.arrows.startDrawing(t,r,a)}startText(t,r,a){this.cancelDrawing(),this.texts.startDrawing(t,r,a)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(on)}updateStyle(t,r){const a=this.getAnnotations().features.find(c=>c.id===t);return a?(at(a)?this.arrows.updateStyle(a,r):vt(a)&&this.texts.updateStyle(a,r),this.onUpdate(a),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(r=>{t.features=[...t.features,...r.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(r=>r.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}T.Arrows=ze,T.Control=fn,T.Texts=$e,T.createArrow=be,T.createSVGElement=St,T.createText=Le,T.defaultArrowOptions=Gt,T.defaultArrowStyle=At,T.defaultControllerOptions=oe,T.defaultTextOptions=Ft,T.defaultTextStyle=mt,T.getAnnotationsBounds=en,T.getArrowEnd=_t,T.getArrowEndPoints=Ot,T.getArrowSide=Ht,T.getArrowStart=Et,T.getAttachmentPointOnNode=Rt,T.getHandleId=Jt,T.getTextBbox=Zt,T.getTextPosition=pt,T.getTextSize=ct,T.isAnnotationCollection=ae,T.isArrow=at,T.isText=vt,T.setArrowEnd=Kt,T.setArrowEndPoint=Dt,T.setArrowStart=Wt,T.setTextBbox=Se,T.updateTextBbox=Ae,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
22
+ `);v(this,"textArea");v(this,"handleSize");v(this,"rect",{x:0,y:0,width:0,height:0});v(this,"annotation",{...qt});v(this,"startX",0);v(this,"startY",0);v(this,"handles",[]);v(this,"draggedHandle",B);v(this,"isFocused",!1);v(this,"placeholder","Type your text here...");v(this,"_onFocus",()=>{this.textArea.value===this.placeholder&&(this.textArea.value=""),this.isFocused=!0});v(this,"_onBlur",()=>{this.isFocused=!1});v(this,"startDrawing",(t,r,a=Le(t,r,0,0,"",vt))=>{this.add(a);const c=this.ogma.view.graphToScreenCoordinates({x:t,y:r});this.select(a.id),this.startDragging(this.getById(a.id),c.x,c.y),this.draggedHandle=6});v(this,"cancelDrawing",()=>{this.isDragging&&(this.remove(this.annotation.id),this.annotation={...qt},this.draggedHandle=B,this.isDragging=!1,this.emit(Tt,this.annotation))});v(this,"startDragging",(t,r,a)=>{this.annotation=t;const c=ut(this.annotation),f=at(this.annotation);this.rect.x=c.x,this.rect.y=c.y,this.rect.width=f.width,this.rect.height=f.height,this.startX=r,this.startY=a,this.disableDragging(),this.textArea.classList.add("noevents"),this.textArea.setAttribute("disabled","disabled"),this.emit(Bt,this.annotation),this.isDragging=!0});v(this,"onHandleMouseDown",t=>{const r=this.getById(this.selectedId)||this.getById(this.hoveredId);r&&(this.selectedId!==r.id&&this.select(this.hoveredId),this.startDragging(r,t.clientX,t.clientY),this.draggedHandle=te(t.target))});v(this,"onMouseMove",t=>{requestAnimationFrame(()=>this._onMouseMove(t))});v(this,"_onMouseMove",t=>{if(!this.isDragging)return;t.stopPropagation(),t.preventDefault();const r=this.handles[this.draggedHandle],a=r.classList.contains("top"),c=r.classList.contains("left"),f=r.classList.contains("right"),g=r.classList.contains("bottom"),p=r.classList.contains("line-handle"),s=this.ogma.view.getZoom(),d=(t.clientX-this.startX)/s,m=(t.clientY-this.startY)/s,A=this.ogma.view.getAngle(),T=new X(d,m).rotateRadians(A);(g&&c||a&&f)&&(T.y=0,T.x=0);const S=c||p?this.rect.x+T.x:this.rect.x,P=a||p?this.rect.y+T.y:this.rect.y,k=Math.max(this.rect.width+d*(p||c?0:1),$e),q=Math.max(this.rect.height+m*(p||a?0:1),$e);Se(this.annotation,S,P,k,q),this.emit(Ft,this.annotation,"text"),this.refreshEditor(),this.layer.refresh()});v(this,"onMouseUp",()=>{!this.isDragging||this.draggedHandle===B||(this.restoreDragging(),this.textArea.classList.remove("noevents"),this.textArea.removeAttribute("disabled"),this.emit(Tt,this.annotation),this.isDragging=!1,this.draggedHandle=B)});v(this,"onViewChanged",()=>{const t=Math.max(2,this.handleSize/this.ogma.view.getZoom());document.documentElement.style.setProperty("--handle-scale",`${1/t}`)});v(this,"_onInput",()=>{const t=this.getById(this.selectedId);t&&(this.textArea.value=this.textArea.value.replace(/ +(?= )/g,""),this.textArea.focus(),t.properties.content=this.textArea.value,this.emit(se,t),this.layer.refresh())});this.showeditorOnHover=!1,this.handleSize=oe.handleSize||r.textHandleSize,this.placeholder=oe.placeholder||r.textPlaceholder||"";const a=this.textArea=this.editor.element.querySelector("textarea");a.addEventListener("input",this._onInput),a.addEventListener("focus",this._onFocus),a.addEventListener("blur",this._onBlur),a.spellcheck=!1,this.handles=Array.prototype.slice.call(this.editor.element.querySelectorAll(".annotation-text-handle > .handle")),this.handles.forEach(c=>c.addEventListener("mousedown",this.onHandleMouseDown)),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("mousemove",this.onMouseMove,!0),t.events.on(["viewChanged","zoom"],this.onViewChanged)}_canRemove(){return!this.isFocused}detect({x:t,y:r},a=0){const c=new X(t,r),f=this.ogma.view.getAngle();return this.elements.find(g=>{const{x:p,y:s}=ut(g),{width:d,height:m}=at(g),A=new X(p,s),{x:T,y:S}=c.sub(A).rotateRadians(-f);return T>-a&&T<d+a&&S>-a&&S<m+a})}draw(t){t.innerHTML="";const r="",a=this.ogma.view.getAngle()*180/Math.PI;this.elements.forEach((f,g)=>{const p=`class${g}`,s=at(f),d=ut(f),m=f.id,{color:A,fontSize:T,font:S,strokeColor:P,strokeWidth:k,strokeType:q,background:G}=f.properties.style||vt;if(m===this.selectedId)return;const D=Et("g");D.classList.add("annotation-text"),D.setAttribute("fill",`${A}`),D.setAttribute("font-size",`${T}px`),D.setAttribute("font-family",`${S}`);const Y=Et("rect");let Z=!1;q&&q!=="none"&&(Z=!0,Y.setAttribute("stroke",P||"black"),Y.setAttribute("stroke-width",`${k}`),q==="dashed"&&Y.setAttribute("stroke-dasharray","5,5")),(G&&G.length||Z)&&(Z=!0,Y.setAttribute("fill",G||"transparent")),Z&&(Y.setAttribute("width",`${s.width}`),Y.setAttribute("height",`${s.height}`)),D.appendChild(Y),cn(f,D),D.setAttribute("transform",`translate(${d.x},${d.y}) rotate(${a})`),D.classList.add(p),D.setAttribute("data-annotation",`${f.id}`),D.setAttribute("data-annotation-type","text"),t.appendChild(D)});const c=Et("style");c.innerHTML=r,t.firstChild&&t.insertBefore(c,t.firstChild)}refreshDrawing(){const t=this.ogma.view.getAngle()*180/Math.PI;[...this.layer.element.children].forEach(r=>{const a=r.getAttribute("transform"),c=a==null?void 0:a.match(/translate\(([^)]+)\)/);c&&r.setAttribute("transform",`translate(${c[1]}) rotate(${t})`)})}getDefaultOptions(){return qt}refreshEditor(){if(+this.selectedId<0&&+this.hoveredId<0)return;const t=this.getById(this.selectedId)||this.getById(this.hoveredId),r=at(t),a=this.ogma.view.graphToScreenCoordinates(ut(t)),c=this.ogma.view.getZoom(),{font:f,fontSize:g,color:p,background:s,padding:d=0}=t.properties.style||vt,m=(g||1)*c;this.textArea.value=t.properties.content,this.editor.element.style.transform=`translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width/2*c}px, ${r.height/2*c}px)`,this.editor.element.style.width=`${r.width*c}px`,this.editor.element.style.height=`${r.height*c}px`,this.textArea.style.font=`${m} ${f}`,this.textArea.style.fontFamily=f||"sans-serif",this.textArea.style.fontSize=`${m}px`,this.textArea.style.padding=`${d}px`,this.textArea.style.lineHeight=`${m}px`,this.textArea.style.boxSizing="border-box",this.textArea.style.color=p||"black",this.textArea.style.background=s||"transparent",this.textArea.placeholder=this.placeholder,this.layer.refresh()}select(t){super.select(t),this.textArea.focus()}destroy(){super.destroy(),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("mousemove",this.onMouseMove,!0),this.ogma.events.off(this.onViewChanged)}}class un{constructor(){v(this,"links",{});v(this,"linksByTargetId",{});v(this,"linksByArrowId",{})}add(l,t,r,a,c){const f=Rt(),g=l.id,p={id:f,arrow:g,target:r,targetType:a,connectionPoint:c,side:t};return this.links[f]=p,this.linksByTargetId[r]||(this.linksByTargetId[r]=[]),this.linksByTargetId[r].push(f),this.linksByArrowId[g]||(this.linksByArrowId[g]={}),this.linksByArrowId[g][t]=f,l.properties.link=l.properties.link||{},l.properties.link[t]={id:r,side:t,type:a,magnet:c},this}arrowIsLinked(l,t){var r;return!!((r=this.linksByArrowId[l])!=null&&r[t])}remove(l,t){var g,p;const r=l.id,a=(g=this.linksByArrowId[r])==null?void 0:g[t];if((p=l.properties.link)==null||delete p[t],!a)return this;const c=this.links[a];delete this.links[a];const f=this.linksByTargetId[c.target];for(let s=0;s<f.length;s++)if(f[s]===a){f.splice(s,1);break}return delete this.linksByArrowId[r][t],this}getArrowLink(l,t){var a;const r=(a=this.linksByArrowId[l])==null?void 0:a[t];return r?this.links[r]:null}getTargetLinks(l,t){var r;return((r=this.linksByTargetId[l])==null?void 0:r.map(a=>this.links[a]).filter(a=>a.targetType===t))??[]}forEach(l){Object.values(this.links).forEach(l)}}const lt=u=>u.properties.type==="arrow",wt=u=>u.properties.type==="text",ae=u=>u.type==="FeatureCollection",dn={magnetColor:"#3e8",detectMargin:20,magnetHandleRadius:5,magnetRadius:10,textPlaceholder:"Type here",arrowHandleSize:3.5,textHandleSize:3.5,minArrowHeight:20,maxArrowHeight:30},He=["start","end"],Re=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:0,y:.5},{x:1,y:.5},{x:0,y:1},{x:.5,y:1},{x:1,y:1}];class fn extends Ie{constructor(t,r={}){super();v(this,"arrows");v(this,"texts");v(this,"links",new un);v(this,"layer");v(this,"annotations");v(this,"ogma");v(this,"options");v(this,"selected",null);v(this,"updateTimeout",0);v(this,"hoveredNode",null);v(this,"dragged",null);v(this,"textToMagnet");v(this,"activeLinks",[]);v(this,"_render",t=>{if(!this.dragged||this.textToMagnet===void 0)return;t.beginPath(),t.fillStyle="green";const r=this.ogma.view.getZoom();Re.forEach(a=>{if(!this.textToMagnet)return;const c=at(this.textToMagnet),f=ut(this.textToMagnet),{x:g,y:p}=new X(a.x,a.y).mul({x:c.width,y:c.height}).rotateRadians(this.ogma.view.getAngle()).add(f);t.moveTo(g,p),t.arc(g,p,this.options.magnetHandleRadius/r,0,Math.PI*2)}),t.fill(),t.closePath()});v(this,"_onFeatureDrag",(t,r)=>{const a=r;if(lt(t)&&a==="line")["start","end"].find(c=>{const f=c==="start"?kt(t):Mt(t);return this._snapToText(t,a,f)||this._findAndSnapToNode(t,c,f)});else if(lt(t)&&a!=="line"){const c=a==="start"?kt(t):Mt(t);this._snapToText(t,a,c)||this._findAndSnapToNode(t,a,c)}else wt(t)&&(this.activeLinks.forEach(({arrow:c,side:f,connectionPoint:g})=>{const p=this.getAnnotation(c),s=at(t),d=ut(t),m=new X(g.x,g.y).mul({x:s.width,y:s.height}).rotateRadians(this.ogma.view.getAngle()).add(d);p.geometry.coordinates[f==="start"?0:1]=[m.x,m.y]}),this.activeLinks.length&&this.arrows.refreshLayer());this.layer.refresh(),this.emit(Ft,t,r)});v(this,"_onFeatureDragEnd",t=>{this.dragged!==null&&lt(t)&&kt(this.dragged)&&He.forEach(r=>{this.links.getArrowLink(t.id,r)&&this.emit(an,{arrow:t,link:this.links.getArrowLink(t.id,r)})}),(wt(t)||lt(t))&&this.onUpdate(t),this.dragged=null,this.activeLinks=[],this.textToMagnet=void 0,this.annotations.forEach(r=>r.enableDetection()),this.layer.refresh(),this.emit(Tt,t)});v(this,"_onFeatureDragStart",t=>{this.textToMagnet=void 0,lt(t)?this.dragged=t:wt(t)&&this.activeLinks.push(...this.links.getTargetLinks(t.id,"text")),this.annotations.forEach(r=>{const a=r.getSelectedFeature();a&&a!==t&&r.unhover().unselect(),r.disableDetection()}),this.emit(Bt,t)});v(this,"_onNodesDragStart",()=>{this.arrows.unhover().unselect(),this.texts.unhover().unselect()});v(this,"_onNodesDrag",t=>{const{dx:r,dy:a}=t;this._moveNodes(t.nodes,r,a)});v(this,"_onLayoutEnd",t=>{t.ids.forEach((r,a)=>{this.links.getTargetLinks(r,"node").forEach(f=>{const g=this.getAnnotation(f.arrow),p=f.side,s=Dt(g,p==="start"?"end":"start"),d=t.positions.current[a],m=this.ogma.getNode(r).getAttribute("radius"),A=Lt(s,d,+m);mt(g,p,A.x,A.y)})}),this.arrows.refreshLayer(),this.texts.refreshLayer()});v(this,"_onAdded",t=>{this.emit(re,t)});v(this,"_onRemoved",t=>{this.emit(ie,t)});v(this,"_onUnselect",t=>{this.selected=null,this.emit(ne,t)});v(this,"_onSelect",t=>{this.selected!==t&&(this.selected=t,this.emit(ee,this.selected))});v(this,"onUpdate",t=>{cancelAnimationFrame(this.updateTimeout),this.updateTimeout=requestAnimationFrame(()=>this._onUpdate(t))});v(this,"_onUpdate",t=>{this.emit(se,t)});this.options=this.setOptions({...dn,...r}),this.ogma=t,this.arrows=new ze(t,this.options),this.texts=new Ne(t,this.options),this.annotations=[this.arrows,this.texts],this.annotations.forEach(a=>{a.on(Bt,this._onFeatureDragStart).on(Ft,this._onFeatureDrag).on(Tt,this._onFeatureDragEnd).on(se,this.onUpdate).on(ne,this._onUnselect).on(ee,this._onSelect).on(re,this._onAdded).on(ie,this._onRemoved)}),this.ogma.events.on("nodesDragStart",this._onNodesDragStart).on("nodesDragProgress",this._onNodesDrag).on("layoutEnd",this._onLayoutEnd).on(["viewChanged","rotate"],()=>{this.refreshTextLinks()}),this.layer=t.layers.addCanvasLayer(this._render),this.layer.moveToBottom()}_moveNodes(t,r,a){t.forEach(c=>{const f=this.links.getTargetLinks(c.getId(),"node"),g=c.getPosition();f.forEach(p=>{const s=this.getAnnotation(p.arrow),d=p.side,m=Dt(s,d==="start"?"end":"start");let A=g;const T=+c.getAttribute("radius"),S=1e-6;(p.connectionPoint.x-(g.x-r)>S||p.connectionPoint.y-(g.y-a)>S)&&(A=Lt(m,g,T)),mt(s,d,A.x,A.y)})}),this.arrows.refreshLayer()}_snapToText(t,r,a){const c=this.texts.detect(a,this.options.detectMargin);if(this.links.remove(t,r),!c)return!1;this.textToMagnet=c;const f=this.findMagnetPoint(Re,c,a);return f?(mt(t,r,f.point.x,f.point.y),this.links.add(t,r,c.id,"text",f.magnet),!0):!1}_findAndSnapToNode(t,r,a){const c=this.ogma.view.graphToScreenCoordinates(a),f=this.ogma.view.getElementAt(c);this.links.remove(t,r),f&&f.isNode?(this.hoveredNode=f,this.hoveredNode.setSelected(!0),this._snapToNode(t,r,f,c)):(this.hoveredNode&&this.hoveredNode.setSelected(!1),this.hoveredNode=null)}_snapToNode(t,r,a,c){const f=a.getPositionOnScreen(),g=+a.getAttribute("radius"),p=g*this.ogma.view.getZoom(),s=c.x-f.x,d=c.y-f.y,m=Math.sqrt(s*s+d*d),A=a.getPosition();if(m<p+this.options.detectMargin){let T=A;if(m>p/2){const S=Dt(t,r==="end"?"start":"end");T=Lt(S,T,g)}mt(t,r,T.x,T.y),this.links.add(t,r,a.getId(),"node",T)}}refreshTextLinks(){let t=!1;this.links.forEach(({connectionPoint:r,targetType:a,target:c,arrow:f,side:g})=>{if(a!=="text")return;t=!0;const p=this.getAnnotation(c),s=this.getAnnotation(f),d=at(p),m=ut(p),A=new X(r.x,r.y).mul({x:d.width,y:d.height}).rotateRadians(this.ogma.view.getAngle()).add(m);mt(s,g,A.x,A.y)}),t&&this.arrows.refreshLayer()}getSelected(){return this.selected}findMagnetPoint(t,r,a){let c;for(const f of t){const g=at(r),p=ut(r),s=new X(f.x,f.y).mul({x:g.width,y:g.height}).rotateRadians(this.ogma.view.getAngle()).add(p),d=s.sub(a).length(),m=Math.min(this.options.magnetRadius*this.ogma.view.getZoom(),g.width/2,g.height/2);if(d<Math.max(m,this.options.magnetHandleRadius)){c={point:s,magnet:f};break}}return c}setOptions(t={}){return this.options={...this.options||{},...t},this.options}select(t){const r=this.getAnnotations().features.find(a=>a.id===t);return r?(lt(r)?this.arrows.select(r.id):wt(r)&&this.texts.select(r.id),this):this}unselect(){return this.selected?(lt(this.selected)?this.arrows.unselect():wt(this.selected)&&this.texts.unselect(),this):this}add(t){if(ae(t))return t.features.forEach(r=>this.add(r)),this.arrows.refreshLayer(),this;switch(t.properties.type){case"text":this.texts.add(t);break;default:this.arrows.add(t),this.loadLink(t);break}return this}remove(t){return ae(t)?(t.features.forEach(r=>this.remove(r)),this):(lt(t)?(this.links.remove(t,"start"),this.links.remove(t,"end"),this.arrows.remove(t.id)):this.texts.remove(t.id),this)}loadLink(t){if(t.properties.link)for(const r of He){const a=t.properties.link[r];if(!a)continue;if(this.getAnnotation(a.id))this.links.add(t,r,a.id,a.type,a.magnet);else{const f=this.ogma.getNode(a.id);if(!f)continue;this.links.add(t,r,a.id,a.type,a.magnet);const g=f.getPosition(),p=f.getAttribute("radius")||0,s=Dt(t,r==="start"?"end":"start"),d=Lt(s,g,+p);mt(t,r,d.x,d.y)}}}startArrow(t,r,a){this.cancelDrawing(),this.arrows.startDrawing(t,r,a)}startText(t,r,a){this.cancelDrawing(),this.texts.startDrawing(t,r,a)}cancelDrawing(){this.annotations.forEach(t=>t.cancelDrawing()),this.emit(on)}updateStyle(t,r){const a=this.getAnnotations().features.find(c=>c.id===t);return a?(lt(a)?this.arrows.updateStyle(a,r):wt(a)&&this.texts.updateStyle(a,r),this.onUpdate(a),this):this}getAnnotations(){const t={type:"FeatureCollection",features:[]};return this.annotations.forEach(r=>{t.features=[...t.features,...r.getElements()]}),t}getAnnotation(t){return this.getAnnotations().features.find(r=>r.id===t)}destroy(){this.annotations.forEach(t=>t.destroy()),this.layer.destroy()}}I.Arrows=ze,I.Control=fn,I.Texts=Ne,I.createArrow=be,I.createSVGElement=Et,I.createText=Le,I.defaultArrowOptions=Wt,I.defaultArrowStyle=St,I.defaultControllerOptions=oe,I.defaultTextOptions=qt,I.defaultTextStyle=vt,I.getAnnotationsBounds=en,I.getArrowEnd=Mt,I.getArrowEndPoints=zt,I.getArrowSide=Dt,I.getArrowStart=kt,I.getAttachmentPointOnNode=Lt,I.getHandleId=te,I.getTextBbox=Kt,I.getTextPosition=ut,I.getTextSize=at,I.isAnnotationCollection=ae,I.isArrow=lt,I.isText=wt,I.setArrowEnd=Qt,I.setArrowEndPoint=mt,I.setArrowStart=Jt,I.setTextBbox=Se,I.updateTextBbox=Ae,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
23
23
  //# sourceMappingURL=index.umd.js.map