figureone 0.10.14 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/figureone.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Fig",[],e):"object"==typeof exports?exports.Fig=e():t.Fig=e()}(self,(function(){return(()=>{"use strict";var t={477:t=>{t.exports=function(t,e,n,i){var r,o=self||window;try{try{try{r=new o.Blob([t])}catch(a){(r=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(t),r=r.getBlob()}var a=o.URL||o.webkitURL,s=a.createObjectURL(r),l=new o[e](s,n);return a.revokeObjectURL(s),l}catch(a){return new o[e]("data:application/javascript,".concat(encodeURIComponent(t)),n)}}catch(a){if(!i)throw Error("Inline worker is not supported");return new o[e](i,n)}}}},e={};function n(i){var r=e[i];return void 0!==r||(r=e[i]={exports:{}},t[i](r,r.exports,n)),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&((t=e.currentScript?e.currentScript.src:t)||(e=e.getElementsByTagName("script")).length&&(t=e[e.length-1].src)),!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})();var i={};return(()=>{n.d(i,{default:()=>bf});var t={};n.r(t),n.d(t,{clipMag:()=>p,clipValue:()=>m,decelerate:()=>y,easein:()=>x,easeinout:()=>b,easeout:()=>w,linear:()=>v,rand:()=>_,rand2D:()=>B,randElement:()=>P,randElements:()=>M,randInt:()=>O,randSign:()=>k,range:()=>A,removeRandElement:()=>E,round:()=>d,roundNum:()=>f,sinusoid:()=>S,sinusoidAbs:()=>T,triangle:()=>g});var e={};n.r(e),n.d(e,{Console:()=>nt,Notification:()=>Ct,NotificationManager:()=>jt,ObjectKeyPointer:()=>rt,ObjectTracker:()=>Bt,PerformanceTimer:()=>Dt,UniqueMap:()=>bt,addToObject:()=>at,assignObjectFromTo:()=>lt,classify:()=>it,cleanUIDs:()=>mt,compressObject:()=>wt,copyKeysFromTo:()=>vt,deleteKeys:()=>yt,diffObjToPaths:()=>Mt,diffPathsToObj:()=>Et,download:()=>Rt,duplicate:()=>st,duplicateFromTo:()=>ht,extractFrom:()=>ot,generateRandomString:()=>gt,generateUniqueId:()=>dt,getElement:()=>function(t,e){return ot(t,e,"_","_")},getFromObject:()=>function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:".";return 0===e.length||e===n?t:void 0!==(n=ot(t,e,"",n))?n.value():void 0},getObjectDiff:()=>kt,isTouchDevice:()=>pt,joinObjects:()=>ct,joinObjectsWithOptions:()=>ut,loadRemote:()=>function(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;document.getElementById(t)?null!=i&&i(t,e):((n=document.createElement("script")).type="text/javascript",n.src=e,n.id=t,document.body&&document.body.appendChild(n),n.onload=function(){null!=i&&i(t,e)})},loadRemoteCSS:()=>function(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;document.getElementById(t)?null!=i&&i(t,e):((n=document.createElement("link")).rel="stylesheet",n.type="text/css",n.href=e,n.id=t,document.body&&document.body.appendChild(n),n.onload=function(){null!=i&&i(t,e)})},minify:()=>St,objectToPaths:()=>At,pathsToObj:()=>_t,refAndDiffToObject:()=>Pt,splitString:()=>Ft,uncompressObject:()=>xt,unminify:()=>Tt,updateObjFromPath:()=>Ot});var r={};n.r(r),n.d(r,{copy:()=>function(t){return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]},identity:()=>Wt,inverse:()=>Gt,mul:()=>It,rotate:()=>Ht,rotationMatrix:()=>qt,scale:()=>Ut,scaleMatrix:()=>Kt,t:()=>Lt,transform:()=>Vt,translate:()=>Nt,translationMatrix:()=>zt});var o={};n.r(o),n.d(o,{Bounds:()=>Ke,Line:()=>Se,LineBounds:()=>Ge,Point:()=>pe,RangeBounds:()=>Ue,Rect:()=>fe,RectBounds:()=>Ve,Rotation:()=>Oe,Scale:()=>Pe,Transform:()=>Ee,TransformBounds:()=>$e,Translation:()=>_e,Vector:()=>Te,clipAngle:()=>ae,comparePoints:()=>je,curvedPath:()=>ye,deceleratePoint:()=>Qe,decelerateTransform:()=>Ze,decelerateValue:()=>Je,deg:()=>function(t){return 180*t/Math.PI},distance:()=>ge,getBorder:()=>nn,getBoundingBorder:()=>Le,getBoundingRect:()=>Ie,getBounds:()=>Ye,getDeltaAngle:()=>xe,getLine:()=>ke,getMaxTimeFromVelocity:()=>Ne,getMoveTime:()=>qe,getPoint:()=>ue,getPoints:()=>ce,getPositionInRect:()=>rn,getRect:()=>de,getScale:()=>he,getTransform:()=>Be,getTriangleCenter:()=>tn,isBuffer:()=>De,isParsablePoint:()=>en,isParsableTransform:()=>Me,isTransformArrayZero:()=>function(t){function e(t){return-i<t&&t<i}function n(t){for(var n=0;n<t.length;n+=1)if(!e(t[n]))return!1;return!0}var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-5;return"number"==typeof t?e(t):Array.isArray(t)?n(t):n(t=Object.values(t).filter((function(t){return null!=t})))},line:()=>Ae,linearPath:()=>me,minAngleDiff:()=>be,normAngle:()=>we,normAngleTo90:()=>function(t){return(t=we(t))>Math.PI/2&&t<Math.PI&&(t+=Math.PI),(t=t===Math.PI?0:t)>Math.PI&&t<3*Math.PI/2&&(t-=Math.PI),t},parsePoint:()=>le,polarToRect:()=>Re,quadBezierPoints:()=>He,quadraticBezier:()=>oe,randomPoint:()=>function(t){return t=B(t.left,t.bottom,t.right,t.top),new pe(t.x,t.y)},rectToPolar:()=>Fe,spaceToSpaceScale:()=>function(t,e){var n=e.x.width/t.x.width;return t=e.y.height/t.y.height,new pe(n,t)},spaceToSpaceTransform:()=>Ce,threePointAngle:()=>We,threePointAngleMin:()=>ze,transformValueToArray:()=>Xe,translationPath:()=>ve});var a={};n.r(a),n.d(a,{addArrows:()=>Hn,joinLinesInPoint:()=>Fn,joinLinesInTangent:()=>Dn,lineSegmentsToPoints:()=>Rn,makeFastPolyLine:()=>Kn,makePolyLine:()=>Nn,makePolyLineCorners:()=>qn});var s={};n.r(s),n.d(s,{circleCloudShapes:()=>function(t){for(var e=ct({},{radius:1,position:[0,0],num:10,size:.01,shape:Xn.bind(this)},t),n=ue(e.position),i=[],r=Qn(e.shape),o=0;o<e.num;o+=1){var a=_(0,2*Math.PI),s=_(_(0,e.radius/2),e.radius);i.push.apply(i,Vn(r([s*Math.cos(a)+n.x,s*Math.sin(a)+n.y],e.size)))}return i},getPixels:()=>Zn,getPolygonCorners:()=>function(t){for(var e=ct({},{sides:4,rotation:0,radius:1,position:[0,0],direction:1},t),n=ue(e.position),i=[],r=2*Math.PI/e.sides,o=0;o<e.sides;o+=1)i.push(new pe(e.radius*Math.cos(e.direction*(r*o+e.rotation))+n.x,e.radius*Math.sin(e.direction*(r*o+e.rotation))+n.y));return i},imageToShapes:()=>function(t){var e,n,i,r,o=ut({except:"image"},{},{num:null,xAlign:"center",yAlign:"middle",align:"image",distribution:"random",filter:function(){return!0},position:[0,0],dither:0,width:null,height:null,excess:"repeatOpaqueOnly",shape:"square",makeColors:Jn.bind(this)},t),a=(c=t.image).height,s=c.width,l=o.filter,u=Qn(o.shape),c=(t=Zn((n=(e=c).width,i=e.height,(r=document.createElement("canvas")).width=n,r.height=i,(r=r.getContext("2d")).drawImage(e,0,0),r.getImageData(0,0,n,i).data),s,a,l)).min,h=(l=t.max,t.pixels),f=t.pixelColors,d=h.length;null!=o.num&&(d=o.num),s-=1,a-=1;var p=[0,0];"filteredImage"===o.align&&(s=l[0]-c[0],a=l[1]-c[1],p=[-c[0],c[1]]),l=o.width;var m=o.height;null==o.height&&null==o.width?l=(m=1)/a*s:null!=o.height&&null==o.width?l=o.height/a*s:null!=o.width&&null==o.height&&(m=o.width/s*a);var y=l/s,v=m/a,g=(c=ue(o.position),s=o.xAlign,a=o.yAlign,new pe(0,0));"left"===s?g.x=c.x:"right"===s?g.x=c.x-l:"center"===s?g.x=c.x-l/2:"number"==typeof s?g.x=c.x+l*s:null!=s&&"o"===s.slice(-1)[0]&&(g.x=c.x+parseFloat(s)),"top"===a?g.y=c.y-m:"bottom"===a?g.y=c.y:"middle"===a?g.y=c.y-m/2:"number"==typeof a?g.y=c.y-m*a:null!=a&&"o"===a.slice(-1)[0]&&(g.y=c.y-parseFloat(a));for(var b=[],w=[],x=Array(h.length),S=[],T=0;T<h.length;T+=1).99999999<=f[x[T]=T][3]&&S.push(T);for(var A=x.slice(),k=Array(A.length),P=0;P<k.length;P+=1)k[P]=[_(-o.dither,o.dither),_(-o.dither,o.dither)];for(var E=0;E<d;E+=1){var M=(A=0===A.length?"lastOpaque"===o.excess?Array(d-E).fill(S.slice(-1)[0]):("repeatOpaqueOnly"===o.excess?S:x).slice():A)[0];"random"===o.distribution?(M=A[C=O(0,A.length-1)],A.splice(C,1)):A.splice(0,1);var B=h[M],C=f[M];M=u(B=new pe(g.x+B[0]*y+p[0]*y+k[M][0],g.y+m-B[1]*v+p[1]*v+k[M][1]),o.size||y),B=[],null!=o.makeColors&&(B=o.makeColors(C,M.length/2)),b.push.apply(b,Vn(M)),w.push.apply(w,Vn(B))}return[b,w]},pointsToShapes:()=>function(t){for(var e=ct({},{size:.01,shape:Xn.bind(this),makeColors:null},t),n=Qn(e.shape),i=[],r=[],o=0;o<e.points.length;o+=1){var a=ue(e.points[o]),s=n(a,e.size),l=[];null!=e.makeColors&&(l=e.makeColors(s.length/2,a)),i.push.apply(i,Vn(s)),r.push.apply(r,Vn(l))}return[i,r]},polygonCloudShapes:()=>function(t){for(var e=ct({},{sides:4,rotation:0,radius:1,position:[0,0],num:10,size:.01,shape:Xn.bind(this)},t),n=ue(e.position),i=[],r=e.radius*Math.cos(Math.PI/e.sides),o=Qn(e.makePoints),a=0;a<e.num;a+=1){var s=_(0,2*Math.PI),l=2*Math.PI/e.sides,u=Math.floor(s/l)*l;l=Math.abs(s-u-l/2),l=_(_(0,(l=r/Math.cos(l))/2),l),i.push.apply(i,Vn(o([l*Math.cos(s+e.rotation)+n.x,l*Math.sin(s+e.rotation)+n.y],e.size)))}return i},polyline:()=>function(t){var e,n=ut({except:"points"},{},{num:null,close:!1,width:.01,simple:!1},t),i=t.points.map(ue);t=0,null==n.num?t=(e=i).length:e=(t=Un(ti(i,t=n.num,n.close),1))[0];var r=Un(Kn(e,n.width,n.close),1)[0];n.close&&r.splice(-2,2),r=r.map((function(t){return t.round()}));for(var o=n.simple?Array(6*r.length*2):n.close?Array(12*r.length*2+6):Array(12*r.length*2),a=0,s=function(t,e,n,i,r,s){o[a]=t.x,o[a+1]=t.y,o[a+2]=e.x,o[a+3]=e.y,o[a+4]=n.x,o[a+5]=n.y,o[a+6]=i.x,o[a+7]=i.y,o[a+8]=r.x,o[a+9]=r.y,o[a+10]=s.x,o[a+11]=s.y,a+=12},l=0;l<r.length-2;l+=4){var u=[r[l],r[l+1],r[l+2],r[l+3]];s(u[0],u[1],u[2],u[1],u[3],u[2]),!n.simple&&l<r.length-4?s(u[2],u[3],r[l+4],u[2],u[3],r[l+5]):!n.simple&&n.close&&s(u[2],u[3],r[0],u[2],u[3],r[1])}return o},polylineToShapes:()=>function(t){for(var e=ct({},{close:!1,size:.01,shape:Xn.bind(this),makeColors:null},t),n=Qn(e.shape),i=[],r=[],o=(t=Un(ti(t=e.points.map(ue),e.num,e.close),3))[0],a=t[1],s=t[2],l=0;l<o.length;l+=1){var u=o[l],c=n(u,e.size),h=[],f=l*s;null!=e.makeColors&&(h=e.makeColors(c.length/2,u,f,f/a)),i.push.apply(i,Vn(c)),r.push.apply(r,Vn(h))}return[i,r]},rectangleCloudShapes:()=>function(t){for(var e=ct({},{width:1,height:1,position:[0,0],num:10,size:.01,shape:Xn.bind(this)},t),n=ue(e.position),i=[],r=Qn(e.shape),o=0;o<e.num;o+=1){var a=_(-e.width/2,e.width/2)+n.x,s=_(-e.height/2,e.height/2)+n.y;i.push.apply(i,Vn(r([a,s],e.size)))}return i}});var l={};n.r(l),n.d(l,{HexToArray:()=>Ci,RGBToArray:()=>Bi,areColorsSame:()=>Fi,areColorsWithinDelta:()=>Di,colorArrayToRGB:()=>function(t){return"rgb(".concat(Math.floor(255*t[0]),",").concat(Math.floor(255*t[1]),",").concat(Math.floor(255*t[2]),")")},colorArrayToRGBA:()=>Ri,cssColorToArray:()=>ji,getCSSColors:()=>Mi});var u={};n.r(u),n.d(u,{AnimationBuilder:()=>ms,AnimationManager:()=>ss,AnimationStep:()=>hi,ColorAnimationStep:()=>ur,CustomAnimationStep:()=>go,DelayAnimationStep:()=>Ro,DimAnimationStep:()=>cr,DissolveInAnimationStep:()=>Tr,DissolveOutAnimationStep:()=>Ar,OpacityAnimationStep:()=>Sr,ParallelAnimationStep:()=>Ki,PositionAnimationStep:()=>Ti,PulseAnimationStep:()=>to,PulseTransformAnimationStep:()=>Dr,RotationAnimationStep:()=>qr,ScaleAnimationStep:()=>Yr,ScenarioAnimationStep:()=>Ji,SerialAnimationStep:()=>Oo,TransformAnimationStep:()=>Mr,TriggerAnimationStep:()=>lo,UndimAnimationStep:()=>hr,custom:()=>function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ho(go,e)},delay:()=>Fo,dim:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return tr(cr,[t].concat(n))},dissolveIn:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return dr(Tr,[t].concat(n))},dissolveOut:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return dr(Ar,[t].concat(n))},inParallel:()=>Ui,inSerial:()=>_o,trigger:()=>uo,undim:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return tr(hr,[t].concat(n))}});var c={};n.r(c),n.d(c,{actionWord:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:dt(),n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],r="action_word";return i&&(r="".concat(r," interactive_word")),i=null,{replacementText:Ts(t,e,r="string"==typeof n?"".concat(n," ").concat(r):r,i=Array.isArray(n)?n:i).replacementText,id:e}},addClass:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return{replacementText:function(e){return Ts(e,"",t)}}},addId:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return{replacementText:function(e){return Ts(e,t)}}},applyModifiers:()=>Os,centerH:()=>xs,centerV:()=>ws,centerVH:()=>function(){var t=bs(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",0);return'<div style="display: table; height: 100%; text-align:center; width:100%;">\n <div style="display: table-cell; vertical-align: middle; height: 100%; width: 100%;">\n '.concat(t,"</div></div>")},click:()=>As,clickW:()=>function(t,e,n){return As(e,n,{color:3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,text:t})},highlight:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e="highlight_word";"string"==typeof t&&(e="".concat(t," ").concat(e));var n=null;return Array.isArray(t)&&(n=t),{replacementText:function(t){return Ts(t,"",e,n)}}},highlightWord:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n="highlight_word",i=null;return{replacementText:Ts(t,"",n="string"==typeof e?"".concat(e," ").concat(n):n,i=Array.isArray(e)?e:i).replacementText}},itemSelector:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[""],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n='<ul id="id__figureone_item_selector_'.concat(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,'" \n class=').concat(e,">");return t.forEach((function(t,e){n+='<li id="id__figureone_item_selector_'.concat(e,'">').concat(t,"</li>")})),n+="</ul>"},link:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n="action_word interactive_word",i=null,r=a={color:null,id:"figureone__id_".concat(dt()),interactive:!0,classes:"",text:null,newTab:!0};Array.isArray(e)?i=e:null!=e&&(r=ct(a,e));var o=r,a=o.color,s=o.id,l=(e=o.classes,o.text);null!=a&&(i=a),""!==e&&(n="".concat(n," ").concat(e));var u=r.newTab?' target="_blank"':"";return{replacementText:function(e){var r=s?' id="'.concat(s,'"'):"",o=i?' style="color:'.concat(Ri(i),';"'):"";return{replacementText:"<a href=".concat(t).concat(r,'class="').concat(n,'"').concat(o,' rel="noreferrer noopener"').concat(u,">").concat((l||e).trim(),"</a>")}},id:function(){return s}}},onClickId:()=>ks,setHTML:()=>Ps,setOnClicks:()=>_s,style:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n="",i="",r="",o="",a="",s="",l="",u="",c="";"number"==typeof t?r="margin-top:".concat(t,"%"):(null!=t.left&&(n="margin-left:".concat(t.left,"%;")),null!=t.right&&(i="margin-right:".concat(t.right,"%;")),t.centerV&&(r="margin-top:0;"),null!=t.top&&(r="margin-top:".concat(t.top,"%;")),null!=t.line&&(o="margin-top:".concat(t.line,"%;")),null!=t.size&&(a="font-size:".concat(t.size,"em;")),t.className&&(s='class="'.concat(t.className,'"')),t.color&&(l="color:".concat(Ri(t.color),";")),t.listStyleType&&(u="list-style-type:".concat(t.listStyleType,";")),t.id&&(c='id="'.concat(t.id,'"')));var h='<p style="'.concat(n).concat(i).concat(o).concat(a).concat(l,'"').concat(s,">"),f='<p style="'.concat(n).concat(i).concat(r).concat(a).concat(l,'"').concat(s).concat(c,">"),d=(o='<li style="'.concat(n).concat(i).concat(o).concat(a).concat(l).concat(u,'"').concat(s,">"),u='<ul style="'.concat(n).concat(i).concat(r).concat(a).concat(l,'"').concat(s).concat(c,">"),c='<ol style="'.concat(n).concat(i).concat(r).concat(a).concat(l,'"').concat(s).concat(c,">"),null!=t.list?(d=Array.isArray(e)?e.join("</li>".concat(o)):e,"unordered"===t.list?"".concat(u).concat(o).concat(d,"</ul>"):"".concat(c).concat(o).concat(d,"</ol>")):(d=Array.isArray(e)?e.join("</p>".concat(h)):e,"".concat(f).concat(d,"</p>")));return t.centerH&&(d=xs(d)),t.centerV?ws(d):d},toHTML:()=>Ts,unit:()=>Ss,withClass:()=>function(){var t=1<arguments.length?arguments[1]:void 0,e=bs(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"");return'<div class="'.concat(t,'">').concat(e,"</div>")}});var h={};n.r(h),n.d(h,{getCSSColors:()=>Mi,getCSSVariables:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],i={},r=t;if((r="string"==typeof t?document.getElementById(t):r)instanceof HTMLElement){var o=window.getComputedStyle(r);if(o)for(var a=o.length,s=0;s<a;s+=1){var l,u,c,h=o[s];""!==e&&!h.startsWith(e)||null!=(u=o.getPropertyValue(h))&&(u=u.trim(),l=parseFloat(u),Number.isNaN(l)||(u=l),n?i[c=ki(h,e)]=u:(c=new RegExp(e,"g"),at(i,c=h.replace(c,""),u,"-")))}}return i},getDefinedCSSVariables:()=>Oi,searchObject:()=>function t(e,n,i){var r=[];return Object.keys(e).forEach((function(o){var a,s="".concat(n,".").concat(o);o.includes(i)?r.push(s):"object"===Ai(e[o])?(a=t(e[o],s,i))&&(r=r.concat(a)):"string"==typeof e[o]&&e[o].includes(i)&&r.push(s)})),r}});var f=function(t){var e=Math.pow(10,1<arguments.length&&void 0!==arguments[1]?arguments[1]:5);return-0!=(t=Math.round(t*e)/e)||0===t&&1/t!=-1/0?t:0};function d(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5,n=0;return Array.isArray(t)?t.map((function(t){return d(t,e)})):("number"==typeof t?n=f(t,e):null!=t&&null!=t.round&&(n=t.round(e)),n)}function p(t,e,n){var i=t;return e=e,null===n?t:(-(e=(e=null===e?0:e)<0?-e:e)<=t&&t<=e&&(i=0),(n=n<0?-n:n)<t&&(i=n),t<-n?-n:i)}function m(t,e,n){return null!==n&&n<t?n:null!==e&&t<e?e:t}var y=function(t,e,n,i,r){var o=0,a=0;return 0===p(e,o=null!==r?r:o,e)?{p:t,v:0}:(r=a=null!==n?n:a,a<0&&(r=-r),0===(a=(a=e-(n=e/Math.abs(e))*r*i)/Math.abs(a)!=n?0:p(a,o,a))&&(o/Math.abs(o)!=n&&(o=-o),i=Math.abs((o-e)/r)),{p:t+e*i-.5*n*r*i*i,v:a})},v=function(t){return t};function g(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+2*(3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)/Math.PI*Math.asin(Math.sin(2*Math.PI*e*t+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0)))}var b=function(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(.5===t)return.5;var e=t;return(2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)}return Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))};function w(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(0===t)return 0;var e=t/2+.5;return 2*((2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)-.5)}return t=.5+t/2,2*(Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))-.5)}function x(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(1===t)return 1;var e=t/2;return(2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)*2}return t/=2,Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))*2}function S(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+(3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)*Math.sin(t*e*2*Math.PI+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0))}function T(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+Math.abs((3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)*Math.sin(t*e*2*Math.PI+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0)))}function A(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:8,r=[];if(t<e){if(n<=0)return[];for(var o=t;o<=e;o=d(o+n,i))r.push(o)}else{if(0<=n)return[];for(var a=t;e<=a;a=d(a+n,i))r.push(a)}return r}function k(){return.5<Math.random()?1:-1}function O(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=0;return r=null!=n?(e=t,Math.floor(Math.random()*Math.floor(n-e)+Math.floor(e))):Math.floor(Math.random()*Math.floor(t)),i&&(r*=k()),r}function _(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=0;return r=null!=n?(e=t,Math.random()*(n-e)+e):Math.random()*t,i&&(r*=k()),r}function P(t){return t[O(t.length)]}function E(t){var e=_(t.length);return t.splice(e,1)[0]}function M(t,e){for(var n=A(0,e.length-1,1),i=[],r=0;r<t;r+=1){var o=E(n);i.push(e[o])}return i}function B(t,e,n,i){return{x:_(t,n),y:_(e,i)}}function C(t){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function j(t,e,n){return(j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=W(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function R(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&F(t,e)}function F(t,e){return(F=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=W(t);return I(this,e?(n=W(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function I(t,e){if(e&&("object"===C(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return L(t)}function L(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function W(t){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function z(t){return function(t){if(Array.isArray(t))return N(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return N(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?N(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function q(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function H(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function K(t,e,n){return e&&H(t.prototype,e),n&&H(t,n),t}var U=function(){function t(){q(this,t),this.map={}}return K(t,[{key:"add",value:function(t,e){null==this.map&&(this.map={}),this.map[t]={fn:e}}},{key:"exec",value:function(t){if(null==t)return null;for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];if("string"==typeof t&&null!=this.map[t])return 0===i.length?this.map[t].fn():(e=this.map[t]).fn.apply(e,i);if("function"==typeof t)return t.apply(void 0,i);throw new Error("".concat(t," needs to be a function or a string"))}},{key:"execOnMaps",value:function(t,e){if(null==t)return null;for(var n=arguments.length,i=new Array(2<n?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];if("string"==typeof t){for(var o=[this.map].concat(z(e)),a=0;a<o.length;a+=1){var s=o[a];if(null!=s[t])return 0===i.length?s[t].fn():(s=s[t]).fn.apply(s,i)}throw new Error("FunctionMap Error: '".concat(t,"' does not exist in map"))}if("function"==typeof t)return t.apply(void 0,i);throw new Error("FunctionMap Error: '".concat(t,"' needs to be a function or a string"))}}]),t}(),V=function(){R(e,U);var t=D(e);function e(){var n;return q(this,e),e.instance||(n=t.call(this),e.instance=L(n),n.map={}),I(n,e.instance)}return e}(),G=function(){R(e,U);var t=D(e);function e(){var n;return q(this,e),(n=t.call(this)).global=new V,n}return K(e,[{key:"exec",value:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.execOnMaps.apply(this,[t,[this.global.map]].concat(n))}},{key:"execOnMaps",value:function(t,n){for(var i,r=arguments.length,o=new Array(2<r?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return(i=j(W(e.prototype),"execOnMaps",this)).call.apply(i,[this,t,[].concat(z(n),[this.global.map])].concat(o))}},{key:"add",value:function(t,n){return j(W(e.prototype),"add",this).call(this,t,n)}}]),e}();function Y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||$(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(t){return function(t){if(Array.isArray(t))return Q(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||$(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(t,e){if(t){if("string"==typeof t)return Q(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Q(t,e):void 0}}function Q(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function J(t){return(J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Z(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function et(t,e,n){return e&&tt(t.prototype,e),n&&tt(t,n),t}var nt=function(){var t;(t=console).log.apply(t,arguments)},it=function(t,e){return e="-"===(e=e||t)[0]||e.startsWith("".concat(t,"-"))?"".concat(t," ").concat(e):e,t=" ".concat(t,"-"),"".concat(e.split(" -").join(t))},rt=function(){function t(e,n){Z(this,t),this.object=e,this.key="",n in e&&(this.key=n)}return et(t,[{key:"setValue",value:function(t){this.key&&(this.object[this.key]=t)}},{key:"execute",value:function(){if(this.key){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.object[this.key].apply(null,e)}}},{key:"value",value:function(){if(this.key)return this.object[this.key]}}]),t}();function ot(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_",r=[];if("string"!=typeof e)return Array.isArray(e)?e.forEach((function(e){void 0!==(e=ot(t,e,n,i))&&r.push(e)})):Object.keys(e).forEach((function(i){n+i in t&&r.push({obj:new rt(t,n+i),value:e[i]})})),r;if(n+e in t)return new rt(t,n+e);var o=e.split(i).filter((function(t){return 0<t.length})),a="".concat(n).concat(o[0]);if(1<o.length){if(a in t)return ot(t[a],o.slice(1).join(i),n,i)}else if(1===o.length&&a in t)return new rt(t,a)}function at(t,e,n){var i=e.split(3<arguments.length&&void 0!==arguments[3]?arguments[3]:".").filter((function(t){return 0<t.length})),r=t;i.forEach((function(t,e){e!==i.length-1?(Object.prototype.hasOwnProperty.call(r,t)||(r[t]={}),r=r[t]):r[t]=n}))}function st(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t||NaN===t||"function"==typeof t)return t;if("function"==typeof t._dup)return t._dup();if(Array.isArray(t)){var e=[];return t.forEach((function(t){return e.push(st(t))})),e}var n={};return Object.keys(t).forEach((function(e){var i=st(t[e]);n[e]=i})),n}function lt(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=3<arguments.length&&void 0!==arguments[3]&&arguments[3],r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"",o="string"==typeof n?[n]:n;Object.keys(t).forEach((function(n){var a,s,l=""!==r?"".concat(r,".").concat(n):n;-1===o.indexOf(l)&&("object"===J(a=t[n])&&null!=a&&a._assignAsLinkOnly?e[n]=t[n]:"number"==typeof a||"boolean"==typeof a||"string"==typeof a||null==a||"function"==typeof a||"function"==typeof a._dup||Array.isArray(a)?void 0===a&&void 0!==e[n]||(e[n]=i?st(a):a):("number"!=typeof(s=e[n])&&"boolean"!=typeof s&&"string"!=typeof s&&null!=s&&"function"!=typeof s&&!Array.isArray(s)||(e[n]={}),lt(a,e[n],o,i,l)))}))}function ut(t){var e=t.except,n=t.duplicate;null==e&&(e=[]),null==n&&(n=!1);for(var i=arguments.length<=1?0:arguments.length-1,r=arguments.length<=1?void 0:arguments[1],o=1;o<i;o+=1){var a=o+1<1||arguments.length<=o+1?void 0:arguments[o+1];null!=a&&lt(a,r,e,n,"")}return r}function ct(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ut.apply(void 0,[{}].concat(e))}function ht(t,e){ut({except:2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],duplicate:!0},e,t)}var ft=function(){function t(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(Z(this,t),e)return t.instance||(t.instance=this).initialize(),t.instance;this.initialize()}return et(t,[{key:"initialize",value:function(){this.seeds={}}},{key:"getId",value:function(t){null==this.seeds[t]&&(this.seeds[t]=0);var e,n="".concat(t).concat((e=9-(n=this.seeds[t]).toString().length+1,Array(+(0<e&&e)).join("0")+n));return this.seeds[t]+=1,n}}]),t}();function dt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return(new ft).getId(t)}function pt(){var t=" -webkit- -moz- -o- -ms- ".split(" ");return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)||(t=["(",t.join("touch-enabled),("),"heartz",")"].join(""),window.matchMedia(t).matches)}var mt=function t(e){var n="0000000000";if(null!=e){if("uid"in e){if(e.uid===n)return;e.uid=n}for(var i=Object.keys(e),r=0;r<i.length;r+=1){var o=i[r],a=e[o];"object"!==J(a)||Array.isArray(a)||null==a||"function"==typeof a||"number"==typeof a||"boolean"==typeof a||"string"==typeof a||"figure"===o||t(a),"recorder"===o&&null!=e.recorder&&(e.recorder.figure=null)}}};function yt(t,e){e.forEach((function(e){void 0!==t[e]&&delete t[e]}))}function vt(t,e,n){n.forEach((function(n){void 0!==t[n]&&(e[n]=t[n])}))}function gt(){return(1e18*Math.random()).toString(36)}var bt=function(){function t(){Z(this,t),this.map={},this.index=1,this.inverseMap={},this.letters="0abcdefghijklmnopqrstuvwxz",this.undefinedCode=".a"}return et(t,[{key:"reset",value:function(){this.index=1,this.map={}}},{key:"add",value:function(t){if(null!=this.map[t])return this.map[t];var e=this.getNextUniqueString();return this.map[t]=e}},{key:"getNextUniqueString",value:function(){if(0===this.index)return"a";for(var t=Math.floor(Math.log(this.index)/Math.log(this.letters.length)),e=this.index,n="",i=t;0<=i;--i){var r=Math.floor(e/Math.pow(this.letters.length,i));e-=r*Math.pow(this.letters.length,i),n="".concat(n).concat(this.letters[r])}return this.index+=1,n}},{key:"makeInverseMap",value:function(){var t=this;this.inverseMap={},Object.keys(this.map).forEach((function(e){var n=t.map[e];t.inverseMap[n]=e}))}},{key:"get",value:function(t){if(t!==this.undefinedCode)return null!=this.inverseMap[t]?this.inverseMap[t]:t}}]),t}();function wt(t,e){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],i=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]&&arguments[5];if("string"==typeof t)return i&&o?e.get(t):i?e.add(t):t;if("number"==typeof t)return null===r||o?t:f(t,r);if("boolean"==typeof t||"function"==typeof t||null===t)return t;if(void 0===t)return e.undefinedCode;if(Array.isArray(t)){for(var a=0;a<t.length;a+=1)t[a]=wt(t[a],e,n,i,r,o);return t}if("object"!==J(t))return t;for(var s=Object.keys(t),l={},u=0;u<s.length;u+=1){var c,h=s[u];t[h]=wt(t[h],e,n,i,r,o),n&&o?null!=(c=e.get(h))&&(l[c]=t[h]):n?l[e.add(h)]=t[h]:l[h]=t[h]}return l}function xt(t,e){return wt(t,e,!(2<arguments.length&&void 0!==arguments[2])||arguments[2],!(3<arguments.length&&void 0!==arguments[3])||arguments[3],null,!0)}function St(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:4,n=new bt;return{minified:wt(t,n,!0,!0,e),map:n}}function Tt(t){var e,n=t.map;return n instanceof bt||((e=new bt).map=n.map,e.index=n.index,e.letters=n.letters,n=e),n.makeInverseMap(),xt(t.minified,n,!0,!0)}function At(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return"string"==typeof t||"boolean"==typeof t||"function"==typeof t?n["".concat(e)]=t:"number"==typeof t?n["".concat(e)]=null!=i?f(t,i):t:null===t?n["".concat(e)]=null:void 0===t||(Array.isArray(t)?t.forEach((function(t,r){At(t,"".concat(e,"[").concat(r,"]"),n,i)})):Object.keys(t).forEach((function(r){At(t[r],"".concat(e,".").concat(r),n,i)}))),n}function kt(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]&&arguments[4],o=t,a=At(o=0<e.length?Pt.apply(void 0,[t].concat(X(e))):o,"",{},i),s=At(n,"",{},i),l={},u={},c={};return Object.keys(a).forEach((function(t){void 0!==s[t]?a[t]!==s[t]&&(u[t]=r?[a[t],s[t]]:s[t]):c[t]=a[t]})),Object.keys(s).forEach((function(t){void 0===a[t]&&(l[t]=s[t])})),i={},0<Object.keys(u).length&&(i.diff=u),0<Object.keys(l).length&&(i.added=l),0<Object.keys(c).length&&(i.removed=c),i}function Ot(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]&&arguments[3];if(0!==(o=t[0]).length){var r=o.match(/\[[^\]]*\]/g),o=o.replace(/\[.*/,"");if(1!==t.length||!i||r){if(r){var a=r.map((function(t){return parseInt(t.replace(/\[|\]/g,""),10)}));null!=e[o]&&Array.isArray(e[o])||(e[o]=[]);for(var s=e[o],l=0,u=0;u<a.length;u+=1){if(l=a[u],s.length<=l)for(var c=s.length;c<l-s.length+1;c+=1)s.push(void 0);u<a.length-1&&(Array.isArray(s[l])||(s[l]=[]),s=s[l])}return 1===t.length&&i?void(s[l]=void 0):1===t.length?void(s[l]=n):(null!=s[l]&&"object"===J(s[l])||(s[l]={}),void Ot(t.slice(1),s[l],n,i))}1!==t.length?(null==e[o]&&(e[o]={}),Ot(t.slice(1),e[o],n,i)):e[o]=n}else delete e[o]}}function _t(t){var e={};return Object.keys(t).forEach((function(n){var i=n.split(".").filter((function(t){return 0<t.length}));n=t[n],Array.isArray(n)?Ot(i,e,n.slice(-1)[0]):Ot(i,e,n)})),e}function Pt(t){for(var e=st(t),n=function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];Object.keys(t).forEach((function(i){var r=i.split(".").filter((function(t){return 0<t.length}));i=t[i],Array.isArray(i)?Ot(r,e,i.slice(-1)[0],n):Ot(r,e,i,n)}))},i=arguments.length,r=new Array(1<i?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];return r.forEach((function(t){var e=t.added,i=t.removed;t=t.diff,null!=i&&n(i,!0),null!=e&&n(e),null!=t&&n(t)})),e}function Et(t){var e={};return t.diff&&0<Object.keys(t.diff).length&&(e.diff=_t(t.diff)),t.added&&0<Object.keys(t.added).length&&(e.added=_t(t.added)),t.removed&&0<Object.keys(t.removed).length&&(e.removed=_t(t.removed)),e}function Mt(t){var e={};return t.diff&&0<Object.keys(t.diff).length&&(e.diff=At(t.diff)),t.added&&0<Object.keys(t.added).length&&(e.added=At(t.added)),t.removed&&0<Object.keys(t.removed).length&&(e.removed=At(t.removed)),e}var Bt=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;Z(this,t),this.precision=e,this.reset()}return et(t,[{key:"toObj",value:function(){var t=this,e={};Object.keys(this.references).forEach((function(n){e[n]={basedOn:t.references[n].basedOn,diff:Et(t.references[n].diff)}}));var n=this.diffs.map((function(t){return[t[0],t[1],Et(t[2]),t[3]]}));return{baseReference:st(this.baseReference),diffs:n,references:e,precision:this.precision,lastReferenceName:this.lastReferenceName}}},{key:"setFromObj",value:function(t){var e={};Object.keys(t.references).forEach((function(n){e[n]={basedOn:t.references[n].basedOn,diff:Mt(t.references[n].diff)}})),this.references=e,this.baseReference=st(t.baseReference),this.precision=t.precision,this.diffs=t.diffs.map((function(t){return[t[0],t[1],Mt(t[2]),t[3]]})),this.lastReferenceName=t.lastReferenceName}},{key:"reset",value:function(){this.baseReference=null,this.references={},this.diffs=[],this.lastReferenceName="__base"}},{key:"setBaseReference",value:function(t){this.baseReference=st(t),this.lastReferenceName="__base"}},{key:"addReference",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"__base";null!=this.baseReference&&"__base"!==e||this.setBaseReference(t),"__base"!==e&&(this.references[e]={diff:this.getDiffToReference(t,n),basedOn:n},this.lastReferenceName=e)}},{key:"getReferenceChain",value:function(t,e){return"__base"===t||null==this.references[t]?e:this.getReferenceChain(this.references[t].basedOn,[this.references[t].diff].concat(X(e)))}},{key:"getReference",value:function(t){return t=this.getReferenceChain(t,[]),Pt.apply(void 0,[this.baseReference].concat(X(t)))}},{key:"getDiffToReference",value:function(t,e){return e=this.getReferenceChain(e,[]),kt(this.baseReference,e,t,this.precision)}},{key:"getObjFromDiffAndReference",value:function(t,e){return e=this.getReferenceChain(e,[]),t=[].concat(X(e),[t]),Pt.apply(void 0,[this.baseReference].concat(X(t)))}},{key:"add",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(e),e=this.getDiffToReference(e,n),this.diffs.push([t,n,e,i])}},{key:"addWithWorker",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(e),this.startWorker(),null!=this.worker&&this.worker.postMessage([t,n,e,i])}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new Worker)}},{key:"getFromIndex",value:function(t){if(t>this.diffs.length||0===this.diffs.length)return null;t=(e=Y(this.diffs[t],3))[1];var e=e[2];return this.getObjFromDiffAndReference(e,t)}}]),t}(),Ct=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new G;Z(this,t),this.fnMap=e,this.subscribers={},this.nextId=0,this.order=[]}return et(t,[{key:"add",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1;return this.subscribers["".concat(this.nextId)]={callback:t,num:e},this.order.push("".concat(this.nextId)),this.nextId+=1,this.nextId-1}},{key:"publish",value:function(t){for(var e=this,n=[],i=0;i<this.order.length;i+=1){var r=this.order[i],o=this.subscribers[r],a=o.callback,s=o.num;1===s&&n.push(r),o=0!==s,0<s&&(this.subscribers["".concat(r)].num=s-1),o&&this.fnMap.exec(a,t)}n.forEach((function(t){e.remove(t)}))}},{key:"remove",value:function(t){t="".concat(t),null!=this.subscribers[t]&&delete this.subscribers[t],-1<(t=this.order.indexOf(t))&&this.order.splice(t,1)}},{key:"_excludeStateKeys",value:function(){return["fnMap"]}}]),t}(),jt=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new G;Z(this,t),this.notifications={},this.fnMap=e}return et(t,[{key:"add",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1;return null==this.notifications[t]&&(this.notifications[t]=new Ct(this.fnMap)),this.notifications[t].add(e,n)}},{key:"publish",value:function(t,e){null!=this.notifications[t]&&this.notifications[t].publish(e)}},{key:"remove",value:function(t,e){var n;null!=this.notifications[t]&&((n=this.notifications[t]).remove(e),0===n.order.length&&delete this.notifications[t])}},{key:"_excludeStateKeys",value:function(){return["fnMap"]}}]),t}();function Rt(t,e){var n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,".concat(encodeURIComponent(e))),n.setAttribute("download",t),n.style.display="none",null!=(t=document.body)&&(t.appendChild(n),n.click(),t.removeChild(n))}function Ft(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"|",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=(t=t.split(""),[]),r=[],o=!1,a=!1,s=0,l=-1;return t.forEach((function(t){var u;r.push(t),0===s&&t===n&&!1===o?o=!0:t===n&&0===s&&o?a=!0:t===e[s]?s+=1:(s=0,o=!1),s===e.length&&(r=o?(t=r.slice(0,-e.length-n.length),u=r.slice(-e.length),[].concat(X(t),X(u))):((0<(u=r.slice(0,-e.length).join("")).length||0<i.length)&&i.push(u),0===u.length&&-1===l?l=0:-1===l&&(l=1),[]),o=!1,s=0),a&&(o=a=!1,r=r.slice(0,-1))})),0<r.length&&i.push(r.join("")),[i,l]}var Dt=function(){function t(){Z(this,t),this.reset()}return et(t,[{key:"reset",value:function(){this.stamps=[[performance.now(),"init"]],this.index=1}},{key:"stamp",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"m".concat(this.index);this.stamps.push([performance.now(),t]),this.index+=1}},{key:"deltas",value:function(){var t,e=[0],n=0;return this.stamps.forEach((function(i,r){i=(o=Y(i,2))[0];var o=o[1];0<r&&(r=i-t,e.push([o,Math.round(100*r)/100]),n+=r),t=i})),e[0]=Math.round(100*n)/100,e}},{key:"log",value:function(){null==window.figureOneDebug&&(window.figureOneDebug={misc:[]}),window.figureOneDebug.misc.push(this.deltas())}}]),t}();function It(t,e){return[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]]}function Lt(t){return[t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]]}function Wt(){return[1,0,0,0,1,0,0,0,1]}function zt(t,e){return[1,0,t,0,1,e,0,0,1]}function Nt(t,e,n){return[t[0],t[1],t[2]+t[0]*e+t[1]*n,t[3],t[4],t[5]+t[3]*e+t[4]*n,t[6],t[7],t[8]+t[6]*e+t[7]*n]}function qt(t){var e=Math.cos(t);return[e,-(t=Math.sin(t)),0,t,e,0,0,0,1]}function Ht(t,e){var n=Math.cos(e);return e=Math.sin(e),[t[0]*n+t[1]*e,t[0]*-e+t[1]*n,t[2],t[3]*n+t[4]*e,t[3]*-e+t[4]*n,t[5],t[6]*n+t[7]*e,t[6]*-e+t[7]*n,t[8]]}function Kt(t,e){return[t,0,0,0,e,0,0,0,1]}function Ut(t,e,n){return[t[0]*e,t[1]*n,t[2],t[3]*e,t[4]*n,t[5],t[6]*e,t[7]*n,t[8]]}function Vt(t,e,n){return[t[0]*e+t[1]*n+t[2],t[3]*e+t[4]*n+t[5]]}function Gt(t){var e=1/(t[0]*(t[4]*t[8]-t[7]*t[5])-t[1]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*t[7]-t[4]*t[6]));return[(t[4]*t[8]-t[7]*t[5])*e,(t[2]*t[7]-t[1]*t[8])*e,(t[1]*t[5]-t[2]*t[4])*e,(t[5]*t[6]-t[3]*t[8])*e,(t[0]*t[8]-t[2]*t[6])*e,(t[3]*t[2]-t[0]*t[5])*e,(t[3]*t[7]-t[6]*t[4])*e,(t[6]*t[1]-t[0]*t[7])*e,(t[0]*t[4]-t[3]*t[1])*e]}function Yt(t){return(Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Xt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$t(t,e)}function $t(t,e){return($t=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Qt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=Zt(t);return Jt(this,e?(n=Zt(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function Jt(t,e){if(e&&("object"===Yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}function Zt(t){return(Zt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function te(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ee(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function ne(t,e,n){return e&&ee(t.prototype,e),n&&ee(t,n),t}function ie(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return re(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?re(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function re(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function oe(t,e,n,i){return(1-i)*((1-i)*t+i*e)+i*((1-i)*e+i*n)}function ae(t,e){return null===e||(t%=2*Math.PI,"0to360"===e&&(t<0&&(t+=2*Math.PI),t>=2*Math.PI&&(t-=2*Math.PI)),"-180to180"===e&&(t<-Math.PI&&(t+=2*Math.PI),t>=Math.PI&&(t-=2*Math.PI)),"-360to0"===e&&(0<t&&(t-=2*Math.PI),t<=2*-Math.PI&&(t+=2*Math.PI))),t}function se(t,e){var n;return null!=(n=t?t.precision:n)?n:1<arguments.length&&void 0!==e?e:8}function le(t,e){if(t instanceof pe)return t;var n=e;if(null==n&&(n=null),null==t)return n;if("string"==typeof(e=t))try{e=JSON.parse(e)}catch(t){return n}return Array.isArray(e)?2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]?new pe(e[0],e[1]):n:null==e.f1Type?"number"==typeof e?new pe(e,e):n:"p"===e.f1Type&&null!=e.state&&Array.isArray([e.state])&&2===e.state.length?(e=(t=ie(e.state,2))[0],t=t[1],new pe(e,t)):n}function ue(t){return null==(t=le(t))?new pe(0,0):t}function ce(t){return!Array.isArray(t)||2===t.length&&"number"==typeof t[0]?[ue(t)]:t.map(ue)}function he(t){return"number"==typeof t?new pe(t,t):ue(t)}var fe=function(){function t(e,n,i,r){te(this,t),this.left=e,this.width=i,this.height=r,this.bottom=n,this.top=n+r,this.right=e+i}return ne(t,[{key:"_dup",value:function(){return new t(this.left,this.bottom,this.width,this.height)}},{key:"_state",value:function(t){return t=se(t),{f1Type:"rect",state:[f(this.left,t),f(this.bottom,t),f(this.width,t),f(this.height,t)]}}},{key:"isPointInside",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=ue(t).round(e),i=f(this.top,e),r=f(this.bottom,e);return t=f(this.left,e),e=f(this.right,e),!(n.x<t||n.x>e||n.y<r||n.y>i)}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,n=new t(f(this.left,e),f(this.bottom,e),f(this.width,e),f(this.height,e));return n.width=f(n.width,e),n.height=f(n.height,e),n.top=f(n.top,e),n.right=f(n.right,e),n}},{key:"intersectsWith",value:function(t){var e=ue(t),n=this.center();return t=new Se(n,e),e=new Se(n,this.width+this.height,t.angle()),n=new Se([this.left,this.bottom],[this.left,this.top]),(t=e.intersectsWith(n)).withinLine?t.intersect:(n=new Se([this.left,this.top],[this.right,this.top]),(t=e.intersectsWith(n)).withinLine?t.intersect:(n=new Se([this.right,this.top],[this.right,this.bottom]),(t=e.intersectsWith(n)).withinLine?t.intersect:(n=new Se([this.left,this.bottom],[this.right,this.bottom]),(t=e.intersectsWith(n)).withinLine?t.intersect:null)))}},{key:"intersectsWithLine",value:function(t){var e=ke(t),n=new Se([this.left,this.bottom],[this.left,this.top]),i=new Se([this.left,this.top],[this.right,this.top]),r=new Se([this.right,this.top],[this.right,this.bottom]),o=new Se([this.left,this.bottom],[this.right,this.bottom]);return t=[],(n=e.intersectsWith(n)).withinLine&&t.push(n.intersect),(i=e.intersectsWith(i)).withinLine&&t.push(i.intersect),(o=e.intersectsWith(o)).withinLine&&t.push(o.intersect),(r=e.intersectsWith(r)).withinLine&&t.push(r.intersect),t}},{key:"center",value:function(){return new pe(this.left+this.width/2,this.bottom+this.height/2)}}]),t}();function de(t){return null==(t=function(t,e){if(t instanceof fe)return t;var n=e;if(null==n&&(n=null),null==t)return n;var i=t;if("string"==typeof i)try{i=JSON.parse(i)}catch(t){return n}if(Array.isArray(i)&&4===i.length)return new fe(i[0],i[1],i[2],i[3]);var r=i;return e=r.f1Type,t=r.state,null!=e&&"rect"===e&&null!=t&&Array.isArray([t])&&4===t.length?(r=(i=ie(t,4))[0],e=i[1],t=i[2],i=i[3],new fe(r,e,t,i)):n}(t))?new fe(0,0,1,1):t}var pe=function(){function t(e,n){te(this,t),this.x=e,this.y=n,this._type="point"}return ne(t,[{key:"_state",value:function(t){return t=se(t),{f1Type:"p",state:[f(this.x,t),f(this.y,t)]}}},{key:"_dup",value:function(){return new t(this.x,this.y)}},{key:"scale",value:function(e){return new t(this.x*e,this.y*e)}},{key:"sub",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return e instanceof t?new t(this.x-e.x,this.y-e.y):new t(this.x-e,this.y-n)}},{key:"add",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return e instanceof t?new t(this.x+e.x,this.y+e.y):new t(this.x+e,this.y+n)}},{key:"distance",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?Math.sqrt(this.x*this.x+this.y*this.y):(null==(t=ue(t))?this:this.sub(t)).distance()}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new t(f(this.x,e),f(this.y,e))}},{key:"clip",value:function(e,n){var i,r;return e=e instanceof t?(i=e.x,e.y):i=e,n=n instanceof t?(r=n.x,n.y):r=n,new t(m(this.x,i,r),m(this.y,e,n))}},{key:"transformBy",value:function(e){return new t((e=Vt(e,this.x,this.y))[0],e[1])}},{key:"quadraticBezier",value:function(e,n,i){return new t(oe(this.x,e.x,n.x,i),oe(this.y,e.y,n.y,i))}},{key:"rotate",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new t(0,0),i=Math.cos(e);return e=[i,-(e=Math.sin(e)),e,i],n=this.sub(i=n),new t(e[0]*n.x+e[1]*n.y+i.x,e[2]*n.x+e[3]*n.y+i.y)}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=this;return t=t,"number"==typeof e&&(n=this.round(e),t=t.round(e)),n.x===t.x&&n.y===t.y}},{key:"isWithinDelta",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-7,n=Math.abs(this.x-t.x);return t=Math.abs(this.y-t.y),!(e<n||e<t)}},{key:"isNotEqualTo",value:function(t,e){return!this.isEqualTo(t,e)}},{key:"isNotWithinDelta",value:function(t){return!this.isWithinDelta(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-7)}},{key:"isWithinLine",value:function(t,e){return t.hasPointOn(this,e)}},{key:"getShaddowOnLine",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=new Se(this,1,t.angle()+Math.PI/2).intersectsWith(t).intersect;return null!=n&&n.isWithinLine(t,e)?n:null}},{key:"shaddowIsOnLine",value:function(t){return null!=this.getShaddowOnLine(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8)}},{key:"clipToLine",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t.hasPointOn(this,e)?this._dup():null!=(e=this.getShaddowOnLine(t,e))?e:(this.distance(t.p1)<=this.distance(t.p2)?t.p1:t.p2)._dup()}},{key:"isOnUnboundLine",value:function(t,e){return t.hasPointAlong(this,e)}},{key:"isInPolygon",value:function(e){var n=0,i=e.length-1,r=e.slice(),o=this;e=!1,r[0].isNotEqualTo(r[i])&&(r.push(r[0]),e=!0,i+=1);for(var a=0;a<i;a+=1)r[a].y<=o.y?r[a+1].y>o.y&&0<t.isLeft(r[a],r[a+1],o)&&(n+=1):r[a+1].y<=o.y&&t.isLeft(r[a],r[a+1],o)<0&&--n;return e&&r.pop(),0!==n}},{key:"isOnPolygon",value:function(t){var e=!1,n=t.length-1,i=t.slice();i[0].isNotEqualTo(i[n])&&(i.push(i[0]),e=!0,n+=1);for(var r=0;r<n;r+=1){var o=Ae(i[r],i[r+1]);if(this.isWithinLine(o))return e&&i.pop(),!0}return this.isInPolygon(t)?(e&&i.pop(),!0):(e&&i.pop(),!1)}},{key:"toPolar",value:function(){return{mag:Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)),angle:Math.atan2(this.y,this.x)}}},{key:"toDelta",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"linear",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{magnitude:.5,offset:.5,controlPoint:null};return ve(n,this._dup(),t,e,i)}}],[{key:"zero",value:function(){return new t(0,0)}},{key:"Unity",value:function(){return new t(1,1)}},{key:"isLeft",value:function(t,e,n){return(e.x-t.x)*(n.y-t.y)-(n.x-t.x)*(e.y-t.y)}}]),t}();function me(t,e,n){return t.add(e.x*n,e.y*n)}function ye(t,e,n,i){var r,o,a,s,l=i;null==(c=i.controlPoint)&&(r=Math.PI/2,null!=l.angle&&(r=l.angle),u=0,null!=l.offset&&(u=l.offset),null==l.direction&&(l.direction="positive"),o=1,null!=l.magnitude&&(o=l.magnitude),a=ae((s=new Se(t,t.add(e))).angle(),"0to360"),i=t.add(new pe(e.x*u,e.y*u)),(u=a)>=Math.PI&&(u-=Math.PI),u=a+r,"positive"===(l=l.direction)?u=a+r:"negative"===l?u=a-r:"up"===l?u=a<=Math.PI/2||a>=Math.PI/2*3?a+r:a-r:"down"===l?u=a<=Math.PI/2||a>=Math.PI/2*3?a-r:a+r:"left"===l?u=a<=Math.PI?a+r:a-r:"right"===l&&(u=a<=Math.PI?a-r:a+r),s=o*s.length(),c=new pe(i.x+s*Math.cos(u),i.y+s*Math.sin(u)));var u=t,c=ue(c);return t=t.add(e),e=oe(u.x,c.x,t.x,n),n=oe(u.y,c.y,t.y,n),new pe(e,n)}function ve(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"linear",e=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,i=3<arguments.length?arguments[3]:void 0,r=4<arguments.length?arguments[4]:void 0;return"linear"===t?me(e,n,i):"curved"===t||"curve"===t?ye(e,n,i,r):new pe(0,0)}function ge(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function be(t,e){return t===e?0:Math.atan2(Math.sin(t-e),Math.cos(t-e))}function we(t){for(var e=t;e>=2*Math.PI;)e-=2*Math.PI;for(;e<0;)e+=2*Math.PI;return e}function xe(t,e){var n=n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return(t=we(t))===(e=we(e))?0:0===(n=2===n?e<t?-1:1:n)?be(e,t):1===n&&e<t?2*Math.PI-t+e:-1===n&&t<e?-t-(2*Math.PI-e):e-t}var Se=function(){function t(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:2;te(this,t),this.p1=ue(e),null==n?(this.ang=i,this.p2=this.p1.add(+Math.cos(this.ang),+Math.sin(this.ang))):"number"==typeof n?(this.p2=this.p1.add(n*Math.cos(i),n*Math.sin(i)),this.ang=i):(this.p2=ue(n),this.ang=Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)),this.ends=r,this.setupLine()}return ne(t,[{key:"_state",value:function(t){return t=se(t),{f1Type:"l",state:[[f(this.p1.x,t),f(this.p1.y,t)],[f(this.p2.x,t),f(this.p2.y,t)],this.ends]}}},{key:"setupLine",value:function(){this.A=this.p2.y-this.p1.y,this.B=this.p1.x-this.p2.x,this.C=this.A*this.p1.x+this.B*this.p1.y,this.distance=ge(this.p1,this.p2)}},{key:"_dup",value:function(){return new t(this.p1,this.p2,0,this.ends)}},{key:"setP1",value:function(t){this.p1=ue(t),this.ang=Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x),this.setupLine()}},{key:"setP2",value:function(t){this.p2=ue(t),this.ang=Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x),this.setupLine()}},{key:"getPoint",value:function(){return 2===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1)?this.p2:this.p1}},{key:"reverse",value:function(){return new t(this.p2,this.p1,0,this.ends)}},{key:"getYFromX",value:function(t){return 0!==this.B?(this.C-this.A*t)/this.B:null}},{key:"getXFromY",value:function(t){return 0!==this.A?(this.C-this.B*t)/this.A:null}},{key:"getYIntercept",value:function(){return this.getYFromX(0)}},{key:"getXIntercept",value:function(){return this.getXFromY(0)}},{key:"getGradient",value:function(){return 0===this.B?null:-this.A/this.B}},{key:"angle",value:function(){return this.ang}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,n=new t(this.p1,this.p2,0,this.ends);return n.A=f(n.A,e),n.B=f(n.B,e),n.C=f(n.C,e),n.ang=f(n.ang,e),n.distance=f(n.distance,e),n}},{key:"length",value:function(){return this.distance}},{key:"midPoint",value:function(){return this.pointAtPercent(.5)}},{key:"pointAtPercent",value:function(t){var e=this.length(),n=this.p2.sub(this.p1);return n=Math.atan2(n.y,n.x),new pe(this.p1.x+e*t*Math.cos(n),this.p1.y+e*t*Math.sin(n))}},{key:"pointAtLength",value:function(t){var e=this.p2.sub(this.p1).distance();return this.pointAtPercent(t/e)}},{key:"hasPointAlong",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;if(t=ue(t),null==e){if(this.C===this.A*t.x+this.B*t.y)return!0}else if(f(this.C,e)===f(this.A*t.x+this.B*t.y,e))return!0;return!1}},{key:"distanceToPoint",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t=ue(t),f(Math.abs(this.A*t.x+this.B*t.y-this.C)/Math.sqrt(Math.pow(this.A,2)+Math.pow(this.B,2)),e)}},{key:"hasPointOn",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return e=ue(e),!!this.hasPointAlong(e,n)&&(2===this.ends?!!function(t,e,n,i){if(null==i){if(t.x>=Math.min(e.x,n.x)&&t.x<=Math.max(e.x,n.x)&&t.y>=Math.min(e.y,n.y)&&t.y<=Math.max(e.y,n.y))return 1}else if(f(t.x,i)>=f(Math.min(e.x,n.x),i)&&f(t.x,i)<=f(Math.max(e.x,n.x),i)&&f(t.y,i)>=f(Math.min(e.y,n.y),i)&&f(t.y,i)<=f(Math.max(e.y,n.y),i))return 1}(e,this.p1,this.p2,n):1!==this.ends||!!this.p1.isEqualTo(e,n)||d(ae(new t(this.p1,e).ang,"0to360"),n)===d(ae(this.ang,"0to360"),n))}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=this;return t=t,!(n.ends!==t.ends||(2===n.ends?n.p1.isNotEqualTo(t.p1,e)&&n.p1.isNotEqualTo(t.p2,e)||n.p2.isNotEqualTo(t.p1,e)&&n.p2.isNotEqualTo(t.p2,e):1===n.ends?n.p1.isNotEqualTo(t.p1,e)||!n.hasPointOn(t.p2,e):!n.hasPointOn(t.p1)))}},{key:"isWithinDelta",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-8,n=this;return t=t,!(n.ends!==t.ends||(2===n.ends?n.p1.isNotWithinDelta(t.p1,e)&&n.p1.isNotWithinDelta(t.p2,e)||n.p2.isNotWithinDelta(t.p1,e)&&n.p2.isNotWithinDelta(t.p2,e):1===n.ends?n.p1.isNotWithinDelta(t.p1,e)||!n.hasPointOn(t.p2,e):!n.hasPointOn(t.p1)))}},{key:"hasLineWithin",value:function(t){return t.isWithinLine(this,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8)}},{key:"isAlongLine",value:function(t){var e=this.round(n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8),n=t.round(n);if(0===e.A&&0===e.B||0===n.A&&0===n.B)return!1;if(0!==e.A){var i=n.A/e.A;return e.B*i===n.B&&e.C*i===n.C}if(0!==n.A)return i=e.A/n.A,n.B*i===e.B&&n.C*i===e.C;if(0===e.B)return 0===n.B||(r=e.B/n.B,n.A*r===e.A&&n.C*r===e.C);var r=n.B/e.B;return e.A*r===n.A&&e.C*r===n.C}},{key:"isWithinLine",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,i=this.round(n),r=t.round(n);return!!i.isAlongLine(r,n)&&(0===t.ends||(i=function(){return r.hasPointOn(e.p1,n)&&r.hasPointOn(e.p2,n)},!(this.ends<t.ends)&&(this.ends,i())))}},{key:"offset",value:function(e,n){var i=this.ang;i>=Math.PI&&(i-=Math.PI),i<0&&(i+=Math.PI);var r=i-Math.PI/2;return"positive"===e?r=ae(this.ang,"0to360")+Math.PI/2:"negative"===e?r=ae(this.ang,"0to360")-Math.PI/2:i<Math.PI/2?"left"!==e&&"top"!==e||(r=i+Math.PI/2):"left"!==e&&"bottom"!==e||(r=i+Math.PI/2),new t(new pe(this.p1.x+n*Math.cos(r),this.p1.y+n*Math.sin(r)),new pe(this.p2.x+n*Math.cos(r),this.p2.y+n*Math.sin(r)),0,this.ends)}},{key:"isParallelWith",value:function(t){return t=this.A*t.B-t.A*this.B,0===f(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8)}},{key:"shaddowOn",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,i=this.intersectsWith(e,n).intersect;return null==i?null:(e=new t(i,1,e.ang+Math.PI/2),e=this.p1.getShaddowOnLine(e,n),e=(n=new t(this.p1,e)).distance,new t(i,new pe(this.p1.x+2*e*Math.cos(n.ang),this.p1.y+2*e*Math.sin(n.ang))))}},{key:"intersectsWith",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,i=e,r=this,o=f(this.distance,n);if(e=f(i.distance,n),0===o||0===e){var a,s=!1,l=!1;return 0===o&&0===e&&r.p1.isEqualTo(i.p1,n)&&(a=r.p1._dup(),l=s=!0),0<o&&(r.hasPointOn(i.p1,n)?(a=i.p1._dup(),s=l=!0):r.hasPointAlong(i.p1,n)&&(a=i.p1._dup(),s=!0)),0<e&&(i.hasPointOn(r.p1,n)?(a=r.p1._dup(),s=l=!0):i.hasPointAlong(r.p1,n)&&(a=r.p1._dup(),s=!0)),{intersect:a,alongLine:s,withinLine:l}}if(!r.isParallelWith(i))return c=0===f(r.A,n)&&0===f(i.B,n)?new pe(i.p1.x,r.p1.y):0===f(r.B,n)&&0===f(i.A,n)?new pe(r.p1.x,i.p1.y):0===f(r.B,n)?(s=(i.C*r.B-r.C*i.B)/(-r.A*i.B+i.A*r.B),l=-i.A/i.B*s+i.C/i.B,new pe(s,l)):(c=(i.C*r.B-r.C*i.B)/(-r.A*i.B+i.A*r.B),u=-r.A/r.B*c+r.C/r.B,new pe(c,u)),r.hasPointOn(c,n)&&i.hasPointOn(c,n)?{alongLine:!0,withinLine:!0,intersect:c}:{alongLine:!0,withinLine:!1,intersect:c};if(!r.isAlongLine(i,n))return{alongLine:!1,withinLine:!1,intersect:void 0};var u=this.getXIntercept(),c=null!=(c=this.getYIntercept())?new pe(0,c):new pe(null!=u?u:0,0);if(r.isEqualTo(i,n))return{alongLine:!0,withinLine:!0,intersect:d=2===r.ends?r.midPoint():1===r.ends?r.p1._dup():c};if((u=function(e,i){return!!e.hasLineWithin(i,n)&&(2===e.ends&&(p=new t(e.midPoint(),i.midPoint()).midPoint()),1===e.ends&&1===i.ends&&(p=new t(e.p1,i.p1)),1===e.ends&&2===i.ends&&(p=i.midPoint()),0===e.ends&&2===i.ends&&(p=i.midPoint()),0===e.ends&&1===i.ends&&(p=i.p1._dup()),e.ends>i.ends&&(p=2===e.ends?e.midPoint():e.p1),1===e.ends&&1===i.ends&&(p=new t(e.p1,i.p1).midPoint()),!0)})(r,i))return{alongLine:!0,withinLine:!0,intersect:p};if(u(i,r))return{alongLine:!0,withinLine:!0,intersect:p};if(2===r.ends&&2===i.ends){if(r.p1.isWithinLine(i,n)||r.p2.isWithinLine(i,n)||i.p1.isWithinLine(r,n)||i.p2.isWithinLine(r,n))return{alongLine:!0,withinLine:!0,intersect:p=(r.p1.isWithinLine(i,n)?i.p1.isWithinLine(r,n)?new t(r.p1,i.p1):new t(r.p1,i.p2):i.p1.isWithinLine(r,n)?new t(r.p2,i.p1):new t(r.p2,i.p2)).midPoint()};var h=new t(r.p1,i.p1),d=(c=new t(r.p1,i.p2),new t(r.p2,i.p1)),p=(u=new t(r.p2,i.p2),h.midPoint());return h=h.length(),c.length()<h&&(p=c.midPoint(),h=c.length()),d.length()<h&&(p=d.midPoint(),h=d.length()),u.length()<h&&(p=u.midPoint(),h=u.length()),{alongLine:!0,withinLine:!1,intersect:p}}if(1===r.ends&&1===i.ends)return{alongLine:!0,withinLine:!1,intersect:new t(r.p1,i.p1).midPoint()};var m=!1;return h=function(e,n){var i;p=e.p1.isWithinLine(n)?(m=!0,(n.p1.isWithinLine(e)?new t(e.p1,n.p1):new t(e.p1,n.p2)).midPoint()):(m=!1,i=new t(e.p1,n.p1),n=new t(e.p1,n.p2),(i.length()<n.length()?i:n).midPoint())},1===r.ends&&2===i.ends?h(r,i):h(i,r),{alongLine:!0,withinLine:m,intersect:p}}}]),t}(),Te=function(){Xt(e,Se);var t=Qt(e);function e(n,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return te(this,e),(r=n instanceof Se?t.call(this,n.p1,n.distance,n.ang):t.call(this,n,i,r)).i=r.distance*Math.cos(r.ang),r.j=r.distance*Math.sin(r.ang),Jt(r)}return ne(e,[{key:"unit",value:function(){return new e(this.p1,1,this.ang)}},{key:"dotProduct",value:function(t){return f(this.i*t.i+this.j*t.j,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8)}}]),e}();function Ae(t,e){return new Se(t,e)}function ke(t){return null==(t=function(t,e){if(t instanceof Se)return t;var n=void 0;if(null==n&&(n=null),null==t)return n;var i=t;if("string"==typeof i)try{i=JSON.parse(i)}catch(t){return n}return Array.isArray(i)?4===i.length?new Se(ue(i[0]),i[1],i[2],i[3]):3===i.length?"number"==typeof i[1]?new Se(ue(i[0]),i[1],i[2]):new Se(ue(i[0]),ue(i[1]),0,i[2]):2===i.length?new Se(ue(i[0]),ue(i[1])):n:null!=i.f1Type&&"l"===i.f1Type&&null!=i.state&&Array.isArray([i.state])&&3===i.state.length?(t=(e=ie(i.state,3))[0],i=e[1],e=e[2],new Se(ue(t),ue(i),0,e)):n}(t))?new Se(new pe(0,0),new pe(1,0)):t}var Oe=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";te(this,t);var i=n;if("string"==typeof(n=e))try{n=JSON.parse(n)}catch(e){n=0}"number"==typeof n?this.r=n:null!=n.f1Type&&"r"===n.f1Type&&null!=n.state&&Array.isArray(n.state)&&2===n.state.length?(n=(e=ie(n.state,2))[0],e=e[1],i=n,this.r=e):this.r=0,this.name=i}return ne(t,[{key:"isUnity",value:function(){return 0===this.r}},{key:"_state",value:function(t){return t=se(t),{f1Type:"r",state:[this.name,f(this.r,t)]}}},{key:"matrix",value:function(){return qt(this.r)}},{key:"transform",value:function(t){return Ht(t,this.r)}},{key:"sub",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t(0,this.name);return new t(this.r-e.r,this.name)}},{key:"round",value:function(){return new t(f(this.r,0<arguments.length&&void 0!==arguments[0]?arguments[0]:8),this.name)}},{key:"add",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t(0,this.name);return new t(this.r+e.r,this.name)}},{key:"mul",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t(1,this.name);return new t(this.r*e.r,this.name)}},{key:"_dup",value:function(){return new t(this.r,this.name)}}]),t}(),_e=function(){Xt(e,pe);var t=Qt(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";te(this,e);var o,a=r;if(r=n,n=i,"string"==typeof r){try{r=JSON.parse(r)}catch(n){r=0}Array.isArray(r)&&2===r.length&&(r=(i=ie(r,2))[0],n=i[1])}return(o=r instanceof pe?t.call(this,r.x,r.y):"number"==typeof r?t.call(this,r,n):null!=r.f1Type&&"t"===r.f1Type&&null!=r.state&&Array.isArray(r.state)&&3===r.state.length?(n=(o=ie(r.state,3))[0],r=o[1],o=o[2],a=n,t.call(this,r,o)):t.call(this,0,0)).name=a,Jt(o)}return ne(e,[{key:"isUnity",value:function(){return 0===this.x&&0===this.y}},{key:"_state",value:function(t){return t=se(t),{f1Type:"t",state:[this.name,f(this.x,t),f(this.y,t)]}}},{key:"matrix",value:function(){return zt(this.x,this.y)}},{key:"transform",value:function(t){return Nt(t,this.x,this.y)}},{key:"sub",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(0,0),n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return new pe(0,0),t="number"==typeof t?new e(t,n):t,new e(this.x-t.x,this.y-t.y,this.name)}},{key:"add",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(0,0),n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return new pe(0,0),t="number"==typeof t?new e(t,n):t,new e(this.x+t.x,this.y+t.y,this.name)}},{key:"mul",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(1,1);return new e(this.x*t.x,this.y*t.y,this.name)}},{key:"round",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new e(f(this.x,t),f(this.y,t),this.name)}},{key:"_dup",value:function(){return new e(this.x,this.y,this.name)}}]),e}(),Pe=function(){Xt(e,pe);var t=Qt(e);function e(n,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";te(this,e);var o,a=r;if(r=n,n=i,"string"==typeof r){try{r=JSON.parse(r)}catch(n){r=0}Array.isArray(r)&&2===r.length&&(r=(i=ie(r,2))[0],n=i[1])}return(o=r instanceof pe?t.call(this,r.x,r.y):"number"==typeof r?null!=n?t.call(this,r,n):t.call(this,r,r):null!=r.f1Type&&"s"===r.f1Type&&null!=r.state&&Array.isArray(r.state)&&3===r.state.length?(n=(o=ie(r.state,3))[0],r=o[1],o=o[2],a=n,t.call(this,r,o)):t.call(this,1,1)).name=a,Jt(o)}return ne(e,[{key:"isUnity",value:function(){return 1===this.x&&1===this.y}},{key:"_state",value:function(t){return t=se(t),{f1Type:"s",state:[this.name,f(this.x,t),f(this.y,t)]}}},{key:"matrix",value:function(){return Kt(this.x,this.y)}},{key:"transform",value:function(t){return Ut(t,this.x,this.y)}},{key:"sub",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(0,0),n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return new pe(0,0),t="number"==typeof t?new e(t,n):t,new e(this.x-t.x,this.y-t.y,this.name)}},{key:"round",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new e(f(this.x,t),f(this.y,t),this.name)}},{key:"add",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(0,0),n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return new pe(0,0),t="number"==typeof t?new e(t,n):t,new e(this.x+t.x,this.y+t.y,this.name)}},{key:"mul",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new e(1,1);return t instanceof e||t instanceof pe?new e(this.x*t.x,this.y*t.y):new e(this.x*t,this.y*t,this.name)}},{key:"_dup",value:function(){return new e(this.x,this.y,this.name)}}]),e}(),Ee=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";te(this,t),"string"==typeof e?(this.order=[],this.name=e):(this.order=e.map((function(t){return t._dup()})),this.name=n),this.index=this.order.length,this._type="transform",this.calcAndSetMatrix()}return ne(t,[{key:"_state",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{precision:8},e=[];return this.order.forEach((function(n){e.push(n._state(t))})),{f1Type:"tf",state:[this.name].concat(e)}}},{key:"standard",value:function(){return this.scale(1,1).rotate(0).translate(0,0)}},{key:"translate",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.name;return e=new _e(e,n,i),n=this.order.slice(),this.index!==this.order.length?(this.order[this.index]=e,this.index+=1,this.calcAndSetMatrix(),this):(n.push(e),new t(n,i))}},{key:"rotate",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.name,i=new Oe(e,n);return e=this.order.slice(),this.index!==this.order.length?(this.order[this.index]=i,this.index+=1,this.calcAndSetMatrix(),this):(e.push(i),new t(e,n))}},{key:"scale",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.name;return e=new Pe(e,n,i),n=this.order.slice(),this.index!==this.order.length?(this.order[this.index]=e,this.index+=1,this.calcAndSetMatrix(),this):(n.push(e),new t(n,i))}},{key:"remove",value:function(e){var n=[],i="string"==typeof e?[e]:e;return this.order.forEach((function(t){-1===i.indexOf(t.name)&&n.push(t._dup())})),new t(n,this.name)}},{key:"calcMatrix",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.order.length-1,n=e,i=[1,0,0,0,1,0,0,0,1],r=n=e<0?this.order.length+e:n;t<=r;--r)this.order[r].isUnity()||(i=It(i,this.order[r].matrix()));return i}},{key:"calcAndSetMatrix",value:function(){this.mat=this.calcMatrix()}},{key:"update",value:function(t){return t<this.order.length&&(this.index=t),this}},{key:"t",value:function(){for(var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=0,i=0;i<this.order.length;i+=1)if((t=this.order[i])instanceof _e){if(n===e)return new pe(t.x,t.y);n+=1}return null}},{key:"clipRotation",value:function(t){for(var e=0;e<this.order.length;e+=1){var n=this.order[e];n instanceof Oe&&(n.r=ae(n.r,t))}}},{key:"updateTranslation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;t instanceof pe&&(i=e);for(var r=0;r<this.order.length;r+=1)if(this.order[r]instanceof _e){if(n===i)return this.order[r]=new _e(t,e,this.name),this.calcAndSetMatrix(),this;n+=1}return this}},{key:"s",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0,n=0;n<this.order.length;n+=1){var i=this.order[n];if(i instanceof Pe){if(e===t)return new pe(i.x,i.y);e+=1}}return null}},{key:"toDelta",value:function(t,e,n,i){for(var r=this._dup(),o=0;o<this.order.length;o+=1){var a=this.order[o],s=t.order[o];a instanceof Pe&&s instanceof Pe&&(r.order[o]=a.add(s.mul(e))),a instanceof Oe&&s instanceof Oe&&(r.order[o]=new Oe(a.r+s.r*e,a.name)),a instanceof _e&&s instanceof _e&&(r.order[o]=new _e(ve(n,a,s,e,i),0,a.name))}return r}},{key:"updateScale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=new pe(1,1);t instanceof pe?(i=null==e?0:e,r=t):null==e?(r.x=t,r.y=t):(r.x=t,r.y=e);for(var o=0;o<this.order.length;o+=1)if(this.order[o]instanceof Pe){if(n===i)return this.order[o]=new Pe(r.x,r.y,this.name),this.calcAndSetMatrix(),this;n+=1}return this}},{key:"r",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0,n=0;n<this.order.length;n+=1){var i=this.order[n];if(i instanceof Oe){if(e===t)return i.r;e+=1}}return null}},{key:"updateRotation",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=0,i=0;i<this.order.length;i+=1)if(this.order[i]instanceof Oe){if(n===e)return this.order[i]=new Oe(t,this.name),this.calcAndSetMatrix(),this;n+=1}return this}},{key:"m",value:function(){return this.mat}},{key:"matrix",value:function(){return this.mat}},{key:"isSimilarTo",value:function(t){if(t.order.length!==this.order.length)return!1;for(var e=0;e<this.order.length;e+=1)if(this.order[e].constructor.name!==t.order[e].constructor.name)return!1;return!0}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;if(!this.isSimilarTo(t))return!1;for(var n=0;n<this.order.length;n+=1){var i=t.order[n],r=this.order[n];if(r.constructor.name!==i.constructor.name)return!1;if((r instanceof _e&&i instanceof _e||r instanceof Pe&&i instanceof Pe)&&i.isNotEqualTo(r,e))return!1;if(r instanceof Oe&&f(i.r,e)!==f(r.r,e))return!1}return!0}},{key:"isWithinDelta",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-8;if(!this.isSimilarTo(t))return!1;for(var n=0;n<this.order.length;n+=1){var i=t.order[n],r=this.order[n];if(r.constructor.name!==i.constructor.name)return!1;if((r instanceof _e&&i instanceof _e||r instanceof Pe&&i instanceof Pe)&&i.isNotWithinDelta(r,e))return!1;if(r instanceof Oe&&e<Math.abs(i.r-r.r))return!1}return!0}},{key:"sub",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t;if(!this.isSimilarTo(e))return new t(this.order,this.name);for(var n=[],i=0;i<this.order.length;i+=1)n.push(this.order[i].sub(e.order[i]));return new t(n,this.name)}},{key:"add",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t;if(!this.isSimilarTo(e))return new t(this.order,this.name);for(var n=[],i=0;i<this.order.length;i+=1)n.push(this.order[i].add(e.order[i]));return new t(n,this.name)}},{key:"mul",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t;if(!this.isSimilarTo(e))return new t(this.order,this.name);for(var n=[],i=0;i<this.order.length;i+=1)n.push(this.order[i].mul(e.order[i]));return new t(n,this.name)}},{key:"transform",value:function(e){var n=new t([],this.name);return n.order=e.order.concat(this.order),n.mat=It(this.matrix(),e.matrix()),n}},{key:"transformBy",value:function(e){var n=new t([],this.name);return n.order=this.order.concat(e.order),n.mat=It(e.matrix(),this.matrix()),n}},{key:"round",value:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,n=[],i=0;i<this.order.length;i+=1)n.push(this.order[i].round(e));return new t(n,this.name)}},{key:"clip",value:function(e,n,i){if(!this.isSimilarTo(e)||!this.isSimilarTo(n))return this._dup();for(var r=[],o=0;o<this.order.length;o+=1){var a,s,l=this.order[o],u=e.order[o],c=n.order[o];l instanceof _e&&u instanceof _e&&c instanceof _e?(a=m(l.x,u.x,c.x),s=m(l.y,u.y,c.y),r.push(new _e(a,s,this.name))):l instanceof Oe&&u instanceof Oe&&c instanceof Oe?r.push(new Oe(m(l.r,u.r,c.r),this.name)):l instanceof Pe&&u instanceof Pe&&c instanceof Pe&&(s=m(l.x,u.x,c.x),c=m(l.y,u.y,c.y),r.push(new Pe(s,c,this.name)))}var h,f=new t(r,this.name);return null!=i&&(null==(h=f.t())||(h=new Se(h,1,i.angle()+Math.PI/2).intersectsWith(i).intersect)&&(h.isWithinLine(i,4)?f.updateTranslation(h):ge(h,i.p1)<ge(h,i.p2)?f.updateTranslation(i.p1):f.updateTranslation(i.p2))),f}},{key:"clipMag",value:function(e,n){for(var i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=[],o=Xe(e,this),a=Xe(n,this),s=0;s<this.order.length;s+=1){var l,u,c,h=this.order[s];h instanceof _e?i?(l=(u=h.toPolar()).mag,u=u.angle,l=p(l,o[s],a[s]),r.push(new _e(l*Math.cos(u),l*Math.sin(u),this.name))):(l=p(h.x,o[s],a[s]),u=p(h.y,o[s],a[s]),r.push(new _e(l,u,this.name))):h instanceof Oe?(c=p(h.r,o[s],a[s]),r.push(new Oe(c,this.name))):h instanceof Pe&&(c=p(h.x,o[s],a[s]),h=p(h.y,o[s],a[s]),r.push(new Pe(c,h,this.name)))}return new t(r,this.name)}},{key:"constant",value:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=[],i=0;i<this.order.length;i+=1){var r=this.order[i];r instanceof _e?n.push(new _e(e,e,this.name)):r instanceof Oe?n.push(new Oe(e,this.name)):r instanceof Pe&&n.push(new Pe(e,e,this.name))}return new t(n,this.name)}},{key:"zero",value:function(){return this.constant(0)}},{key:"isZero",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0;e<this.order.length;e+=1){var n=this.order[e];if(n instanceof _e||n instanceof Pe){if(Math.abs(n.x)>t||Math.abs(n.y)>t)return!1}else if(n instanceof Oe&&ae(n.r,"0to360")>t)return!1}return!0}},{key:"_dup",value:function(){var e=new t;return e.name=this.name,e.order=this.order.map((function(t){return t._dup()})),e.mat=this.mat.slice(),e.index=this.index,e}},{key:"decelerate",value:function(t,e,n,i,r,o){var a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:8;return e=Xe(e,this),r=Xe(r,this),o=Xe(o,this),{velocity:(a=Ze(this,t,e,n,i=i instanceof $e?i:"none"===i?new $e(this):new $e(this,i),r,o,a)).velocity,transform:a.transform,duration:a.duration}}},{key:"timeToZeroV",value:function(t,e,n,i,r){return this.decelerate(t,e,null,n,i,r,5<arguments.length&&void 0!==arguments[5]?arguments[5]:8)}},{key:"velocity",value:function(e,n,i,r){var o=[];if(!this.isSimilarTo(e))return this.zero();for(var a=this.sub(e),s=0;s<a.order.length;s+=1){var l=a.order[s];l instanceof _e?o.push(new _e(l.x/n,l.y/n)):l instanceof Oe?o.push(new Oe(l.r/n)):l instanceof Pe&&o.push(new Pe(l.x/n,l.y/n))}return new t(o).clipMag(i,r)}},{key:"identity",value:function(){for(var e=[],n=0;n<this.order.length;n+=1){var i=this.order[n];i instanceof _e?e.push(new _e(0,0,this.name)):i instanceof Oe?e.push(new Oe(0,this.name)):i instanceof Pe&&e.push(new Pe(1,1,this.name))}return new t(e,this.name)}}]),t}();function Me(t){if(t instanceof Ee)return!0;if(Array.isArray(t)&&Array.isArray(t[0])&&("r"===t[0][0]||"s"===t[0][0]||"t"===t[0][0]))return!0;if(null!=t.f1Type&&"tf"===t.f1Type)return!0;if("string"!=typeof t)return!1;var e;try{e=JSON.parse(t)}catch(t){return!1}return Me(e)}function Be(t){return null==(t=function(t,e){if(t instanceof Ee)return t;var n=void 0;if(null==n&&(n=null),null==t)return n;var i=t;if("string"==typeof i)try{i=JSON.parse(i)}catch(t){return n}if(Array.isArray(i)){var r=new Ee;return i.forEach((function(t){var e,n,i;"string"!=typeof t?r=3!==t.length?(e=(i=ie(t,2))[0],n=i[1],"s"===e?r.scale(n,n):"t"===e?r.translate(n,n):r.rotate(n)):(e=(i=ie(t,3))[0],n=i[1],i=i[2],"s"===e?r.scale(n,i):r.translate(n,i)):r.name=t})),r}if(t=i.f1Type,e=i.state,null!=t&&"tf"===t&&null!=e&&Array.isArray(e)){var o=new Ee;return i.state.forEach((function(t){var e;"string"!=typeof t?null!=(e=t.f1Type)&&("s"===e?o=o.scale(t):"t"===e?o=o.translate(t):"r"===e&&(o=o.rotate(t))):o.name=t})),o}return n}(t))?new Ee:t}function Ce(t,e){var n=e.x.width/t.x.width,i=e.y.height/t.y.height;return new Ee(2<arguments.length&&void 0!==arguments[2]?arguments[2]:"").scale(n,i).translate(e.x.bottomLeft-t.x.bottomLeft*n,e.y.bottomLeft-t.y.bottomLeft*i)}function je(t,e,n,i){var r=new pe(0,0),o=new pe(0,0);return i?(r.x=t.x,r.y=t.y,o.x=t.x,o.y=t.y):(r.x=(t.x<e.x?t:e).x,r.y=(t.y<e.y?t:e).y,o.x=(t.x>n.x?t:n).x,o.y=(t.y>n.y?t:n).y),{min:r,max:o}}function Re(t,e){return new pe(t*Math.cos(e),t*Math.sin(e))}function Fe(t){var e="number"==typeof t?new pe(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0):t;return t=e.distance(),(e=Math.atan2(e.y,e.x))<0&&(e+=2*Math.PI),{mag:t,angle:e}}function De(t){if("number"==typeof t)return!0;if(!Array.isArray(t))return!1;if((4===t.length||2===t.length)&&"number"==typeof t[0])return!0;if("object"!==Yt(t))return!1;var e=Object.keys(t);if(4<e.length)return!1;for(var n=0;n<e.length;n+=1){var i=e[n];if("left"!==i&&"right"!==i&&"top"!==i&&"bottom"!==i)return!1}return!0}function Ie(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=!0,i={min:new pe(0,0),max:new pe(0,0)};t.forEach((function(t){Array.isArray(t)?t.forEach((function(t){i=je(t,i.min,i.max,n),n=!1})):i=je(t,i.min,i.max,n),n=!1}));var r,o,a=("number"==typeof e?l=s=a=r=e:Array.isArray(e)?2===e.length?(a=r=(o=ie(e,2))[0],l=s=o[1]):(r=(o=ie(e,4))[0],l=o[1],a=o[2],s=o[3]):(r=(e=ct({left:0,right:0,top:0,bottom:0},e)).left,a=e.right,s=e.top,l=e.bottom),{left:r,right:a,top:s,bottom:l}),s=a.left,l=a.bottom;return new fe(i.min.x-s,i.min.y-l,i.max.x-i.min.x+a.right+s,i.max.y-i.min.y+a.top+l)}function Le(t){return t=Ie(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),[new pe(t.left,t.bottom),new pe(t.right,t.bottom),new pe(t.right,t.top),new pe(t.left,t.top)]}function We(t,e,n){return t=t.sub(e),e=n.sub(e),t=t.toPolar().angle,e=e.toPolar().angle,ae(e-=t,"0to360")}function ze(t,e,n){return t=ae(Math.atan2(t.y-e.y,t.x-e.x),"0to360"),(t=ae(Math.atan2(n.y-e.y,n.x-e.x),"0to360")-t)>Math.PI?t=-(2*Math.PI-t):t<-Math.PI&&(t=2*Math.PI+t),t}function Ne(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,r=e.sub(t),o=0,a="number"==typeof n?t._dup().constant(n):n;return r.order.forEach((function(n,r){var s;!(n instanceof _e||n instanceof Pe)||((s=a.order[r])instanceof _e||s instanceof Pe)&&0!==s.x&&0!==s.y&&(l=Math.abs(n.x/s.x),u=Math.abs(n.y/s.y),o=(o=o<l?l:o)<u?u:o);var l=t.order[r],u=e.order[r];n instanceof Oe&&l instanceof Oe&&u instanceof Oe&&(u=xe(l.r,u.r,i),n.r=u,(r=a.order[r])instanceof Oe&&0!==r&&(r=Math.abs(n.r/r.r),o=o<r?r:o))})),o}function qe(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new pe(.25,.25),r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:2*Math.PI/6,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:new pe(1,1),a=(t=t instanceof Ee?[t]:t,e instanceof Ee?[e]:e);if(a.length!==t.length)return 0;var s=0;return t.forEach((function(t,e){e=a[e];for(var l=t._dup(),u=0;u<l.order.length;u+=1){var c=l.order[u];c instanceof _e?(c.x=i.x,c.y=i.y):c instanceof Oe?c.r=r:(c.x=o.x,c.y=o.y)}e=Ne(t,e,l,n),s<e&&(s=e)})),s}function He(t,e,n,i){var r=1/i;if(0===i||1===i||2===i)return[t,e,n];for(var o=[],a=0;a<i+1;a+=1){var s=0+a*r;o.push(new pe(Math.pow(1-s,2)*t.x+2*(1-s)*s*e.x+s*s*n.x,Math.pow(1-s,2)*t.y+2*(1-s)*s*e.y+s*s*n.y))}return o}var Ke=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"inside",i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:8;te(this,t),this.boundary=e,this.bounds=n,this.precision=i}return ne(t,[{key:"_dup",value:function(){return new t}},{key:"_state",value:function(t){return{f1Type:"bounds",state:[]}}},{key:"contains",value:function(t){return!0}},{key:"intersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return"number"==typeof t?{intersect:t,distance:0,reflection:e+Math.PI}:{intersect:ue(t),distance:0,reflection:e+Math.PI}}},{key:"clip",value:function(t){return"number"==typeof t?t:ue(t)}},{key:"isDefined",value:function(){return!1}}]),t}(),Ue=function(){Xt(e,Ke);var t=Qt(e);function e(n){te(this,e);var i=ct({},{bounds:"inside",precision:8,min:null,max:null},n);return n={min:i.min,max:i.max},t.call(this,n,i.bounds,i.precision)}return ne(e,[{key:"isDefined",value:function(){return null!=this.boundary.min||null!=this.boundary.max}},{key:"_dup",value:function(){return new e({bounds:this.bounds,precision:this.precision,min:this.boundary.min,max:this.boundary.max})}},{key:"_state",value:function(t){return t=se(t),{f1Type:"rangeBounds",state:[this.bounds,this.precision,null!=this.boundary.min?f(this.boundary.min,t):null,null!=this.boundary.max?f(this.boundary.max,t):null]}}},{key:"contains",value:function(t){return"number"!=typeof t?(t=ue(t),!(!this.contains(t.x)||!this.contains(t.y))):(t=f(t,this.precision),(null==this.boundary.min||t>=f(this.boundary.min,this.precision))&&(null==this.boundary.max||t<=f(this.boundary.max,this.precision)))}},{key:"intersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=-1*e,i=(r=this.boundary).min,r=r.max;return"number"!=typeof t?{intersect:null,distance:0,reflection:e}:this.contains(t)?null!=r&&d(t,this.precision)===d(r,this.precision)&&"outside"===this.bounds?-1===e?{intersect:r,distance:0,reflection:1}:{intersect:null,distance:0,reflection:1}:null!=i&&d(t,this.precision)===d(i,this.precision)&&"outside"===this.bounds?1===e?{intersect:i,distance:0,reflection:-1}:{intersect:null,distance:0,reflection:-1}:1===e?null==r?{intersect:null,distance:0,reflection:e}:{intersect:r,distance:Math.abs(t-r),reflection:-1}:null==i?{intersect:null,distance:0,reflection:e}:{intersect:i,distance:Math.abs(t-i),reflection:1}:null!=i&&t<i&&1===e?{intersect:i,distance:Math.abs(t-i),reflection:n}:null!=r&&r<t&&-1===e?{intersect:r,distance:Math.abs(t-r),reflection:n}:{intersect:null,distance:0,reflection:e}}},{key:"clip",value:function(t){if("number"==typeof t)return m(t,this.boundary.min,this.boundary.max);var e=ue(t);return(t=e._dup()).x=m(e.x,this.boundary.min,this.boundary.max),t.y=m(e.y,this.boundary.min,this.boundary.max),t}}]),e}(),Ve=function(){Xt(e,Ke);var t=Qt(e);function e(n){te(this,e);var i=ct({},{left:null,right:null,top:null,bottom:null,bounds:"inside",precision:8},n);return n={left:i.left,right:i.right,top:i.top,bottom:i.bottom},t.call(this,n,i.bounds,i.precision)}return ne(e,[{key:"isDefined",value:function(){return null!=this.boundary.left||null!=this.boundary.right||null!=this.boundary.top||null!=this.boundary.bottom}},{key:"_dup",value:function(){return new e({bounds:this.bounds,precision:this.precision,left:this.boundary.left,right:this.boundary.right,top:this.boundary.top,bottom:this.boundary.bottom})}},{key:"_state",value:function(t){return t=se(t),{f1Type:"rectBounds",state:[this.bounds,this.precision,null!=this.boundary.left?f(this.boundary.left,t):null,null!=this.boundary.bottom?f(this.boundary.bottom,t):null,null!=this.boundary.right?f(this.boundary.right,t):null,null!=this.boundary.top?f(this.boundary.top,t):null]}}},{key:"contains",value:function(t){return"number"!=typeof t&&(t=ue(t).round(this.precision),!(null!=this.boundary.left&&t.x<f(this.boundary.left,this.precision)||null!=this.boundary.right&&t.x>f(this.boundary.right,this.precision)||null!=this.boundary.bottom&&t.y<f(this.boundary.bottom,this.precision)||null!=this.boundary.top&&t.y>f(this.boundary.top,this.precision)))}},{key:"clip",value:function(t){return"number"==typeof t||(t=ue(t),null!=this.boundary.left&&t.x<this.boundary.left&&(t.x=this.boundary.left),null!=this.boundary.right&&t.x>this.boundary.right&&(t.x=this.boundary.right),null!=this.boundary.bottom&&t.y<this.boundary.bottom&&(t.y=this.boundary.bottom),null!=this.boundary.top&&t.y>this.boundary.top&&(t.y=this.boundary.top)),t}},{key:"intersect",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if("number"==typeof t)return{intersect:null,distance:0,reflection:n};var i,r=f(ae(n,"0to360"),this.precision),o=f(Math.PI,this.precision),a=f(3*Math.PI/2,this.precision),s=f(Math.PI/2,this.precision),l=ue(t),u=(v=this.boundary).top,c=v.bottom,h=v.left,p=v.right,m=function(t){if(null!=t){if(null!=c&&null!=u)return new Se([t,c],[t,u]);if(null==c&&null!=u)return new Se([t,u],null,-Math.PI/2,1);if(null!=c&&null==u)return new Se([t,c],null,Math.PI/2,1);if(null==c&&null==u)return new Se([t,0],null,Math.PI/2,0)}return null},y=(g=function(t){if(null!=t){if(null!=h&&null!=p)return new Se([h,t],[p,t]);if(null==h&&null!=p)return new Se([p,t],null,-Math.PI,1);if(null!=h&&null==p)return new Se([h,t],null,0,1);if(null==h&&null==p)return new Se([0,t],null,Math.PI,0)}return null})(c),v=(t=g(u),m(h)),g=m(p),b=new Se(l,null,n,1);if(y=(m=function(t,n){return null==t?null:t.hasPointOn(l,e.precision)?{intersect:l._dup(),distance:0,id:n}:(t=b.intersectsWith(t,e.precision)).withinLine&&null!=t.intersect?{intersect:t.intersect,distance:d(l.distance(t.intersect),e.precision),id:n}:null})(y,"bottom"),t=m(t,"top"),v=m(v,"left"),m=m(g,"right"),t=(g=function(t,n){var i=null;return null!=t&&null!=n?i=0===t.distance&&"inside"===e.bounds||!(0===n.distance&&"inside"===e.bounds||t.distance<n.distance)?n:t:null!=t?i=t:null!=n&&(i=n),i})(y,t),v=g(v,m),m=[],null!=t&&null!=v&&t.distance===v.distance?m=[t,v]:null!=(T=g(t,v))&&(m=[T]),0===m.length)return{intersect:null,distance:0,reflection:n};var w=0,x=1,S=1;m.forEach((function(t){"left"===t.id||"right"===t.id?x=-1:S=-1,i=t.intersect,w=t.distance})),v=Re(1,n),-1===x&&(v.x*=-1),-1===S&&(v.y*=-1),0===w&&(i=l);var T=Fe(v).angle;return v=!1,0===w&&"inside"===this.bounds&&1===m.length&&("bottom"!==m[0].id&&"top"!==m[0].id||null!=this.boundary.left&&null!=this.boundary.right||0!==r&&r!==o||(v=!0),"right"!==m[0].id&&"left"!==m[0].id||null!=this.boundary.top&&null!=this.boundary.bottom||r!==s&&r!==a||(v=!0),"right"===m[0].id&&null==this.boundary.left&&r===o&&(v=!0),"left"===m[0].id&&null==this.boundary.right&&0===r&&(v=!0),"top"===m[0].id&&null==this.boundary.bottom&&r===a&&(v=!0),"bottom"===m[0].id&&null==this.boundary.top&&r===s&&(v=!0)),0===w&&"inside"===this.bounds&&2===m.length&&("bottom"===m[0].id&&"left"===m[1].id&&null==this.boundary.right&&0===r&&(v=!0),"bottom"===m[0].id&&"left"===m[1].id&&null==this.boundary.top&&r===s&&(v=!0),"top"===m[0].id&&"left"===m[1].id&&null==this.boundary.right&&0===r&&(v=!0),"top"===m[0].id&&"left"===m[1].id&&null==this.boundary.bottom&&r===a&&(v=!0),"top"===m[0].id&&"right"===m[1].id&&null==this.boundary.left&&r===o&&(v=!0),"top"===m[0].id&&"right"===m[1].id&&null==this.boundary.bottom&&r===a&&(v=!0),"bottom"===m[0].id&&"right"===m[1].id&&null==this.boundary.left&&r===o&&(v=!0),"bottom"===m[0].id&&"right"===m[1].id&&null==this.boundary.top&&r===s&&(v=!0)),0===w&&"outside"===this.bounds&&2===m.length&&("bottom"===m[0].id&&"left"===m[1].id&&(s<=r||0===r)&&(v=!0),"top"===m[0].id&&"left"===m[1].id&&0<=r&&r<=a&&(v=!0),"top"===m[0].id&&"right"===m[1].id&&(r<=o||a<=r)&&(v=!0),"bottom"===m[0].id&&"right"===m[1].id&&(r<=s||o<=r)&&(v=!0)),0===w&&"outside"===this.bounds&&1===m.length&&("left"===(m=ie(m,1)[0]).id&&s<=r&&r<=a&&(v=!0),"right"===m.id&&(r<=s||a<=r)&&(v=!0),"bottom"===m.id&&(o<=r||0===r)&&(v=!0),"top"===m.id&&r<=o&&(v=!0)),v&&(i=null,T=n),{intersect:i,distance:w,reflection:T}}}]),e}(),Ge=function(){Xt(e,Ke);var t=Qt(e);function e(n){var i;return te(this,e),null!=(n=ct({},{angle:0,mag:1,bounds:"inside",precision:8,ends:2},n)).line?i=ke(n.line):null!=n.p1&&null!=n.p2?i=new Se(n.p1,n.p2,0,n.ends):null!=n.p1&&(i=new Se(n.p1,n.mag,n.angle,n.ends)),t.call(this,i,n.bounds,n.precision)}return ne(e,[{key:"isDefined",value:function(){return!0}},{key:"_dup",value:function(){return new e({bounds:this.bounds,precision:this.precision,p1:this.boundary.p1._dup(),p2:this.boundary.p2._dup(),mag:this.boundary.distance,angle:this.boundary.ang,ends:this.boundary.ends})}},{key:"_state",value:function(t){return t=se(t),{f1Type:"lineBounds",state:[this.bounds,this.precision,f(this.boundary.p1.x,t),f(this.boundary.p1.y,t),f(this.boundary.p2.x,t),f(this.boundary.p2.y,t),this.boundary.ends]}}},{key:"contains",value:function(t){return"number"!=typeof t&&ue(t).isWithinLine(this.boundary,this.precision)}},{key:"clip",value:function(t){return"number"==typeof t?t:ue(t).clipToLine(this.boundary,this.precision)}},{key:"intersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if("number"==typeof t||0===this.boundary.ends)return{intersect:null,distance:0,reflection:e};var n=ue(t);if(!this.boundary.hasPointAlong(n,this.precision))return{intersect:null,distance:0,reflection:e};var i=!1;this.boundary.hasPointOn(n,this.precision)&&(i=!0);var r,o,a=this.boundary,s=this.boundary.p1._dup(),l=this.boundary.p2._dup(),u=d(Math.abs(ae(e,"0to360")-ae(a.ang,"0to360")),this.precision),c=n.distance(s);if(t=n.distance(l),n.isEqualTo(s,this.precision)){if("inside"===this.bounds&&0!==u)return{intersect:s,distance:0,reflection:a.ang};if("outside"===this.bounds&&0!==u)return{intersect:null,distance:0,reflection:e};if("outside"===this.bounds&&0===u)return{intersect:s,distance:0,reflection:a.ang+Math.PI}}if(1===a.ends)return!0===i&&0===u||!1===i&&0!==u?{intersect:null,distance:0,reflection:e}:{intersect:s,distance:c,reflection:e+Math.PI};if(n.isEqualTo(l,this.precision)){if("inside"===this.bounds&&0===u)return{intersect:l,distance:0,reflection:a.ang+Math.PI};if("outside"===this.bounds&&0===u)return{intersect:null,distance:0,reflection:e};if("outside"===this.bounds&&0!==u)return{intersect:l,distance:0,reflection:a.ang}}if(i&&0===u)return{intersect:l,distance:t,reflection:e+Math.PI};if(i)return{intersect:s,distance:c,reflection:e+Math.PI};if(c<t&&0===u)r=s,o=c;else{if(!(t<c&&0!==u))return{intersect:null,distance:0,reflection:e};r=l,o=t}return{intersect:r,distance:o,reflection:e+Math.PI}}},{key:"clipVelocity",value:function(t){if("number"==typeof t)return t;if(null==this.boundary)return t;var e=ue(t);return t=new Te(this.boundary).unit().dotProduct(new Te([0,0],e)),e=this.boundary.ang,t<-1&&(e+=Math.PI,t=-t),Re(t,e)}}]),e}();function Ye(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new Ee;if(null==t)return new Ke;if(t instanceof Ke)return t;if(null!=t.type)return Ye(t.bounds,t.type);if("rect"===e)return new Ve(t);if("range"===e)return new Ue(t);if("line"===e)return new Ge(t);if("transform"===e)return new $e(n,t);if(void 0!==t.min||void 0!==t.max)return Ye(t,"range");if(t instanceof fe)return new Ve(t);if(t instanceof Se)return new Ge({line:t});if(void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom)return Ye(t,"rect");if(void 0!==t.line||void 0!==t.p1||void 0!==t.p2||void 0!==t.angle||void 0!==t.mag||void 0!==t.ends)return Ye(t,"line");if(void 0!==t.translation||void 0!==t.scale||void 0!==t.rotation)return Ye(t,"transform",n);if(void 0!==t.f1Type&&null!=t.state){var i=t.f1Type,r=t.state;if(null!=i&&"rangeBounds"===i&&null!=r&&Array.isArray([r])&&4===r.length){e=(o=ie(r,4))[0],n=o[1],t=o[2];var o=o[3];return new Ue({bounds:e,precision:n,min:t,max:o})}if(null!=i&&"rectBounds"===i&&null!=r&&Array.isArray([r])&&6===r.length){var a=(h=ie(r,6))[0],s=h[1],l=h[2],u=h[3],c=h[4],h=h[5];return new Ve({bounds:a,precision:s,left:l,bottom:u,right:c,top:h})}if(null!=i&&"lineBounds"===i&&null!=r&&Array.isArray([r])&&7===r.length){a=(f=ie(r,7))[0],s=f[1],l=f[2],u=f[3],c=f[4],h=f[5];var f=f[6];return new Ge({bounds:a,precision:s,p1:new pe(l,u),p2:new pe(c,h),ends:f})}if(null!=i&&"transformBounds"===i&&null!=r&&Array.isArray([r])&&3===r.length){i=(f=ie(r,3))[0],r=f[1],f=f[2],(i=new $e(new Ee,{},i)).order=r.slice();var d=[];return f.forEach((function(t){null==t?d.push(null):d.push(Ye(t))})),i.boundary=d,i}}return null}function Xe(t,e){if(Array.isArray(t))return t;var n=[];if("number"==typeof t){for(var i=0;i<e.order.length;i+=1)n.push(t);return n}for(var r=0;r<e.order.length;r+=1){var o,a=e.order[r];a instanceof _e?(o=0,null!=t.position&&(o=t.position),null!=t.translation&&(o=t.translation),n.push(o)):a instanceof Pe?(o=0,null!=t.scale&&(o=t.scale),n.push(o)):a instanceof Oe&&(a=0,null!=t.rotation&&(a=t.rotation),n.push(a))}return n}var $e=function(){Xt(e,Ke);var t=Qt(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:8;te(this,e);for(var o=[],a=0;a<n.order.length;a+=1){var s=n.order[a];s instanceof _e?o.push("t"):s instanceof Pe?o.push("s"):o.push("r")}return(r=t.call(this,[],"inside",r)).order=o,r.createBounds(i),r}return ne(e,[{key:"isUnbounded",value:function(){for(var t=0;t<this.boundary.length;t+=1)if(null!==this.boundary[t])return!1;return!0}},{key:"_dup",value:function(){var t=new e(new Ee,{},this.precision);return t.order=this.order.slice(),t.boundary=[],this.boundary.forEach((function(e){null==e?t.boundary.push(null):t.boundary.push(e._dup())})),t}},{key:"_state",value:function(t){var e=se(t),n=[];return this.boundary.forEach((function(t){null==t?n.push(null):n.push(t._state({precision:e}))})),{f1Type:"transformBounds",state:[this.precision,this.order.slice(),n]}}},{key:"createBounds",value:function(t){var e;null==t||t instanceof Ke?this.boundary[1<arguments.length&&void 0!==arguments[1]?arguments[1]:0]=t:Array.isArray(t)?this.boundary=t:(e=[],this.order.forEach((function(n){var i=null;"t"===n&&null!=t.position&&(i=Ye(t.position)),"t"===n&&null!=t.translation&&(i=Ye(t.translation)),"r"===n&&null!=t.rotation&&(i=Ye(t.rotation)),"s"===n&&null!=t.scale&&(i=Ye(t.scale)),e.push(i)})),this.boundary=e)}},{key:"update",value:function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=0,r=0;r<this.order.length;r+=1)this.order[r]===t&&(null!=n&&n!==i||(this.boundary[r]=Ye(e)),i+=1)}},{key:"updateTranslation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;(t=Ye(t))instanceof Ue&&(t=new Ve({left:t.boundary.min,bottom:t.boundary.min,top:t.boundary.max,right:t.boundary.max})),this.update("t",t,e)}},{key:"updateRotation",value:function(t){this.update("r",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"updateScale",value:function(t){this.update("s",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"getBound",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=0,i=0;i<this.order.length;i+=1)if(this.order[i]===t){if(n===e)return this.boundary[i];n+=1}return null}},{key:"getTranslation",value:function(){return this.getBound("t",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)}},{key:"getScale",value:function(){return this.getBound("s",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)}},{key:"getRotation",value:function(){return this.getBound("r",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)}},{key:"contains",value:function(t){for(var e=0;e<t.order.length;e+=1){var n=t.order[e],i=this.boundary[e];if(n instanceof Oe){if(null!=i&&!i.contains(n.r))return!1}else if(null!=i&&!i.contains(new pe(n.x,n.y)))return!1}return!0}},{key:"clip",value:function(t){for(var e=[],n=0;n<t.order.length;n+=1){var i,r=t.order[n],o=this.boundary[n];null!=o?(i=r instanceof Oe?o.clip(r.r):o.clip(new pe(r.x,r.y)),o=void 0,o=r instanceof _e?new _e(i.x,i.y,r.name):r instanceof Pe?new Pe(i.x,i.y,r.name):new Oe(i,r.name),e.push(o)):e.push(r._dup())}return new Ee(e,t.name)}}]),e}();function Qe(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,o=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,a=7<arguments.length&&void 0!==arguments[7]?arguments[7]:8,s=(f=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null)instanceof Ue?new Ve({left:f.boundary.min,right:f.boundary.max,bottom:f.boundary.min,top:f.boundary.max}):f;if(0===d(n,a)&&(0===r||null==s||!s.isDefined())&&null==i)return{velocity:e,position:t,duration:null};var l=e,u=!1;null==i&&(u=!0);var c=(l=null!=s&&null!=s.clipVelocity?s.clipVelocity(e):l).toPolar(),h=c.mag,f=c.angle;if(h<=o)return{velocity:new pe(0,0),position:t,duration:0};if(e=t._dup(),null!=s&&(e=s.clip(t)),l=h,c=Math.abs(l)-o,t=i,h=Math.max(n,1e-7),c=Re(n=l*(t=null==t||t>Math.abs(c/h)?Math.abs(c/h):t)-.5*h*Math.pow(t,2),f).add(e),null==s||s.contains(c))return u?{duration:t,position:c,velocity:new pe(0,0)}:{position:c,velocity:Re(m=d(m=l-h*t,a)<=d(o,a)?0:m,f),duration:t};var p,m=1-r;if(null!=(e=s.intersect(e,ae(f,"0to360"))).distance&&e.distance>n)throw new Error("Error in calculating intersect");if("number"==typeof e.intersect)p=new pe(e.intersect,0);else{if(null==e.intersect)return{position:c,velocity:new pe(0,0),duration:t};p=e.intersect}return f=e.distance,n=e.reflection,e=.5*(c=-l/Math.abs(l)*h),f=-f,e=(-l+Math.sqrt(Math.pow(l,2)-4*e*f))/(2*e),1===r?{velocity:new pe(0,0),position:p,duration:e}:(n=new pe((m*=l+c*e)*Math.cos(n),m*Math.sin(n)),u?null==(i=Qe(p,n,h,i,s,r,o,a)).duration?{duration:null,position:i.position,velocity:new pe(0,0)}:{duration:e+i.duration,position:i.position,velocity:new pe(0,0)}:Qe(p,n,h,t-e,s,r,o,a))}function Je(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:8,l=r;return 0!==d(n,s)||0!==o&&null!=r&&(null==r||r.isDefined())||null!=i?(null!=r&&(l=new Ge({p1:[null!=r.boundary.min?r.boundary.min:0,0],p2:[null!=r.boundary.max?r.boundary.max:0,0]})),{duration:(s=Qe(new pe(t,0),new pe(e,0),n,i,l,o,a,s)).duration,value:s.position.x,velocity:s.velocity.x}):{velocity:e,value:t,duration:null}}function Ze(t,e,n,i,r,o,a){for(var s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:8,l=0,u=[],c=[],h=r instanceof $e?r:new $e(t,r),f=0;f<t.order.length;f+=1){var d=void 0,p=void 0,m=(m=t.order[f])instanceof _e?(d=Qe(m,e.order[f],n[f],i,h.boundary[f],o[f],a[f],s),p=new _e(d.position.x,d.position.y),new _e(d.velocity.x,d.velocity.y)):m instanceof Pe?(d=function(t,e,n,i,r,o,a,s){var l=3<arguments.length&&void 0!==i?i:null,u=4<arguments.length&&void 0!==r?r:null;return i=5<arguments.length&&void 0!==o?o:0,r=6<arguments.length&&void 0!==a?a:0,o=7<arguments.length&&void 0!==s?s:8,a=null,s=null,null!=u&&(a=new Ue({min:u.boundary.left,max:u.boundary.right}),s=new Ue({min:u.boundary.bottom,max:u.boundary.top})),a=Je(t.x,e.x,n,l,a,i,r,o),o=Je(t.y,e.y,n,l,s,i,r,o),null==a.duration||null==o.duration?{duration:null,point:new pe(a.value,o.value),velocity:new pe(a.velocity,o.velocity)}:{duration:Math.max(a.duration,o.duration),point:new pe(a.value,o.value),velocity:new pe(a.velocity,o.velocity)}}(m,e.order[f],n[f],i,h.boundary[f],o[f],a[f],s),p=new Pe(d.point.x,d.point.y),new Pe(d.velocity.x,d.velocity.y)):(d=Je(m.r,e.order[f].r,n[f],i,h.boundary[f],o[f],a[f],s),p=new Oe(d.value),new Oe(d.velocity));null===i&&(null==d.duration||d.duration>l)&&(l=d.duration),c.push(m),u.push(p)}return null!=i&&(l=i),{transform:new Ee(u,t.name),velocity:new Ee(c,t.name),duration:l}}function tn(t,e,n){var i=ue(t);return t=ue(e),e=ue(n),n=(i.x+t.x+e.x)/3,e=(i.y+t.y+e.y)/3,new pe(n,e)}function en(t){if(Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1])return!0;if(t instanceof pe)return!0;if(null!=t.f1Type&&"p"===t.f1Type)return!0;if("string"!=typeof t||"["!==t.charAt(0))return!1;var e;try{e=JSON.parse(t)}catch(t){return!1}return en(e)}function nn(t){return"string"==typeof t||"number"==typeof t?t:en(t[0])?[t.map(ue)]:t.map((function(t){return t.map(ue)}))}function rn(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=de(t);return t=new pe(i.left,i.bottom),"center"===e?t.x+=i.width/2:"right"===e?t.x=i.right:"number"==typeof e?t.x+=i.width*e:e.startsWith("o")&&(t.x+=parseFloat(e.slice(1))),"middle"===n?t.y+=i.height/2:"top"===n?t.y=i.top:"number"==typeof n?t.y+=i.height*n:n.startsWith("o")&&(t.y+=parseFloat(n.slice(1))),t}function on(t){return function(t){if(Array.isArray(t))return an(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return an(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?an(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function an(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function sn(t,e,n,i,r,o){var a=new Se(e,t),s=new Se(e,n),l="fromVertex"===r?(l=o,Math.min(l,a.length()/2*.99,s.length()/2*.99)):"radius"===r?(n=Math.abs(ze(t,e,n))/2,l=o/Math.tan(n),Math.min(l,a.length()/2*.99,s.length()/2*.99)):Math.min(a.length(),s.length());return function(t,e,n,i){if(i<1)return[t._dup(),e._dup(),n._dup()];if(1===i)return[t._dup(),n._dup()];var r=t._dup(),o=n._dup(),a=[];if((f=ze(r,e,o))===Math.PI){a.push(t._dup());for(var s=0;s<i-2;s+=1)a.push(e._dup());return a.push(n._dup()),a}var l=!1;0===f&&(l=!0,f=1e-5);var u=f/Math.abs(f),c=new Se(e,r),h=Math.abs(f/2),f=(t=Math.PI/2,n=Math.PI-h-t,c.length()),d=(f=Math.sin(t)/Math.sin(n)*f,new pe(e.x+f*Math.cos(h*u+c.angle()),e.y+f*Math.sin(h*u+c.angle()))),p=2*n/i*u*-1,m=(u=new Se(d,r)).angle(),y=u.length();if(a.push(r),l)for(var v=c.angle()+Math.PI/2,g=Math.PI/i,b=0;b<=i;b+=1)a.push(new pe(d.x+1e-4*Math.cos(v+g*b),d.y+1e-4*Math.sin(v+g*b)));else for(var w=0;w<i-1;w+=1){var x=m+(w+1)*p;a.push(new pe(d.x+y*Math.cos(x),d.y+y*Math.sin(x)))}return a.push(o),a}(a.pointAtPercent(l/a.length()),e,s.pointAtPercent(l/s.length()),i)}function ln(t,e,n,i,r){var o=4<arguments.length&&void 0!==r&&r,a=new Se(e,t),s=new Se(e,n),l=a.pointAtPercent(i/a.length());return r=s.pointAtPercent(i/s.length()),!1===o&&(i>a.length()&&(l=t._dup()),i>s.length()&&(r=n._dup())),[l,e._dup(),r]}function un(t){return function(t){if(Array.isArray(t))return fn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||hn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function cn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||hn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function hn(t,e){if(t){if("string"==typeof t)return fn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fn(t,e):void 0}}function fn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function dn(t,e,n){for(var i=2<arguments.length&&void 0!==n?n:8,r=e>t.sum?f(e%t.sum,i):e,o=0;o<t.definition.length;o+=1){if(r<t.cum[o])return[o,f(t.cum[o]-r,i)];if(r===t.cum[o])return o+1<t.definition.length?[o+1,f(t.cum[o+1]-r,i)]:[0,f(t.cum[0],i)]}return[0,0]}function pn(t){var e=t.radius,n=t.rotation,i=t.offset,r=t.sides,o=t.sidesToDraw,a=t.direction,s=t.innerRadius,l=2*Math.PI/r,u=1;null!=s&&(l/=2,u=2);var c=[];if(0===o)return[];for(var h=0;h<o*u;h+=u)c.push(new pe(e*Math.cos(l*h*a+n)+i.x,e*Math.sin(l*h*a+n)+i.y)),null!=s&&c.push(new pe(s*Math.cos(l*(h+1)*a+n)+i.x,s*Math.sin(l*(h+1)*a+n)+i.y));return o<r&&c.push(new pe(e*Math.cos(l*o*u*a+n)+i.x,e*Math.sin(l*o*u*a+n)+i.y)),c}function mn(t,e,n,i){for(var r=[],o=1;o<e.length;o+=1)r.push(t._dup()),r.push(e[o]._dup()),r.push(e[o-1]._dup());return n===i&&(r.push(t._dup()),r.push(e[0]._dup()),r.push(e[e.length-1]._dup())),r}function yn(t){return function(t){if(Array.isArray(t))return bn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||gn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||gn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gn(t,e){if(t){if("string"==typeof t)return bn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bn(t,e):void 0}}function bn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function wn(t,e,n){return[new pe(-t-n,-e/2-n),new pe(n,-e/2-n),new pe(n,e/2+n),new pe(-t-n,e/2+n)]}function xn(t){return t.map((function(t){return t._dup()}))}function Sn(t){var e=new Se([-t.length,t.tailWidth/2],1,0),n=new Se([-t.length,0],[0,t.width/2]),i=e.intersectsWith(n).intersect||new pe(-t.length,t.tailWidth/2),r=0;"number"==typeof t.tail&&(r=t.tail),r=Math.max(i.x,r);var o=-t.length;return 0<r&&(o=-(t.length-r),n=new Se([o,0],[0,t.width/2]),i=e.intersectsWith(n).intersect||new pe(-t.length+r,t.tailWidth/2)),n=-t.length,[i,o,n=r<0?-t.length-r>=i.x?i.x:-t.length-r:n]}function Tn(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(-t.barb,e);var n=-t.length;0<e&&(n=-(t.length-e));var i=-t.length;e<0&&(i=-e<t.barb?-t.length-e:n+t.barb),!1===t.tail&&(i=n+t.barb);var r=new Se([i,t.tailWidth/2],1,0);return e=new Se([n+t.barb,0],[n,t.width/2]),e=(r=r.intersectsWith(e)).intersect||new pe(i,t.tailWidth/2),[e=!1===r.withinLine?new pe(n+t.barb,t.tailWidth/2):e,n,i]}function An(t){var e=0;"number"==typeof t.tail&&(e=t.tail);var n=Math.atan(t.width/2/t.length),i=Math.PI-n-Math.PI/2,r=t.tailWidth*Math.cos(i),o=-t.length,a=-t.length;0<e&&(o=-(t.length-e));var s=new Se([o+r,t.width/2],[0,0]),l=s.offset("bottom",t.tailWidth),u=new Se([o,t.tailWidth/2],1,0);return n=s.intersectsWith(u).intersect||new pe(o,t.tailWidth/2),(i=l.intersectsWith(u).intersect||new pe(o,t.tailWidth/2)).x<-t.length&&(i=new pe(-t.length,t.tailWidth/2)),u=(r=l.intersectsWith(new Se([-t.length,0],1,0)))?r.intersect.x:-t.length,r.isWithinLine&&!1!==t.tail||(a=-t.length),r=!1,e<0&&(-t.length-e>i.x?(a=i.x,r=!0):a=-t.length-e),!1===t.tail&&(a=u),[new pe(n.x,t.tailWidth/2),o,a,u,s.p1,l.p1,r,i]}function kn(t){var e,n,i,r,o=t.head,a=t.length;return"circle"===o||"polygon"===o?(n=0,"number"==typeof(e=t).tail&&(n=Math.max(0,e.tail)),"mid"===e.align?(e.tail,[e.radius,e.radius,2*e.radius+n]):"boolean"==typeof e.tail?[2*e.radius,2*e.radius,2*e.radius]:[n=2*e.radius+n,n,n]):"line"===o?(n=vn(An(e=t),3)[2],[e.length,-n,e.length]):"reverseTriangle"===o?(i=vn(Sn(r=t),3)[2],[r.length,-i,r.length]):"triangle"===o?[t.length,t.length,t.length]:"barb"===o?(r=vn(Tn(i=t),3)[2],[i.length,-r,i.length]):"rectangle"===o||"bar"===o?"mid"===t.align?[t.length/2,t.length/2,t.length]:[t.length,t.length,t.length]:[a,a,a]}function On(t){var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x=ct({},t);null!=x.drawPosition&&(x.drawPosition=ue(x.drawPosition)),0<x.tailWidth&&x.width<x.tailWidth&&(x.width=.001*x.tailWidth);var S,T,A,k="barb"===x.head?(u=(S=x).length,f=S.drawBorderBuffer,e=S.tailWidth,c=S.barb,n=S.width,t=S.tail,T=(i=vn(Tn(S),3))[0],S=i[1],i=i[2],T=!1===t||T.x>=S+c?[new pe(-u+c,0),new pe(-u,-n/2),new pe(0,0),new pe(-u,n/2)]:[new pe(i,-e/2),new pe(T.x,-e/2),new pe(S,-n/2),new pe(0,0),new pe(S,n/2),new pe(T.x,e/2),new pe(i,e/2)],i=[new pe(i,e/2),new pe(i,-e/2)],S=(c=vn([e=T,e=0<f?wn(u,n,f):e,i],3))[0],T=c[1],c[2]):"rectangle"===x.head||"bar"===x.head?(S=(w=vn((m=(p=x).length,y=p.drawBorderBuffer,v=p.tailWidth,g=p.width,b=p.tail,t=(w=vn(function(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=-t.length;return 0<e&&(n=-(t.length-e)),e=-t.length,[new pe(e,t.tailWidth/2),n,e]}(p),3))[0],p=w[1],w=w[2],p=!1===b||t.x>=p?[new pe(-m,-g/2),new pe(0,-g/2),new pe(0,g/2),new pe(-m,g/2)]:[new pe(w,-v/2),new pe(p,-v/2),new pe(p,-g/2),new pe(0,-g/2),new pe(0,g/2),new pe(p,g/2),new pe(p,v/2),new pe(w,v/2)],w=[new pe(w,v/2),new pe(w,-v/2)],[v=p,v=0<y?wn(m,g,y):v,w]),3))[0],T=w[1],w[2]):"line"===x.head?(r=(u=x).length,a=u.drawBorderBuffer,l=u.tailWidth,o=u.width,n=u.tail,e=(f=vn(An(u),8))[0],s=f[2],i=f[3],c=f[4],w=f[5],u=f[6],f=f[7],w=!1===n||e.x<=s?[new pe(c.x,-c.y),new pe(0,0),new pe(c.x,c.y),new pe(w.x,w.y),new pe(i,0),new pe(w.x,-w.y)]:u?[new pe(c.x,-c.y),new pe(0,0),new pe(c.x,c.y),new pe(w.x,w.y),new pe(f.x,f.y),new pe(f.x,-f.y),new pe(w.x,-w.y)]:[new pe(c.x,-c.y),new pe(0,0),new pe(c.x,c.y),new pe(w.x,w.y),new pe(f.x,f.y),new pe(s,l/2),new pe(s,-l/2),new pe(f.x,-f.y),new pe(w.x,-w.y)],s=[new pe(s,l/2),new pe(s,-l/2)],S=(r=vn([l=w,l=0<a?wn(r,o,a):l,s],3))[0],T=r[1],r[2]):"polygon"===x.head||"circle"===x.head?(S=(h=vn((c=(u=x).drawBorderBuffer,h=u.tailWidth,f=u.radius,d=u.tail,w=function(t){if(!1===t.tail)return pn({radius:t.radius,sides:t.sides,sidesToDraw:t.sides,rotation:0,offset:new pe(-t.radius,0),direction:1});var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=Math.PI-Math.asin(t.tailWidth/2/t.radius),i=Math.PI+Math.asin(t.tailWidth/2/t.radius),r=2*Math.PI/t.sides,o=Math.floor(n/r),a=Math.floor(i/r),s=pn({radius:t.radius,sides:t.sides,sidesToDraw:t.sides,rotation:0,offset:new pe(-t.radius,0),direction:1}),l=new Se(s[o],s[o+1]);return n=new Se(s[a],s[a+1]),i=new Se([-t.radius,t.tailWidth/2],1,0),r=new Se([-t.radius,-t.tailWidth/2],1,0),l=i.intersectsWith(l).intersect||new pe(-t.radius,t.tailWidth/2),n=r.intersectsWith(n).intersect||new pe(-t.radius,-t.tailWidth/2),[l,new pe(2*-t.radius-e,t.tailWidth/2),new pe(2*-t.radius-e,-t.tailWidth/2),n].concat(yn(s.slice(a+1)),yn(s.slice(0,o+1)))}(u),u=0,d=!1===d?[new pe(2*-f,h/2),new pe(2*-f,-h/2)]:("number"==typeof d&&(u=Math.max(d,0)),[new pe(2*-f-u,h/2),new pe(2*-f-u,-h/2)]),[h=w,h=0<c?wn(2*f+u,2*f,c):h,d]),3))[0],T=h[1],h[2]):"reverseTriangle"===x.head?(a=(o=x).length,l=o.drawBorderBuffer,_=o.tailWidth,s=o.width,r=o.tail,h=(k=vn(Sn(o),3))[0],o=k[1],k=k[2],h=!1===r||k>=h.x?[new pe(0,-s/2),new pe(0,s/2),new pe(-a,0)]:o<k?(r=new Se([k,-_/2],[k,0]),o=new Se([-a,0],[0,s/2]),o=r.intersectsWith(o).intersect||new pe(k,-_/2),[new pe(0,-s/2),new pe(0,s/2),new pe(h.x,_/2),new pe(k,_/2),new pe(o.x,o.y),new pe(-a,0),new pe(o.x,-o.y),new pe(k,-_/2),new pe(h.x,-_/2)]):[new pe(0,-s/2),new pe(0,s/2),new pe(h.x,_/2),new pe(-a,_/2),new pe(-a,-_/2),new pe(h.x,-_/2)],k=[new pe(k,_/2),new pe(k,-_/2)],S=(_=vn([_=h,_=0<l?wn(a,s,l):_,k],3))[0],T=_[1],_[2]):(S=(O=vn((r=(d=x).length,o=d.drawBorderBuffer,h=d.tailWidth,a=d.width,s=d.tail,l=(O=vn(function(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=-t.length;return 0<e&&(n=-(t.length-e)),e=-t.length,[new pe(e,t.tailWidth/2),n,e]}(d),3))[0],d=O[1],O=O[2],d=!1===s||l.x>=d?[new pe(-r,-a/2),new pe(0,0),new pe(-r,a/2)]:[new pe(O,-h/2),new pe(d,-h/2),new pe(d,-a/2),new pe(0,0),new pe(d,a/2),new pe(d,h/2),new pe(O,h/2)],O=[new pe(O,h/2),new pe(O,-h/2)],[h=d,h=0<o?wn(r,a,o):h,O]),3))[0],T=O[1],O[2]),O=(_=vn(kn(x),3))[1],_=_[2];return[(k=vn((A=("start"===x.align?(new Ee).translate(_,0):"tip"===x.align?new Ee:"mid"===x.align?(new Ee).translate(_/2,0):(new Ee).translate(O,0)).rotate(x.angle).translate(x.drawPosition).matrix(),[S.map((function(t){return t.transformBy(A)})),T.map((function(t){return t.transformBy(A)})),k.map((function(t){return t.transformBy(A)}))]),3))[0],[k[1]],k[2]]}function _n(t,e){return"triangle"===e.head?3===(n=t).length?xn(n):xn([n[4],n[2],n[3],n[6],n[0],n[1],n[6],n[1],n[5]]):"reverseTriangle"===e.head?3===(n=t).length?xn(n):9===n.length?xn([n[0],n[1],n[2],n[0],n[2],n[8],n[8],n[2],n[3],n[8],n[3],n[7],n[6],n[4],n[5]]):xn([n[0],n[1],n[2],n[0],n[2],n[5],n[2],n[3],n[4],n[5],n[2],n[4]]):"barb"===e.head?4===(i=t).length?xn([i[0],i[1],i[2],i[0],i[2],i[3]]):xn([i[0],i[1],i[5],i[0],i[5],i[6],i[2],i[3],i[1],i[5],i[1],i[3],i[5],i[3],i[4]]):"rectangle"===e.head||"bar"===e.head?4===(i=t).length?xn([i[0],i[1],i[2],i[0],i[2],i[3]]):xn([i[0],i[1],i[6],i[0],i[6],i[7],i[2],i[3],i[4],i[2],i[4],i[5]]):"polygon"===e.head||"circle"===e.head?function(t){for(var e=[],n=1;n<t.length;n+=1)e.push(t[0]),e.push(t[n-1]),e.push(t[n]);return e}(t):6===t.length?xn([t[0]._dup(),t[1]._dup(),t[5]._dup(),t[5]._dup(),t[1]._dup(),t[4]._dup(),t[4]._dup(),t[1]._dup(),t[3]._dup(),t[3]._dup(),t[1]._dup(),t[2]._dup()]):7===t.length?xn([t[3]._dup(),t[1]._dup(),t[2]._dup(),t[3]._dup(),t[4]._dup(),t[1]._dup(),t[0]._dup(),t[1]._dup(),t[6]._dup(),t[6]._dup(),t[1]._dup(),t[5]._dup(),t[5]._dup(),t[1]._dup(),t[4]._dup()]):xn([t[0]._dup(),t[1]._dup(),t[8]._dup(),t[8]._dup(),t[1]._dup(),t[7]._dup(),t[7]._dup(),t[1]._dup(),t[4]._dup(),t[4]._dup(),t[1]._dup(),t[2]._dup(),t[3]._dup(),t[4]._dup(),t[2]._dup(),t[5]._dup(),t[7]._dup(),t[4]._dup(),t[6]._dup(),t[7]._dup(),t[5]._dup()]);var n,i}function Pn(t){var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y={align:"tip",tail:!1,angle:0,drawPosition:new pe(0,0),scale:1};return"triangle"===t.head||null==t.head?ct({},y,t,(n=(e=t).length,i=e.width,r=e.tailWidth,e=null==(e=e.scale)?1:e,{width:i=null==i?null!=r?6*r*e:null!=n?n:1:i,length:n=null==n?i:n,tailWidth:r=null==r?i/6/e:r}),{head:"triangle"}):"polygon"===t.head||"circle"===t.head?ct({},y,t,(r=(s=t).radius,a=s.tailWidth,o=null==(o=s.scale)?1:o,{radius:r=null==r?null!=a?3*a*o:1:r,tailWidth:a=null==a?r/3/o:a,sides:s=null==(s=s.sides)?30:s})):"barb"===t.head?ct({},y,t,(a=(o=t).length,s=o.width,u=o.tailWidth,l=o.barb,o=null==(o=o.scale)?1:o,null==s&&(s=null!=u?6*u*o:null!=a?a:null!=l?6*l*o:1),null==u&&(u=s/6/o),{width:s,length:a=null==a?s:a,barb:l=null==l?u*o:l,tailWidth:u})):"reverseTriangle"===t.head?ct({},y,t,(l=(c=t).length,u=c.width,h=c.tailWidth,c=null==(c=c.scale)?1:c,{width:u=null==u?null!=h?6*h*c:null!=l?l:1:u,length:l=null==l?u:l,tailWidth:h=null==h?u/6/c:h})):"bar"===t.head?ct({},y,t,(c=(f=t).length,h=f.width,d=f.tailWidth,f=null==(f=f.scale)?1:f,{width:h=null==h?null!=d?6*d*f:null!=c?6*c:1:h,length:c=null==c?h/6:c,tailWidth:d=null==d?h/6/f:d})):"line"===t.head?ct({},y,t,(f=(p=t).length,d=p.width,m=p.tailWidth,p=null==(p=p.scale)?1:p,{width:d=null==d?null!=m?6*m*p:null!=f?f:1:d,length:f=null==f?d:f,tailWidth:m=null==m?d/6/p:m})):ct({},y,t,(m=(p=t).length,y=p.width,t=p.tailWidth,p=null==(p=p.scale)?1:p,{width:y=null==y?null!=t?6*t*p:null!=m?m:1:y,length:m=null==m?y:m,tailWidth:t=null==t?y/6/p:t}))}function En(t,e,n){var i=2<arguments.length&&void 0!==n&&n;if(null!=t){var r="string"==typeof t?{start:t,end:t}:t,o=ut({except:["end","start"]},{},r),a={};return(t=function(t){var n;"string"==typeof r[t]&&(r[t]={head:r[t]}),0<Object.keys(o).length&&(null==r[t]?r[t]=ct({},o):r[t]=ct({},o,r[t])),(null!=r[t]||null==r.start&&null==r.end)&&(n={},null!=e&&(n.tailWidth=e),i&&(n.tail=!0),n=ut({except:["end","start"]},n,r[t]),a[t]=ct(Pn(n),n),a[t].drawPosition=ue(a[t].drawPosition))})("start"),t("end"),0<Object.keys(a).length?a:void 0}}function Mn(t){return function(t){if(Array.isArray(t))return jn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Cn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Bn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Cn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Cn(t,e){if(t){if("string"==typeof t)return jn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jn(t,e):void 0}}function jn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Rn(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"line",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[[]],r=4<arguments.length?arguments[4]:void 0,o=5<arguments.length?arguments[5]:void 0,a=[],s=[[]],l=[],u=[];t.forEach((function(n,c){var h,f=n[0],d=n.slice(-1)[0];if(e)for(var p=0;p<n.length;p+=1)a.push(n[p].p1._dup()),a.push(n[p].p2._dup());else a.push(d.p1._dup()),a.push(d.p2._dup()),a.push(f.p1._dup()),a.push(f.p1._dup()),a.push(d.p2._dup()),a.push(f.p2._dup());0!==c&&!l[l.length-1].isNotEqualTo(d.p1)||l.push(d.p1._dup()),(!1===o||c<t.length-1||c===t.length-1&&l[0].isNotEqualTo(d.p2))&&l.push(d.p2._dup()),0!==c&&!u[u.length-1].isNotEqualTo(f.p1)||u.push(f.p1._dup()),(!1===o||c<t.length-1||c===t.length-1&&u[0].isNotEqualTo(f.p2))&&u.push(f.p2._dup()),"fill"!==r&&"auto"!==r||(c<t.length-1?h=t[c+1]:o&&(h=Bn(t,1)[0]),null!=h&&(c=h[0],h=h.slice(-1)[0],e?(c.p1.isNotEqualTo(f.p2,10)&&(a.push(f.p2._dup()),a.push(c.p1._dup())),h.p1.isNotEqualTo(d.p2,10)&&(a.push(d.p2._dup()),a.push(h.p1._dup()))):(c.p1.isNotEqualTo(f.p2,10)&&(a.push(f.p2._dup()),a.push(d.p2._dup()),a.push(c.p1._dup())),h.p1.isNotEqualTo(d.p2,10)&&(a.push(d.p2._dup()),a.push(h.p1._dup()),a.push(f.p2._dup()))))),"positive"===i?s[0].push(d.p1._dup(),d.p2._dup()):"negative"===i&&s[0].push(f.p1._dup(),f.p2._dup())}));var c=[[]];return"positive"===n?c=[l]:"negative"===n?c=[u]:"line"===n?c=!1===o?[[].concat(u,Mn(l.reverse()))]:[[].concat(u,[u[0],l[0]],Mn(l.reverse()))]:Array.isArray(n)&&(c=n),Array.isArray(i)&&(s=i),[a,c,s]}function Fn(t,e,n){var i=t.intersectsWith(e);!i.withinLine&&"fill"===n||null==i.intersect||(t.setP2(i.intersect._dup()),e.setP1(i.intersect._dup()))}function Dn(t,e,n,i,r){e=ze(t.p1,t.p2,e.p2),t=new Se(t.p2,1,t.angle()+e/2+Math.PI/2),e=n.intersectsWith(t),t=i.intersectsWith(t),"fill"!==r&&(null!=e.intersect&&n.setP2(e.intersect),null!=t.intersect&&i.setP1(t.intersect))}function In(t,e,n,i,r){var o=(a=n.intersectsWith(i)).withinLine,a=a.intersect;if(o&&null!=a)return n.setP2(a),i.setP1(a),0;r||(null!=(e=n.intersectsWith(e)).intersect&&e.withinLine&&n.setP2(e.intersect),null!=(e=i.intersectsWith(t)).intersect&&e.withinLine&&i.setP1(e.intersect))}function Ln(t,e,n,i){var r=(o=n.intersectsWith(i)).withinLine,o=o.intersect;if(r&&null!=o)return n.setP2(o),i.setP1(o),0;null!=(o=n.intersectsWith(e)).intersect&&o.intersect.isWithinLine(e,8)&&n.setP2(o.intersect),null!=(o=i.intersectsWith(t)).intersect&&o.intersect.isWithinLine(t,8)&&i.setP1(o.intersect)}function Wn(t,e,n,i,r,o,a,s,l,u,c){e=1<arguments.length&&void 0!==e?e:.01,n=2<arguments.length?n:void 0,i=3<arguments.length?i:void 0;var h=4<arguments.length&&void 0!==r&&r,f=5<arguments.length?o:void 0,d=(a=6<arguments.length&&void 0!==a?a:Math.PI/7,7<arguments.length&&void 0!==s&&s),p=8<arguments.length&&void 0!==l?l:2,m=(u=9<arguments.length&&void 0!==u?u:"line",c=10<arguments.length&&void 0!==c?c:[[]],(i=Bn(function(t,e,n,i,r,o,a){for(var s=6<arguments.length&&void 0!==a?a:2,l=[],u=function(t,e){return new Se(t,e)},c=0;c<t.length-1;c+=1)l.push(u(t[c],t[c+1]));n&&l.push(u(t[t.length-1],t[0]));for(var h=[],f="negative",d="positive",p=[],m=function(t,e,n,a,s){var l=a,u=a,c=Math.PI;null!=t&&(c=We(t.p1,e.p1,e.p2),f=ze(t.p1,e.p1,e.p2),h=e.distanceToPoint(t.p1),h=Math.min(h,Math.tan(Math.abs(f))*e.length()),c<Math.PI/2?l=Math.min(l,h):c>Math.PI/2*3&&(u=Math.min(u,h)));var h,f=Math.PI;null!=n&&(f=We(e.p1,e.p2,n.p2),h=ze(e.p1,e.p2,n.p2),n=e.distanceToPoint(n.p2),h=Math.min(n,Math.tan(Math.abs(h))*e.length()),f<Math.PI/2?l=Math.min(l,h):f>Math.PI/2*3&&(u=Math.min(u,h))),a="negative"===r?"auto"===i&&(o||c<Math.PI||f<Math.PI)?e.offset("negative",l):e.offset("negative",a):"positive"===r&&"auto"===i&&(o||c>Math.PI||f>Math.PI)?e.offset("positive",u):e.offset("positive",a),p[s].push(a)},y=e/(s-1),v=0;v<l.length;v+=1){var g,b=0<v?l[v-1]:null,w=l[v],x=v<l.length-1?l[v+1]:null;n&&0===v&&(b=l[l.length-1]),n&&v===l.length-1&&(x=l[0]),p.push([]),h.push([]),"negative"===r||"positive"===r||1===s?(p[v].push(w._dup()),h[v].push("mid")):(g="number"==typeof r?w.offset("negative",r*e):w.offset("negative",e/2),p[v].push(g),h[v].push(f));for(var S=1;S<s;S+=1)"negative"===r?(m(b,w,x,S*y,v),h[v].push(f)):"positive"===r?(m(b,w,x,S*y,v),h[v].push(d)):"number"==typeof r?(m(b,w,x,-r*e+S*y,v),h[v].push(0<-r*e+S*y?d:f)):(m(b,w,x,-e/2+S*y,v),h[v].push(0<-e/2+S*y?d:f));"negative"===r&&(p[v].reverse(),h[v].reverse())}return[l,p,h]}(t,e,h,f,n,i,p),3))[0]),y=i[1],v=i[2],g=n;function b(t,e,n){var i=m[t],r=m[e],o=y[t][n],a=y[e][n];e=We(i.p1,i.p2,r.p2),n=v[t][n],0<e&&e<w?"mid"===n?Dn(i,r,o,a,f):"negative"===n?In(i,r,o,a,d):"positive"===n&&Dn(i,r,o,a,f):w<=e&&e<=Math.PI/2?"mid"===n?Fn(o,a,f):"negative"===n?In(i,r,o,a,d):"positive"===n&&Fn(o,a,f):Math.PI/2<=e&&e<Math.PI?"mid"===n||"number"==typeof g?Fn(o,a,f):"negative"===n?Ln(i,r,o,a):"positive"===n&&Fn(o,a,f):e===Math.PI?"negative"!==n&&"positive"!==n||Fn(o,a,f):Math.PI<e&&e<Math.PI/2*3?"mid"===n?(Fn(o,a,f),Fn(o,a,f)):"negative"===n?Fn(o,a,f):"positive"===n&&Ln(i,r,o,a):Math.PI/2*3<=e&&e<=2*Math.PI-w?"mid"===n||"negative"===n?Fn(o,a,f):"positive"===n&&In(i,r,o,a,d):2*Math.PI-w<e&&e<2*Math.PI?"mid"===n||"negative"===n?Dn(i,r,o,a,f):"positive"===n&&In(i,r,o,a,d):Math.PI}"number"==typeof n&&(g="mid");var w=null==a?0:a;if("none"!==f)for(var x=0;x<p;x+=1){for(var S=0;S<y.length-1;S+=1)b(S,S+1,x);h&&b(y.length-1,0,x)}return u=(a=Bn(Rn(y,d,u,c,f,h),3))[0],c=a[1],a=a[2],[[].concat(Mn(u),[]),c,a]}function zn(t,e,n){var i=new pe(-t.x,-t.y),r=(s=new Se(n.p1.add(i),n.p2.add(i))).p1.x,o=s.p1.y,a=(u=s.p2.x)-r,s=(t=(l=s.p2.y)-o,Math.sqrt(a*a+t*t)),l=(r=r*l-u*o,e),u=(o=(r*t+(u=function(t){return t<0?-1:1})(t)*a*Math.sqrt(l*l*s*s-r*r))/(s*s),e=(r*t-u(t)*a*Math.sqrt(l*l*s*s-r*r))/(s*s),(-r*a+Math.abs(t)*Math.sqrt(l*l*s*s-r*r))/(s*s));return r=(-r*a-Math.abs(t)*Math.sqrt(l*l*s*s-r*r))/(s*s),s=[],isNaN(o)||isNaN(u)||(u=new pe(o,u).sub(i),n.hasPointOn(u)&&s.push(u)),isNaN(e)||isNaN(r)||(i=new pe(e,r).sub(i),n.hasPointOn(i)&&s.push(i)),s}function Nn(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"mid",o=4<arguments.length?arguments[4]:void 0,a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:.1,s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:10,l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:Math.PI/7,u=8<arguments.length&&void 0!==arguments[8]?arguments[8]:[],c=9<arguments.length&&void 0!==arguments[9]&&arguments[9],h=10<arguments.length&&void 0!==arguments[10]?arguments[10]:2,d=11<arguments.length&&void 0!==arguments[11]?arguments[11]:"line",p=12<arguments.length&&void 0!==arguments[12]?arguments[12]:0,m=13<arguments.length&&void 0!==arguments[13]?arguments[13]:[[]],y=14<arguments.length&&void 0!==arguments[14]?arguments[14]:null,v=15<arguments.length&&void 0!==arguments[15]?arguments[15]:8,g=[],b=t,w=En(y,n,!0);!1===i&&null!=y&&(b=function(t,e){var n=e.start,i=e.end;if(e=[],null!=n){for(var r=t[0],o=0,a=Bn(kn(n),2)[1],s=!1;o<t.length-1&&!1===s;)a<r.distance(t[o+=1])&&(s=!0);!s||null!=(n=Bn(zn(r,a,new Se(t[o-1],t[o])),1)[0])&&(e=[n].concat(Mn(t.slice(o))))}else e=t;if(null!=i){for(var l=t[t.length-1],u=t.length-1,c=Bn(kn(i),2)[1],h=!1;0<u&&!1===h;)c<l.distance(t[--u])&&(h=!0);!h||null!=(i=Bn(zn(l,c,new Se(t[u+1],t[u])),1)[0])&&(e=[].concat(Mn(e.slice(0,u+1)),[i]))}return e}(t,w)),"auto"===o?(g=b.map((function(t){return t._dup()})),e="auto"):"radius"===o?(g=function(t,e,n,i,r){var o=[];e?o=sn(t[t.length-1],t[0],t[1],i,n,r):o.push(t[0]);for(var a=1;a<t.length-1;a+=1){var s=sn(t[a-1],t[a],t[a+1],i,n,r);o=[].concat(on(o),on(s))}return e?o=[].concat(on(o),on(sn(t[t.length-2],t[t.length-1],t[0],i,n,r))):o.push(t[t.length-1]._dup()),o}(b,i,"fromVertex",s,a),e="fill"):(e=o,g=b.map((function(t){return t._dup()})));var x,S=function(t,e,n){if("mid"===n||"negative"===n||"positive"===n||"number"==typeof n)return n;for(var i=0,r=e?t.length:t.length-2,o=function(t,e,n){(n=We(t,e,n))<Math.PI&&(i+=1),n===Math.PI&&--r},a=1;a<t.length-1;a+=1)o(t[a-1],t[a],t[a+1]);return e&&(o(t[t.length-1],t[0],t[1]),o(t[t.length-2],t[t.length-1],t[0])),r/2<=i?"inside"===n?"negative":"positive":"inside"===n?"positive":"negative"}(g,i,r),T=[],A=!0;1<u.length&&(O=(k=Bn(function(t,e,n,i){var r=2<arguments.length&&void 0!==n&&n,o=3<arguments.length&&void 0!==i?i:8;n=e,i=0,e.length%2==1&&(n=e.slice(1),i=cn(e,1)[0]);for(var a,s=[],l=(a=[],n=(e=n).reduce((function(t,e){return a.push(t+e),t+e}),0),{definition:e,sum:n,cum:a}),u=i,c=!1,h=!0,d=function(t,e){var n=function(t,e,n,i,r){for(var o=4<arguments.length&&void 0!==r?r:8,a=[],s=0,l=(i=cn(dn(t,i,o),2))[0],u=(i=i[1],!0),c=new Se(e,n),h=f(c.length(),o),d=f(i,o),p=l;s<h;){var m,y=l%2==0;u=y,y?(m=c.pointAtPercent(s/h),y=f(s+d,o)<=h?c.pointAtPercent((s+d)/h):n._dup(),s+=d,a.push([m,y])):s+=d,s=f(s,o),l=((p=l)+1)%t.definition.length,d=f(t.definition[l],o)}return{points:a,continues:h<s&&p%2==0,onLine:u}}(l,t,e,u,o);h=n.onLine;var i=n.points;n=n.continues,s=c&&null!=i[0]?(s[s.length-1]=[].concat(un(s[s.length-1]),un(i[0].slice(1))),[].concat(un(s),un(i.slice(1)))):[].concat(un(s),un(i)),c=n,u=f(u+ge(t,e),o)},p=0;p<t.length-1;p+=1)d(t[p],t[p+1]);return r&&(d(t[t.length-1],t[0]),i=cn(dn(l,i),1)[0],c&&i%2==0&&1<s.length&&(s[0]=[].concat(un(s[s.length-1]),un(s[0].slice(1))))),[s,h]}(g,u,i,v),2))[0],A=k[1],x=!1,1===O.length&&(x=i),O.forEach((function(t){t=Bn(Wn(t,n,S,"inside"===r,x,e,l,c,h,d,m),1)[0],T=[].concat(Mn(T),Mn(t))})));var k,O,_,P=Bn(Wn(g,n,S,"inside"===r,i,e,l,c,h,d,m),3),E=P[0];return s=P[1],a=P[2],o=s,"number"==typeof p&&0!==p&&(v=.5,k=n+2*p,v="positive"===S?p/k:"negative"===S?(p+n)/k:"mid"===S?.5:(p+S*n)/k,O=g,!(o=[])===i&&(P=new Se(g[0],g[1]).pointAtLength(-p),_=(_=new Se(g[g.length-2],g[g.length-1])).pointAtLength(_.length()+p),O=[P].concat(Mn(g.slice(1,-1)),[_])),_=d,Array.isArray(d)&&(_="line"),o=Bn(Wn(O,k,v,"inside"===r,i,e,l,c,h,_,m),2)[1]),E=1<u.length?T:E,null!=y&&!1===i?Hn(w,[b[0],t[0]],[b[b.length-1],t[t.length-1]],E,s,o,a,p,n,A):[E,s,o,a]}function qn(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length?arguments[3]:void 0,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"mid",o=5<arguments.length?arguments[5]:void 0,a=6<arguments.length?arguments[6]:void 0,s=7<arguments.length?arguments[7]:void 0,l=8<arguments.length&&void 0!==arguments[8]?arguments[8]:Math.PI/7,u=9<arguments.length&&void 0!==arguments[9]&&arguments[9],c=10<arguments.length&&void 0!==arguments[10]?arguments[10]:1,h=11<arguments.length&&void 0!==arguments[11]?arguments[11]:0,f=(i=function(t,e,n){for(var i=3<arguments.length&&!1,r=[],o=1;o<t.length-1;o+=1)r.push(ln(t[o-1],t[o],t[o+1],n,i));return e&&(r.push(ln(t[t.length-2],t[t.length-1],t[0],n,i)),r.push(ln(t[t.length-1],t[0],t[1],n,i))),r}(t,n,i,!1),[]),d=[],p=[],m=[],y="number"==typeof h?h:0;return i.forEach((function(t){var n=(h=Bn(Nn(t,e,!1,r,o,a,s,l,[],u,c,"line",y,[[]]),4))[0],i=h[1],h=(t=h[2],h[3]);f=[].concat(Mn(f),Mn(n)),d=[].concat(Mn(d),Mn(i)),m=[].concat(Mn(m),Mn(t)),p=[].concat(Mn(p),Mn(h))})),[f,d,m,p]}function Hn(t,e,n,i,r,o,a,s,l,u){var c={},h=i,f=r;i=o,r=h.length,null!=(o=(c=null!=t?t:c).start)&&(t=new Se(e[0],e[1]),e=new Se(h[0],h[2]).midPoint(),t=(e=Bn(On(ct({},o,{align:"tail",drawPosition:(d=[(t=new Se(e,t.length(),t.angle())).p1,t.p2])[0],angle:new Se(d[0],d[1]).angle(),drawBorderBuffer:s,tailWidth:l})),3))[0],d=e[1],e=e[2],o=_n(t,o),h=[].concat(Mn(h),Mn(o),[h[0]._dup(),h[2]._dup(),e[0]._dup(),e[0]._dup(),h[2]._dup(),e[1]._dup()]),f=[].concat(Mn(f),[t]),i=[].concat(Mn(i),[d[0]]));var d=c.end;return null!=d&&(c=r,r=new Se(n[0],n[1]),n=new Se(h[c-2],h[c-1]).midPoint(),n=(r=Bn(On(ct({},d,{align:"tail",drawPosition:(n=[(r=new Se(n,r.length(),r.angle())).p1,r.p2])[0],angle:new Se(n[0],n[1]).angle(),drawBorderBuffer:s,tailWidth:l})),3))[0],s=r[1],l=r[2],r=_n(n,d),d=[],u&&(d=[h[c-2]._dup(),h[c-1]._dup(),l[0]._dup(),l[0]._dup(),h[c-1]._dup(),l[1]._dup()]),h=[].concat(Mn(h),Mn(r),Mn(d)),f=[].concat(Mn(f),[n]),i=[].concat(Mn(i),[s[0]])),[h,f,i,a]}function Kn(t,e,n){for(var i,r,o=n?4*t.length+2:4*(t.length-1),a=Array(o),s=e/2,l=Math.PI/2,u=function(e,n){var i=t[e],r=t[n],o=Math.atan2(r.y-i.y,r.x-i.x),a=s*Math.cos(o-l);return e=s*Math.cos(o+l),n=s*Math.sin(o-l),o=s*Math.sin(o+l),[new pe(i.x+a,i.y+n),new pe(i.x+e,i.y+o),new pe(r.x+a,r.y+n),new pe(r.x+e,r.y+o)]},c=0;c<t.length-1;c+=1){var h=(p=Bn(u(c,c+1),4))[0],f=p[1],d=p[2],p=p[3];a[4*c]=h,a[4*c+1]=f,a[4*c+2]=d,a[4*c+3]=p}return n&&(i=(r=Bn(u(t.length-1,0),4))[0],e=r[1],n=r[2],r=r[3],a[o-6]=i,a[o-5]=e,a[o-4]=n,a[o-3]=r,a[o-2]=a[0]._dup(),a[o-1]=a[1]._dup()),[a,[[]],[[]],[[]]]}function Un(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Gn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vn(t){return function(t){if(Array.isArray(t))return Yn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Gn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gn(t,e){if(t){if("string"==typeof t)return Yn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yn(t,e):void 0}}function Yn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Xn(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01;return[(t=ue(t)).x-e/2,t.y-e/2,t.x+e/2,t.y-e/2,t.x+e/2,t.y+e/2,t.x-e/2,t.y-e/2,t.x+e/2,t.y+e/2,t.x-e/2,t.y+e/2]}function $n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,n=ue(t);return t=2*Math.PI/6,[(n=[[e+n.x,n.y],[e*Math.cos(t)+n.x,e*Math.sin(t)+n.y],[e*Math.cos(2*t)+n.x,e*Math.sin(2*t)+n.y],[e*Math.cos(3*t)+n.x,e*Math.sin(3*t)+n.y],[e*Math.cos(4*t)+n.x,e*Math.sin(4*t)+n.y],[e*Math.cos(5*t)+n.x,e*Math.sin(5*t)+n.y]])[0][0],n[0][1],n[1][0],n[1][1],n[2][0],n[2][1],n[0][0],n[0][1],n[2][0],n[2][1],n[3][0],n[3][1],n[0][0],n[0][1],n[3][0],n[3][1],n[4][0],n[4][1],n[0][0],n[0][1],n[4][0],n[4][1],n[5][0],n[5][1]]}function Qn(t){return"number"==typeof t&&2<t?4===t?Xn.bind(this):6===t?$n.bind(this):function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.01,i=ue(e),r=2*Math.PI/t,o=[],a=0;a<t;a+=1)o.push([n*Math.cos(r*a)+i.x,n*Math.sin(r*a)+i.y]);for(var s=[],l=1;l<t-1;l+=1)s.push.apply(s,[o[0][0],o[0][1],o[l][0],o[l][1],o[l+1][0],o[l+1][1]]);return s}.bind(this,t):"hex"===t?$n.bind(this):"function"==typeof t?t:Xn.bind(this)}var Jn=function(t,e){for(var n=[],i=0;i<e;i+=1)n.push.apply(n,Vn(t));return n};function Zn(t,e,n,i){for(var r=[],o=[],a=[e,n],s=[0,0],l=0;l<n;l+=1)for(var u=0;u<e;u+=1){var c=l*e*4+4*u;i(c=[t[c]/255,t[1+c]/255,t[2+c]/255,t[3+c]/255],[u,l])&&(r.push([u,l]),o.push(c),a[0]=u<a[0]?u:a[0],a[1]=l<a[1]?l:a[1],s[0]=u>s[0]?u:s[0],s[1]=l>s[1]?l:s[1])}return{max:s,min:a,pixels:r,pixelColors:o}}function ti(t,e,n){for(var i=1<arguments.length&&void 0!==e?e:null,r=t,o=(t=(n=Un(function(t,e){for(var n=r,i=0,o=Array(n.length).fill(0),a=Array(n.length).fill(0),s=1;s<n.length;s+=1){var l=[n[s].x,n[s].y],u=[n[s-1].x,n[s-1].y];i+=u=Math.sqrt(Math.pow(l[0]-u[0],2)+Math.pow(l[1]-u[1],2)),o[s]=u,a[s]=i}return e&&(t=[n[0].x,n[0].y],e=[n[n.length-1].x,n[n.length-1].y],i+=e=Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)),o[0]=e,a[0]=i),[i,a,o]}(0,e=2<arguments.length&&void 0!==n&&n),3))[0],n[1]),a=n[2],s=r.length,l=t/((s=null!=i?i:s)-1),u=[],c=1,h=0,f=0;f<s-1;f+=1){var d=f*l,p=void 0;if(0===f)p=new pe(r[f].x,r[f].y);else{for(;o[c]<d&&0<c;)c===r.length-1?c=0:c+=1,h+=1;var m=1-(o[c]-d)/a[c],y=r[h],v=r[c];p=new pe((v.x-y.x)*m+y.x,(v.y-y.y)*m+y.y)}u.push(p)}return e||u.push(r[r.length-1]._dup()),[u,t,l]}function ei(t){return function(t){if(Array.isArray(t))return ni(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return ni(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ni(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ni(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var ii={simple:{src:"attribute vec2 a_position;uniform mat3 u_matrix;uniform float u_z;void main() {gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, u_z, 1);}",vars:["a_position","u_matrix","u_z"]},vertexColor:{src:"\nattribute vec2 a_position;\nattribute vec4 a_col;\nvarying vec4 v_col;\nuniform mat3 u_matrix;\nuniform float u_z;\nvoid main() {\n gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, u_z, 1);\n v_col = a_col;\n}",vars:["a_position","a_col","u_matrix","u_z"]},withTexture:{src:"attribute vec2 a_position;attribute vec2 a_texcoord;uniform mat3 u_matrix;uniform float u_z;varying vec2 v_texcoord;void main() {gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, u_z, 1);v_texcoord = a_texcoord;}",vars:["a_position","a_texcoord","u_matrix","u_z"]},morph4:{src:"\nattribute vec2 a_pos0;\nattribute vec2 a_pos1;\nattribute vec2 a_pos2;\nattribute vec2 a_pos3;\nuniform mat3 u_matrix;\nuniform float u_percent;\nuniform int u_from;\nuniform int u_to;\n\nvoid main() {\n vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[4];\n\n positions[0] = a_pos0;\n positions[1] = a_pos1;\n positions[2] = a_pos2;\n positions[3] = a_pos3;\n\n for (int i = 0; i < 4; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n break;\n }\n }\n for (int i = 0; i < 4; i++) {\n if (u_to == i) {\n toPos = positions[i];\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = vec4((u_matrix * vec3(newPosition.xy, 1)).xy, 0, 1);\n}\n",vars:["a_pos0","a_pos1","a_pos2","a_pos3","u_matrix","u_percent","u_from","u_to"]},morpher:function(t,e){var n="",i="vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[".concat(t,"];\n"),r="",o="",a=["u_matrix","u_percent"];e&&(o="vec4 fromCol = a_col0;\n vec4 toCol = a_col1;\n vec4 colors[".concat(t,"];"));for(var s=0;s<t;s+=1)a.push("a_pos".concat(s)),n="".concat(n,"attribute vec2 a_pos").concat(s,";\n"),i="".concat(i," positions[").concat(s,"] = a_pos").concat(s,";\n"),e&&(r="".concat(r,"attribute vec4 a_col").concat(s,";\n"),o="".concat(o," colors[").concat(s,"] = a_col").concat(s,";\n"),a.push("a_col".concat(s)));a.push("u_to"),a.push("u_from");var l="",u="",c="";return e&&(r="".concat(r,"varying vec4 v_col;\n"),l="toCol = colors[i];\n",u="fromCol = colors[i];\n",c="v_col = (toCol - fromCol) * u_percent + fromCol;\n"),{src:"\n".concat(n,"\n").concat(r,"\nuniform mat3 u_matrix;\nuniform float u_percent;\n").concat("uniform int u_from;\nuniform int u_to;\n","\n\nvoid main() {\n ").concat(i,"\n ").concat(o,"\n\n for (int i = 0; i < ").concat(t,"; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n ").concat(u,"\n break;\n }\n }\n for (int i = 0; i < ").concat(t,"; i++) {\n if (u_to == i) {\n toPos = positions[i];\n ").concat(l,"\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = vec4((u_matrix * vec3(newPosition.xy, 1)).xy, 0, 1);\n ").concat(c,"\n}\n"),vars:a}},morph4VertexColor:{src:"\nattribute vec2 a_pos0;\nattribute vec2 a_pos1;\nattribute vec2 a_pos2;\nattribute vec2 a_pos3;\nattribute vec4 a_col0;\nattribute vec4 a_col1;\nattribute vec4 a_col2;\nattribute vec4 a_col3;\nuniform mat3 u_matrix;\nuniform float u_percent;\nuniform int u_from;\nuniform int u_to;\nvarying vec4 v_col;\n\nvoid main() {\n vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[4];\n positions[0] = a_pos0;\n positions[1] = a_pos1;\n positions[2] = a_pos2;\n positions[3] = a_pos3;\n\n vec4 fromCol = a_col0;\n vec4 toCol = a_col1;\n vec4 colors[4];\n colors[0] = a_col0;\n colors[1] = a_col1;\n colors[2] = a_col2;\n colors[3] = a_col3;\n\n for (int i = 0; i < 4; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n fromCol = colors[i];\n break;\n }\n }\n for (int i = 0; i < 4; i++) {\n if (u_to == i) {\n toPos = positions[i];\n toCol = colors[i];\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = vec4((u_matrix * vec3(newPosition.xy, 1)).xy, 0, 1);\n v_col = (toCol - fromCol) * u_percent + fromCol;\n}\n",vars:["a_pos0","a_pos1","a_pos2","a_pos3","a_col0","a_col1","a_col2","a_col3","u_matrix","u_percent","u_from","u_to"]}},ri={simple:{src:"precision mediump float;uniform vec4 u_color;void main() {gl_FragColor = u_color;gl_FragColor.rgb *= gl_FragColor.a;}",vars:["u_color"]},vertexColor:{src:"precision mediump float;uniform vec4 u_color;varying vec4 v_col;void main() {gl_FragColor = v_col;gl_FragColor.rgb *= gl_FragColor.a;}",vars:["u_color"]},withTexture:{src:"precision mediump float;uniform vec4 u_color;uniform int u_use_texture;uniform sampler2D u_texture;varying vec2 v_texcoord;void main() {if ( u_use_texture == 1) {gl_FragColor = texture2D(u_texture, v_texcoord) * u_color.a;} else {gl_FragColor = u_color;gl_FragColor.rgb *= gl_FragColor.a;}}",vars:["u_color","u_use_texture","u_texture"]},text:{src:"precision mediump float;uniform vec4 u_color;uniform sampler2D u_texture;varying vec2 v_texcoord;void main() {vec4 c = texture2D(u_texture, v_texcoord);gl_FragColor = vec4(c.a * u_color.rgb, c.a * u_color.a);}",vars:["u_color","u_texture"]}},oi={TRIANGLES:1,TRIANGLE_STRIP:2,TRIANGLE_FAN:3,LINES:4,LINK_STATUS:1,VERTEX_SHADER:1,COMPILE_STATUS:1,FRAGMENT_SHADER:1,SRC_ALPHA:1,ONE_MINUS_SRC_ALPHA:1,BLEND:1,COLOR_BUFFER_BIT:1,TEXTURE_2D:1,RGBA:1,UNSIGNED_BYTE:1,TEXTURE_WRAP_S:1,CLAMP_TO_EDGE:1,TEXTURE_WRAP_T:1,TEXTURE_MIN_FILTER:1,LINEAR:1,ARRAY_BUFFER:1,STATIC_DRAW:1,FLOAT:1,UNPACK_PREMULTIPLY_ALPHA_WEBGL:1,createBuffer:function(){},bindBuffer:function(){},bufferData:function(){},enableVertexAttribArray:function(){},vertexAttribPointer:function(){},disableVertexAttribArray:function(){},uniformMatrix3fv:function(){},uniform4f:function(){},uniform1f:function(){},uniform1i:function(){},texParameteri:function(){},drawArrays:function(){},clearColor:function(){},clear:function(){},createTexture:function(){},activeTexture:function(){},bindTexture:function(){},pixelStorei:function(){},texImage2D:function(){},blendFunc:function(){},attachShader:function(){},linkProgram:function(){},getProgramParameter:function(){},createProgram:function(){},deleteProgram:function(){},createShader:function(){},shaderSource:function(){},compileShader:function(){},getShaderParameter:function(){},getAttribLocation:function(){},getUniformLocation:function(){},enable:function(){},map:function(){},getExtension:function(){return{loseContext:function(){}}},disable:function(){},deleteShader:function(){},useProgram:function(){},viewport:function(){},canvas:{toDataURL:function(){return""},width:100,clientHeight:100,height:100,style:{top:0,visibility:"visible"}}};function ai(t,e,n){if(e=t.createShader(e),t.shaderSource(e,n),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS))return e;throw new Error("Could not compile shader: ".concat(n))}const si=function(){function t(e,n){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),null==(e=e.getContext("webgl",{antialias:!0}))&&(e=oi),this.programs=[],this.lastUsedProgram=null,this.textures={},null!=e&&(this.gl=e,this.resize(),this.gl.disable(this.gl.DEPTH_TEST),this.gl.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this.gl.enable(e.BLEND))}var e=[{key:"addTexture",value:function(t,e,n){if(this.textures[t]&&null!=this.textures[t].glTexture)return this.textures[t].index;var i=this.textures[t]?this.textures[t].index:Object.keys(this.textures).length;return this.textures[t]={glTexture:e,index:i,type:n,state:"loaded",onLoad:[]},i}},{key:"onLoad",value:function(t){this.textures[t].onLoad.forEach((function(t){return t()})),this.textures[t].onLoad=[]}},{key:"getProgram",value:function(t,e){for(var n=0;n<this.programs.length;n+=1){var i=this.programs[n];if(i.vertexShader===t&&i.fragmentShader===e)return n}var r,o,a=function(t,e){var n=0<arguments.length&&void 0!==t?t:"simple",i=1<arguments.length&&void 0!==e?e:"simple",r="",o="";if(t=[],"string"==typeof n){if(null==ii[n])throw new Error("Built in vertex shader does not exist: ".concat(n));r=ii[n].src,t.push.apply(t,ei(ii[n].vars))}else if(Array.isArray(n)&&"string"==typeof n[0])r=(e=ii[n[0]].apply(ii,ei(n.slice(1)))).src,t.push.apply(t,ei(e.vars));else{if(Array.isArray(n))throw new Error("Vertex shader definition incorrect: ".concat(n));r=n.src,t.push.apply(t,ei(n.vars))}if("string"==typeof i){if(null==ri[i])throw new Error("Built in fragment shader does not exist: ".concat(i));o=ri[i].src,t.push.apply(t,ei(ri[i].vars))}else if(Array.isArray(i)&&"string"==typeof i[0])o=(n=ii[i[0]].apply(ii,ei(i.slice(1)))).src,t.push.apply(t,ei(n.vars));else{if(Array.isArray(i))throw new Error("Fragment shader definition incorrect: ".concat(i));o=i.src,t.push.apply(t,ei(i.vars))}return{vertexSource:r,fragmentSource:o,vars:t}}(t,e),s=(r=this.gl,o=a.vertexSource,s=a.fragmentSource,o=ai(r,r.VERTEX_SHADER,o),s=ai(r,r.FRAGMENT_SHADER,s),o&&s?function(t,e,n){var i=t.createProgram();if(t.attachShader(i,e),t.attachShader(i,n),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS))return i;throw i=t.getProgramInfoLog(i),new Error("Could not compile WebGL program. \n\n ".concat(i||""))}(r,o,s):null);return a={vertexShader:t,fragmentShader:e,program:s,locations:function(t,e,n){for(var i,r={},o=0;o<n.length;o+=1)"a"===(i=n[o])[0]&&(r[i]=t.getAttribLocation(e,i)),"u"===i[0]&&(r[i]=t.getUniformLocation(e,i));return r}(this.gl,s,a.vars)},this.programs.push(a),this.programs.length-1}},{key:"useProgram",value:function(t){return t=this.programs[t],this.lastUsedProgram!==t.program&&(this.gl.useProgram(t.program),this.lastUsedProgram=t.program),t.locations}},{key:"resize",value:function(){var t=window.devicePixelRatio,e=Math.floor(this.gl.canvas.clientWidth*t);t=Math.floor(this.gl.canvas.clientHeight*t),this.gl.canvas.width===e&&this.gl.canvas.height===t||(this.gl.canvas.width=e,this.gl.canvas.height=t),this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function li(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ui(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ui(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ui(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ci(t,e,n){var i=ct({},{precision:5,ignoreShown:!1,min:!1},n),r=i.precision,o={};return e.forEach((function(e){var n,a=function t(e,n,i){var r=li(i,1)[0];return 1===i.length?[e,n,i[0]]:(null==e[r]&&(e[r]={}),null==n[r]?null:t(e[r],n[r],i.slice(1)))}(o,t,e.split("."));null!=a&&(e=(n=li(a,3))[0],a=n[1],e[n=n[2]]=function t(e){if("string"==typeof e)return e;if("number"==typeof e)return e;if("boolean"==typeof e)return e;if("function"!=typeof e){if(null==e)return e;if(null!=e._def)return e._def(r);if(null!=e._state)return e._state(i);if(Array.isArray(e)){var n=[];return e.forEach((function(e){n.push(t(e))})),n}if(null!=e._dup)return e._dup();var o,a={},s=Object.keys(e),l=s=e._stateKeys?e._stateKeys():s;return e._excludeStateKeys&&(l=[],o=e._excludeStateKeys(),s.forEach((function(t){-1===o.indexOf(t)&&l.push(t)}))),l.forEach((function(n){"function"!=typeof e[n]&&(a[n]=t(e[n]))})),a}}(a[n]))})),o}var hi=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e=ct({},{onFinish:null,completeOnCancel:null,removeOnFinish:!0,name:gt(),duration:1,delay:0,beforeFrame:null,afterFrame:null,precision:8,element:null},e),this.onFinish=e.onFinish,this.completeOnCancel=e.completeOnCancel,this.duration=e.duration,this.element=e.element,this.startTime=null,this.state="idle",this.name=e.name,this.afterFrame=e.afterFrame,this.beforeFrame=e.beforeFrame,this.startDelay=e.delay,this.precision=e.precision,(this.timeKeeper=null)!=e.timeKeeper&&(this.timeKeeper=e.timeKeeper),this.removeOnFinish=e.removeOnFinish,this.startTimeOffset=0,this.fnMap=new G,this.fnMap.add("tools.math.easein",x),this.fnMap.add("tools.math.easeout",w),this.fnMap.add("tools.math.easeinout",b),this.fnMap.add("tools.math.linear",v),this.fnMap.add("tools.math.sinusoid",S),this}var e=[{key:"_fromDef",value:function(t){return ct(this,t),this}},{key:"fnExec",value:function(t){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return(e=this.fnMap).exec.apply(e,[t].concat(i))}},{key:"setTimeDelta",value:function(t){null!=this.startTime&&null!=t&&(this.startTime+=t),null==t&&(this.startTime=null)}},{key:"_getStateProperties",value:function(){return["startTime","duration","onFinish","completeOnCancel","state","startTimeOffset","removeOnFinish","name","startDelay","beforeFrame","afterFrame","_stepType"]}},{key:"_getStateName",value:function(){return"animationStep"}},{key:"_state",value:function(t){return{f1Type:this._getStateName(),state:ci(this,this._getStateProperties(),t)}}},{key:"_fromState",value:function(t,e,n){return ct(this,t),null!=this.element&&"string"==typeof this.element&&null!=e&&(this.element=e(this.element)),this.timeKeeper=n,this}},{key:"setTimeSpeed",value:function(t,e,n){null!=this.startTime&&(t=(n-this.startTime)*t,this.startTime=n-t/e)}},{key:"nextFrame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return null==this.startTime&&(this.startTime=t-this.startTimeOffset),t=(t-this.startTime)*e,e=d(-(this.duration+this.startDelay-t),this.precision),t>=this.startDelay&&((t-=this.startDelay)>=this.duration&&(e=t-this.duration,t=this.duration),this.beforeFrame&&this.beforeFrame(t/this.duration),this.setFrame(t),this.afterFrame&&this.afterFrame(t/this.duration),0<=e&&this.finish()),e}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;if(null==this.duration)return null;var e=this.getTotalDuration();return null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:(t-=this.startTime,this.duration+this.startDelay-t)}},{key:"getTotalDuration",value:function(){return null==this.duration?null:this.duration+this.startDelay}},{key:"setFrame",value:function(t){}},{key:"startWaiting",value:function(){this.state="waitingToStart"}},{key:"start",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.state="animating","number"!=typeof e&&null!=e?"nextFrame"!==e?null!=this.timeKeeper?(t=this.timeKeeper.getWhen(e),this.startTime=null!=t?t/1e3:null):this.startTime="nextFrame"===e?null:performance.now():this.startTime=null:this.startTime=e}},{key:"finishIfZeroDuration",value:function(){0===this.duration&&0===this.startDelay&&this.finish()}},{key:"setToEnd",value:function(){}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(t=this.state,this.state="finished",e&&("complete"===n||null==n&&!0===this.completeOnCancel?("waitingToStart"===t&&this.start(),this.setToEnd()):"waitingToStart"===t&&this.cancelledWithNoComplete()),!1===e&&("waitingToStart"===t&&this.start(),this.setToEnd()),null!=this.onFinish&&this.fnExec(this.onFinish,e,n))}},{key:"cancelledWithNoComplete",value:function(){}},{key:"cancel",value:function(){this.finish(!0,0<arguments.length&&void 0!==arguments[0]?arguments[0]:null)}},{key:"_dup",value:function(){var e=new t;return ht(this,e,["timeKeeper","element"]),e.timeKeeper=this.timeKeeper,e.element=this.element,e}},{key:"whenFinished",value:function(t){return this.onFinish=t,this}},{key:"ifCanceledThenComplete",value:function(){return this.completeOnCancel=!0,this}},{key:"ifCancelled",value:function(){return this.completeOnCancel="complete"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"freeze"),this}},{key:"ifCanceledThenStop",value:function(){return this.completeOnCancel=!1,this}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function fi(t){return(fi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function di(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function pi(t,e,n){return(pi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=yi(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function mi(t,e){return(mi=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function yi(t){return(yi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var vi=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mi(t,e)}(r,hi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=yi(e);return function(t,e){if(e&&("object"===fi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=yi(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var e=i.call(this,t),n="easeinout";return t=ct({},{element:null,type:"custom",progression:n="color"===t.type||"custom"===t.type||"opacity"===t.type?"linear":n},t),e.element=t.element,e.type=t.type,e.onFinish=t.onFinish,e.progression=t.progression,"linear"===e.progression?e.progression="tools.math.linear":"easein"===t.progression?e.progression="tools.math.easein":"easeout"===t.progression?e.progression="tools.math.easeout":"easeinout"===t.progression?e.progression="tools.math.easeinout":e.progression=t.progression,e}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(i)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(i))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return di(t)}(t=pi(yi(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return di(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?di(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["type","progression","element"]);var t}},{key:"getPercentComplete",value:function(t){return"string"!=typeof this.progression?"function"==typeof this.progression?this.progression(t):0:null==(t=this.fnExec(this.progression,t))?0:t}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;pi(yi(r.prototype),"start",this).call(this,t),null!=this.element&&this.element.animateNextFrame()}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function gi(t){return(gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function bi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function wi(t,e,n){return(wi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Si(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function xi(t,e){return(xi=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Si(t){return(Si=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ti=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&xi(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Si(e);return function(t,e){if(e&&("object"===gi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Si(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t;!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ct.apply(void 0,[{},{type:"position"}].concat(n));yt(a,["start","delta","target","path","pathOptions","velocity","maxDuration"]),(t=i.call(this,a))._stepType="position";var s={start:null,target:null,delta:null,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},maxDuration:null,velocity:null};return t.element&&t.element.animations.options.translation&&(a=t.element.animations.options.translation,ct(s.path,a)),null!=(s=ct.apply(void 0,[{},s].concat(n))).start&&(s.start=ue(s.start)),null!=s.target&&(s.target=ue(s.target)),null!=s.delta&&(s.delta=ue(s.delta)),t.position={path:{}},vt(s,t.position,["start","delta","target","path","velocity","maxDuration"]),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return bi(t)}(t=wi(Si(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return bi(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?bi(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["position"]);var t}},{key:"_getStateName",value:function(){return"positionAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(wi(Si(r.prototype),"start",this).call(this,t),null==this.position.start){if(null==this.element)return void(this.duration=0);this.position.start=this.element.getPosition()}null==this.position.delta&&null!=this.position.target&&null!=this.position.start?(n=this.position.target.sub(this.position.start),this.position.delta=n):null!=this.position.delta&&null!=this.position.start?this.position.target=this.position.start.add(this.position.delta):this.duration=0;var e=this.position,n=e.target,i=e.start;null!=(e=e.velocity)&&null!=i&&null!=n&&(e=ue(e),this.duration=Ne((new Ee).translate(i),(new Ee).translate(n),(new Ee).translate(e))),null!=this.position.maxDuration&&this.duration>this.position.maxDuration&&(this.duration=this.position.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration,t=this.getPercentComplete(t),null!=this.position.delta&&null!=this.position.start&&(t=this.position.start.toDelta(this.position.delta,t,this.position.path.style,this.position.path),null!=this.element&&this.element.setPosition(t))}},{key:"setToEnd",value:function(){null!=this.element&&null!=this.position.target&&this.element.setPosition(this.position.target)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ai(t){return(Ai="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ki(t,e){var n=new RegExp(e,"g");return e=function(t){return t[1].toUpperCase()},t.replace(n,"").replace(/-[a-z]/g,e).replace(/_[a-z]/g,e).replace(/-/g,"")}function Oi(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:function(t){return t},a={},s=t;return(s="string"==typeof t?document.getElementById(t):s)instanceof HTMLElement&&(n=window.getComputedStyle(s))&&e.forEach((function(t){var e,s,l=n.getPropertyValue(t);null!=l&&(l=l.trim(),e=parseFloat(l),Number.isNaN(e)||(l=e),l=o(l),r?(s=ki(t,i),a[s]=l):(s=new RegExp(i,"g"),s=t.replace(s,""),at(a,s,l,"-")))})),a}var _i=["base","lighter","light","dark","darker","higher","high","low","lower"],Pi=[];["blue","red","yellow","green","cyan","brown","orange","violet","grey","black","white"].forEach((function(t){_i.forEach((function(e){Pi.push("--palette-".concat(t,"-").concat(e))}))}));var Ei=["--figure-background","--figure-primary","--figure-warning","--figure-safe","--figure-passive","--figure-construction1","--figure-construction2","--figure-construction3","--figure-construction4","--figure-construction5","--figure-construction6","--figure-construction7","--figure-construction8","--figure-construction9","--figure-disabled","--figure-disabledDark","--figure-disabledDarker","--figure-disabledDarkest","--figure-push","--figure-action","--figure-text-base","--figure-text-warning","--figure-text-plot","--figure-text-keyword","--figure-text-keyword2","--figure-text-latin","--figure-text-greek","--figure-text-english","--figure-text-note","--figure-qr-background"];function Mi(){var t={},e={},n={},i=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[]).map((function(t){return"--colors-".concat(t)})),r=document.body;return r&&(t=Oi(r,i,"--colors-",!1,ji),e=Oi(r,Pi,"--palette-",!1,ji),n=Oi(r,Ei,"--figure-",!1,ji)),t.palette=e,t.figure=n,t}function Bi(t){return 3===(t=t.replace(/.*\(/i,"").replace(/\)/i,"").split(",").map((function(t,e){return e<3?parseInt(t,10)/255:parseFloat(t)}))).length&&t.push(1),t}function Ci(t){return(t=t.slice(1)).length<6&&(t="".concat(t[0]).concat(t[0]).concat(t[1]).concat(t[1]).concat(t[2]).concat(t[2])),[parseInt(t.slice(0,2),16)/255,parseInt(t.slice(2,4),16)/255,parseInt(t.slice(4,6),16)/255,1]}function ji(t){var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},n=t.slice(0);return t=[],(n=n in e?e[n]:n).toLowerCase().startsWith("rgb")?t=Bi(n):n.startsWith("#")&&(t=Ci(n)),0<t.length?t:null}function Ri(t){return"rgba(".concat(Math.floor(255*t[0]),",").concat(Math.floor(255*t[1]),",").concat(Math.floor(255*t[2]),",").concat(t[3],")")}function Fi(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)return!1;for(var i=0;i<t.length;i+=1)if(d(t[i],n)!==d(e[i],n))return!1;return!0}function Di(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.001;if(t.length!==e.length)return!1;for(var i=0;i<t.length;i+=1)if(n<Math.abs(t[i]-e[i]))return!1;return!0}function Ii(t){return(Ii="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Li(t,e,n){return(Li=qi()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&Ni(i,n.prototype),i}).apply(null,arguments)}function Wi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function zi(t,e,n){return(zi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Hi(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ni(t,e){return(Ni=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function qi(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Hi(t){return(Hi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ki=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ni(t,e)}(r,hi);var t,e,n,i=(e=r,n=qi(),function(){var t,i=Hi(e);return function(t,e){if(e&&("object"===Ii(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Hi(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var n,o={steps:[],duration:0},a=arguments.length,s=new Array(1<a?a-1:0),l=1;l<a;l++)s[l-1]=arguments[l];return Array.isArray(e)?(n=ct.apply(void 0,[{},o].concat(s))).steps=e:n=ct.apply(void 0,[{},o,e].concat(s)),(t=i.call(this,n)).steps=[],e=[],Array.isArray(n.steps)||null==n.steps?null!=n.steps&&(e=n.steps):e=[n.steps],t.steps=[],e.forEach((function(e){null!=e&&t.steps.push(e)})),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Wi(t)}(t=zi(Hi(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Wi(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Wi(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["steps"]);var t}},{key:"_getStateName",value:function(){return"parallelAnimationStep"}},{key:"setTimeDelta",value:function(t){zi(Hi(r.prototype),"setTimeDelta",this).call(this,t),null!=this.steps&&this.steps.forEach((function(e){e.setTimeDelta(t)}))}},{key:"with",value:function(t){return null!=t&&this.steps.push(t),this}},{key:"setTimeSpeed",value:function(t,e,n){zi(Hi(r.prototype),"setTimeSpeed",this).call(this,t,e,n),this.steps.forEach((function(i){return i.setTimeSpeed(t,e,n)}))}},{key:"nextFrame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;null===this.startTime&&(this.startTime=t-this.startTimeOffset);var n=null;return null!=this.beforeFrame&&this.beforeFrame(t-this.startTime),this.steps.forEach((function(i){"animating"!==i.state&&"waitingToStart"!==i.state||(i=i.nextFrame(t,e))<(n=null===n?i:n)&&(n=i)})),null!=this.afterFrame&&this.afterFrame(t-this.startTime),0<=(n=null===n?0:n)&&this.finish(),n}},{key:"finishIfZeroDuration",value:function(){var t="finished";this.steps.forEach((function(e){"finished"!==e.state&&(t="animating")})),"finished"===t&&this.finish()}},{key:"startWaiting",value:function(){zi(Hi(r.prototype),"startWaiting",this).call(this),this.steps.forEach((function(t){t.startWaiting()}))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.startWaiting(),zi(Hi(r.prototype),"start",this).call(this,t),this.steps.forEach((function(e){e.start(t),e.finishIfZeroDuration()}))}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(this.state="finished",!(t=null)===this.completeOnCancel&&(t="complete"),!1===this.completeOnCancel&&(t="freeze"),null!=n&&(t=n),this.steps.forEach((function(n){"idle"!==n.state&&"finished"!==n.state&&n.finish(e,t)})),null!=this.onFinish&&this.fnExec(this.onFinish,e))}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.steps.length;e+=1){var n=this.steps[e].getTotalDuration();if(null==n)return null;t<n&&(t=n)}return t}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;var e=this.getTotalDuration();return null==e?null:null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:e-(t-this.startTime)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ui(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Li(Ki,[t].concat(n))}function Vi(t){return(Vi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Gi(t,e){if(t){if("string"==typeof t)return Yi(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yi(t,e):void 0}}function Yi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Xi(t,e,n){return(Xi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Qi(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function $i(t,e){return($i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Qi(t){return(Qi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ji=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$i(t,e)}(r,Ki);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Qi(e);return function(t,e){if(e&&("object"===Vi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Qi(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t;!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ct.apply(void 0,[{},{type:"scenario"}].concat(n));yt(a,["start","target","path","velocity","maxDuration","allDurationsSame","rotDirection","clipRotationTo","element","progression"]),(t=i.call(this,a))._stepType="position";var s,l={element:null,start:null,target:null,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},rotDirection:0,clipRotationTo:null,velocity:null,maxDuration:null,allDurationsSame:!0,zeroDurationThreshold:0,progression:"tools.math.easeinout"};return t.element&&t.element.animations.options.translation&&(s=t.element.animations.options.translation,ct(l.path,s)),l=ct.apply(void 0,[{},l].concat(n)),t.element=l.element,t.scenario={},vt(l,t.scenario,["start","target","path","velocity","maxDuration","allDurationsSame","zeroDurationThreshold","rotDirection","clipRotationTo","progression"]),null!=t.scenario.velocity&&null==a.duration?t.duration=0:null==a.duration&&(t.duration=1),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Yi(t)}(t=Xi(Qi(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Gi(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["scenario","element"]);var t}},{key:"_getStateName",value:function(){return"scenarioAnimationStep"}},{key:"getDuration",value:function(t,e){var n=this.element;if(null==(s=this.scenario.velocity)||null==n)return[this.duration,this.duration,this.duration];var i=n.transform._dup().constant(1),r=null==s.color?1:s.color,o=null==s.opacity?1:s.opacity;null!=s.transform&&(i=Be(s.transform)._dup()),null!=s.position&&i.updateTranslation(he(s.position)),null!=s.translation&&i.updateTranslation(he(s.translation)),null!=s.scale&&i.updateScale(he(s.scale)),null!=s.rotation&&i.updateRotation(s.rotation);var a=0,s=(n=t.transform,e.transform);return null!=n&&null!=s&&(a=Ne(n._dup(),s._dup(),i,this.scenario.rotDirection)),i=0,null==t.color||null==e.color||Fi(e.color,t.color)||(i=Math.max(Math.abs(e.color[0]-t.color[0]),Math.abs(e.color[1]-t.color[1]),Math.abs(e.color[2]-t.color[2]),Math.abs(e.color[3]-t.color[3]))/r),r=0,null!=t.isShown&&null!=e.isShown&&(null!=t.opacity&&!0===e.isShown?r=(1-t.opacity)/o:null!=t.opacity&&!1===e.isShown?r=t.opacity/o:t.isShown!==e.isShown&&(r=1/o)),null!=(o=this.scenario.maxDuration)&&(i=Math.min(i,o),r=Math.min(r,o),a=Math.min(a,o)),(i=i<=this.scenario.zeroDurationThreshold?0:i)<this.duration&&(i=this.duration),(r=r<=this.scenario.zeroDurationThreshold?0:r)<this.duration&&(r=this.duration),(a=a<=this.scenario.zeroDurationThreshold?0:a)<this.duration&&(a=this.duration),[a=this.scenario.allDurationsSame?r=i=Math.max(i,r,a):a,i,r]}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Xi(Qi(r.prototype),"start",this).call(this,t);var e=this.element;if(null==e)throw new Error("Missing Element in scenario animation - null element for target: ".concat(this.scenario.target));var n=e.getScenarioTarget(this.scenario.target);0===Object.keys(n).length&&(n=e.getCurrentScenario());var i={};null!=this.scenario.start&&(i=e.getScenarioTarget(this.scenario.start)),0===Object.keys(i).length&&(i=e.getCurrentScenario(),1!==e.opacity&&(i.opacity=e.opacity));var o=null,a=!1;!1===i.isShown&&!0===n.isShown&&null==i.opacity?o="in":!0===n.isShown&&null!=i.opacity?(o="in",a=!0):!0===i.isShown&&!1===n.isShown&&null==i.opacity?o="out":!1===n.isShown&&null!=i.opacity&&(o="out",a=!0);var s=(u=3,(c=function(t){if(Array.isArray(t))return t}(l=this.getDuration(i,n))||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(l,u)||Gi(l,u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),l=c[1],u=c[2],c=[];null!=n.transform&&c.push(e.animations.transform({delay:this.startDelay,start:i.transform,target:n.transform,duration:s,rotDirection:this.scenario.rotDirection,path:this.scenario.path,clipRotationTo:this.scenario.clipRotationTo,progression:this.scenario.progression})),null!=n.color&&c.push(e.animations.color({delay:this.startDelay,start:i.color,target:n.color,duration:l,progression:this.scenario.progression})),null!=o&&c.push(e.animations.opacity({delay:this.startDelay,dissolve:o,dissolveFromCurrent:a,duration:u,progression:this.scenario.progression})),this.steps=c,Xi(Qi(r.prototype),"start",this).call(this,t)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Zi(t){return(Zi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function tr(t,e,n){return(tr=sr()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&or(i,n.prototype),i}).apply(null,arguments)}function er(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function nr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ir(t,e,n){return(ir="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=lr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function rr(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&or(t,e)}function or(t,e){return(or=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ar(t){var e=sr();return function(){var n,i=lr(t);return function(t,e){if(e&&("object"===Zi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=lr(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function sr(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function lr(t){return(lr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ur=function(){rr(n,vi);var t,e=ar(n);function n(){nr(this,n);for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];yt(a=ct.apply(void 0,[{}].concat(i,[{type:"color"}])),["start","delta","target","dissolve"]);var o=e.call(this,a),a=ct.apply(void 0,[{},{start:null,target:null,delta:null,dissolve:null}].concat(i));return o.color={},vt(a,o.color,["start","delta","target","dissolve"]),"dim"===o.color.target?(null!=o.element&&(o.color.target=o.element.dimColor.slice()),o.color.setDefault=!1):"undim"===o.color.target?(null!=o.element&&(o.color.target=o.element.defaultColor.slice()),o.color.setDefault=!1):o.color.setDefault=!0,o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return er(t)}(t=ir(lr(n.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return er(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?er(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["color"]);var t}},{key:"_getStateName",value:function(){return"colorAnimationStep"}},{key:"start",value:function(){var t,e,i,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=this.element;null!=o?(ir(lr(n.prototype),"start",this).call(this,r),null==this.color.start&&(this.color.start=o.color.slice()),null==this.color.delta&&null==this.color.target?this.color.target=this.color.start.slice():null!=this.color.delta&&(this.color.target=(e=this.color.start,i=this.color.delta,e.map((function(t,e){return Math.min(t+i[e],1)})))),this.color.whenComplete=this.color.target.slice(),"out"===this.color.dissolve&&(this.color.target[3]=.001),"in"===this.color.dissolve&&(this.color.start[3]=.001,o.setColor(this.color.start,this.color.setDefault),o.showAll()),this.color.delta=(o=this.color.target,t=this.color.start,o.map((function(e,n){return e-t[n]})))):this.duration=0,"now"!==r&&"prevFrame"!==r||this.setFrame(0)}},{key:"setFrame",value:function(t){var e=this,n=(t/=this.duration,this.getPercentComplete(t));t=this.color.start.map((function(t,i){return(i=1<(i=t+e.color.delta[i]*n)?1:i)<0?0:i})),null!=this.element&&this.element.setColor(t,this.color.setDefault)}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(t.setColor(this.color.whenComplete,this.color.setDefault),"out"===this.color.dissolve&&t.hide())}},{key:"_dup",value:function(){var t=new n;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,t),n}(),cr=function(){rr(e,ur);var t=ar(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};nr(this,e);for(var i={duration:1,target:"dim",completeOnCancel:!0},r=arguments.length,o=new Array(1<r?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n=ct.apply(void 0,("number"==typeof n?[{},i,{duration:n}]:[{},i,n]).concat(o)),t.call(this,n)}return e}(),hr=function(){rr(e,ur);var t=ar(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};nr(this,e);for(var i={duration:1,target:"undim",completeOnCancel:!0},r=arguments.length,o=new Array(1<r?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n=ct.apply(void 0,("number"==typeof n?[{},i,{duration:n}]:[{},i,n]).concat(o)),t.call(this,n)}return e}();function fr(t){return(fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function dr(t,e,n){return(dr=wr()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&gr(i,n.prototype),i}).apply(null,arguments)}function pr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function mr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function yr(t,e,n){return(yr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=xr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function vr(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&gr(t,e)}function gr(t,e){return(gr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function br(t){var e=wr();return function(){var n,i=xr(t);return function(t,e){if(e&&("object"===fr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=xr(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function wr(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function xr(t){return(xr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Sr=function(){vr(n,vi);var t,e=br(n);function n(){mr(this,n);for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];yt(a=ct.apply(void 0,[{}].concat(i,[{type:"opacity"}])),["start","delta","target","dissolve","dissolveFromCurrent"]);var o=e.call(this,a),a=ct.apply(void 0,[{},{start:null,target:null,delta:null,dissolve:null,dissolveFromCurrent:!1}].concat(i));return o.opacity={},vt(a,o.opacity,["start","delta","target","dissolve","dissolveFromCurrent"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return pr(t)}(t=yr(xr(n.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return pr(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?pr(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["opacity"]);var t}},{key:"_getStateName",value:function(){return"opacityAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=this.element;null!=e?(yr(xr(n.prototype),"start",this).call(this,t),null==this.opacity.start&&(this.opacity.start=e.opacity),null==this.opacity.delta&&null==this.opacity.target?this.opacity.target=this.opacity.start:null!=this.opacity.delta&&(this.opacity.target=this.opacity.start+this.opacity.delta),this.opacity.whenComplete=this.opacity.target,"out"===this.opacity.dissolve&&(this.opacity.dissolveFromCurrent&&e.isShown?this.opacity.start=e.opacity:this.opacity.start=1,this.opacity.target=.001,this.opacity.whenComplete=1,e.setOpacity(this.opacity.start)),"in"===this.opacity.dissolve&&(this.opacity.dissolveFromCurrent&&e.isShown?this.opacity.start=e.opacity:this.opacity.start=.001,this.opacity.target=1,this.opacity.whenComplete=1,e.showAll(),e.setOpacity(this.opacity.start)),this.opacity.delta=this.opacity.target-this.opacity.start):this.duration=0,"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"cancelledWithNoComplete",value:function(){var t=this.element;null!=t&&.001===t.opacity&&(t.hide(),t.opacity=1)}},{key:"setFrame",value:function(t){t/=this.duration,t=this.getPercentComplete(t),(t=1<(t=this.opacity.start+this.opacity.delta*t)?1:t)<0&&(t=0),null!=this.element&&this.element.setOpacity(t)}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(t.setOpacity(this.opacity.whenComplete),"out"===this.opacity.dissolve&&t.hide())}},{key:"_dup",value:function(){var t=new n;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,t),n}(),Tr=function(){vr(e,Sr);var t=br(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};mr(this,e);for(var i={duration:1,dissolve:"in",completeOnCancel:!0},r=arguments.length,o=new Array(1<r?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n=ct.apply(void 0,("number"==typeof n?[{},i,{duration:n}]:[{},i,n]).concat(o)),t.call(this,n)}return e}(),Ar=function(){vr(e,Sr);var t=br(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};mr(this,e);for(var i={duration:1,dissolve:"out",completeOnCancel:!0},r=arguments.length,o=new Array(1<r?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n=ct.apply(void 0,("number"==typeof n?[{},i,{duration:n}]:[{},i,n]).concat(o)),t.call(this,n)}return e}();function kr(t){return(kr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Or(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function _r(t,e,n){return(_r="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Er(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Pr(t,e){return(Pr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Er(t){return(Er=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Mr=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Pr(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Er(e);return function(t,e){if(e&&("object"===kr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Er(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ct.apply(void 0,[{},{type:"transform"}].concat(e));yt(o,["start","delta","target","rotDirection","path","velocity","clipRotationTo","maxDuration"]);var a,s={start:null,target:null,delta:null,rotDirection:0,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},velocity:null,clipRotationTo:null,maxDuration:null};return(a=i.call(this,o)).element&&a.element.animations.options.translation&&(o=a.element.animations.options.translation,ct(s.path,o)),null!=(s=ct.apply(void 0,[{},s].concat(e))).start&&(s.start=Be(s.start)),null!=s.target&&(s.target=Be(s.target)),null!=s.delta&&(s.delta=Be(s.delta)),null!=s.velocity&&"number"!=typeof s.velocity&&(s.velocity=Be(s.velocity)),a.transform={},vt(s,a.transform,["start","delta","target","path","velocity","rotDirection","clipRotationTo","maxDuration"]),a}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Or(t)}(t=_r(Er(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Or(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Or(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["transform"]);var t}},{key:"_getStateName",value:function(){return"transformAnimationStep"}},{key:"start",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(_r(Er(r.prototype),"start",this).call(this,n),null===this.transform.start){if(null==this.element)return void(this.duration=0);this.transform.start=this.element.transform._dup()}null==this.transform.delta&&null!=this.transform.target?((t=this.transform.target.sub(this.transform.start)).order.forEach((function(t,n){var i=e.transform.start.order[n];n=e.transform.target.order[n],t instanceof Oe&&i instanceof Oe&&n instanceof Oe&&(n=xe(i.r,n.r,e.transform.rotDirection),t.r=n)})),this.transform.delta=t):null!=this.transform.delta?this.transform.target=this.transform.start.add(this.transform.delta):this.duration=0,null!=this.transform.velocity&&(this.duration=Ne(this.transform.start,this.transform.target,this.transform.velocity,this.transform.rotDirection)),null!=this.transform.maxDuration&&this.duration>this.transform.maxDuration&&(this.duration=this.transform.maxDuration),"now"!==n&&"prevFrame"!==n||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration+1e-6,t=this.getPercentComplete(t),t=this.transform.start.toDelta(this.transform.delta,t,this.transform.path.style,this.transform.path),null!==this.transform.clipRotationTo&&t.clipRotation(this.transform.clipRotationTo),null!=this.element&&this.element.setTransform(t)}},{key:"setToEnd",value:function(){null!=this.element&&this.element.setTransform(this.transform.target)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Br(t){return(Br="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function jr(t,e,n){return(jr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Fr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Rr(t,e){return(Rr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Fr(t){return(Fr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Dr=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Rr(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Fr(e);return function(t,e){if(e&&("object"===Br(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Fr(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ct.apply(void 0,[{},{type:"transform"}].concat(e));yt(o,["start","delta","target","rotDirection","path","velocity","clipRotationTo","maxDuration","zeroDurationThreshold"]);var a,s,l={start:null,target:null,delta:[],path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},rotDirection:0,velocity:null,clipRotationTo:null,maxDuration:null,zeroDurationThreshold:0};return(a=i.call(this,o)).element&&a.element.animations.options.translation&&(s=a.element.animations.options.translation,ct(l.path,s)),l=ct.apply(void 0,[{},l].concat(e)),a.transform={},vt(l,a.transform,["start","delta","target","path","velocity","rotDirection","clipRotationTo","maxDuration","zeroDurationThreshold"]),null!=a.transform.velocity&&null==o.duration&&(a.duration=0),a}return t=[{key:"spread",value:function(t,e){if(e===t.length)return t;if(e<=1)return[t[0]];var n=[];if(e>t.length){for(var i=e-t.length,r=Math.ceil(i/2),o=Math.floor(i/2),a=t[0]._dup(),s=t[t.length-1]._dup(),l=0;l<r;l+=1)n.push(a._dup());for(var u=0;u<t.length;u+=1)n.push(t[u]._dup());for(var c=0;c<o;c+=1)n.push(s._dup());return n}e=t.length-e;for(var h=Math.ceil((t.length-e)/2),f=(e=Math.floor((t.length-e)/2),0);f<h;f+=1)n.push(t[f]._dup());for(var d=t.length-e;d<t.length;d+=1)n.push(t[d]._dup());return n}},{key:"setStartAndTarget",value:function(){var t=(e=this.transform).start,e=e.target;e=Math.max(t.length,e.length),this.transform.start=this.spread(this.transform.start,e),this.transform.target=this.spread(this.transform.target,e)}},{key:"calculateStartTargetDelta",value:function(){var t=this;if(this.transform.start.length===this.transform.target.length){this.transform.delta=[];for(var e=0;e<this.transform.start.length;e+=1)!function(e){var n=t.transform.start[e],i=t.transform.target[e];(e=i.sub(n)).order.forEach((function(e,r){var o=n.order[r];r=i.order[r],e instanceof Oe&&o instanceof Oe&&r instanceof Oe&&(r=xe(o.r,r.r,t.transform.rotDirection),e.r=r)})),t.transform.delta.push(e)}(e)}else this.transform.delta=[]}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Cr(t)}(t=jr(Fr(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Cr(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Cr(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["transform"]);var t}},{key:"_getStateName",value:function(){return"transformAnimationStep"}},{key:"getVelocityTransform",value:function(){var t=this.transform.velocity;if(null==t)return new Ee;if(t instanceof Ee)return t;if("number"==typeof t)return this.transform.start[0]._dup().constant(t);var e=this.transform.start[0]._dup().constant(1);null!=t.transform&&(e=Be(t.transform)._dup());for(var n=0;n<e.order.length;n+=1){var i,r,o=e.order[n];o instanceof Pe&&null!=t.scale&&(i=he(t.scale),o.x=i.x,o.y=i.y),o instanceof _e&&null!=t.translation&&(r=he(t.translation),o.x=r.x,o.y=r.y),o instanceof _e&&null!=t.position&&(r=he(t.position),o.x=r.x,o.y=r.y),o instanceof Oe&&null!=t.rotation&&(o.r=t.rotation)}return e}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(jr(Fr(r.prototype),"start",this).call(this,t),null==this.transform.start||0===this.transform.start.length){if(null==this.element)return void(this.duration=0);0<this.element.pulseTransforms.length?this.transform.start=this.element.pulseTransforms.map((function(t){return t._dup()})):this.transform.start=[this.transform.target[0].identity()]}if(0===this.transform.start.length&&null!=this.element&&(this.transform.start=[this.element.transform._dup()]),this.setStartAndTarget(),this.calculateStartTargetDelta(),0===this.transform.delta.length&&(this.duration=0),null!=this.transform.velocity)for(var e=this.getVelocityTransform(),n=0;n<this.transform.start.length;n+=1){var i=Ne(this.transform.start[n],this.transform.target[n],e,this.transform.rotDirection);i>this.duration&&(this.duration=i)}null!=this.transform.maxDuration&&this.duration>this.transform.maxDuration&&(this.duration=this.transform.maxDuration),this.duration<=this.transform.zeroDurationThreshold&&(this.duration=0),this.duration=d(this.duration,this.precision),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration;var e=this.getPercentComplete(t);if(null!=this.element){var n=this.element;n.frozenPulseTransforms=[];for(var i=0;i<this.transform.start.length;i+=1){var r=this.transform.start[i].toDelta(this.transform.delta[i],e,this.transform.path.style,this.transform.path);null!==this.transform.clipRotationTo&&r.clipRotation(this.transform.clipRotationTo),n.frozenPulseTransforms.push(r)}}}},{key:"setToEnd",value:function(){var t;null!=this.element&&((t=this.element).frozenPulseTransforms=[],this.transform.target.forEach((function(e){t.frozenPulseTransforms.push(e._dup())})))}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ir(t){return(Ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Wr(t,e,n){return(Wr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Nr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function zr(t,e){return(zr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Nr(t){return(Nr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var qr=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&zr(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Nr(e);return function(t,e){if(e&&("object"===Ir(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Nr(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];yt(a=ct.apply(void 0,[{},{type:"rotation"}].concat(e)),["start","delta","target","direction","velocity","clipTo","maxDuration"]);var o=i.call(this,a),a=ct.apply(void 0,[{},{start:null,target:null,delta:null,direction:0,velocity:null,clipTo:null,maxDuration:null}].concat(e));return o.rotation={},vt(a,o.rotation,["start","delta","target","velocity","direction","clipTo","maxDuration"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Lr(t)}(t=Wr(Nr(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Lr(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Lr(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["rotation"]);var t}},{key:"_getStateName",value:function(){return"rotationAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(Wr(Nr(r.prototype),"start",this).call(this,t),null===this.rotation.start){if(null==this.element)return void(this.duration=0);this.rotation.start=this.element.transform.r()||0}null==this.rotation.delta&&null!=this.rotation.target?(e=xe(this.rotation.start,this.rotation.target,this.rotation.direction),this.rotation.delta=e):null!=this.rotation.delta?this.rotation.target=this.rotation.start+this.rotation.delta:this.duration=0;var e=this.rotation.velocity;null!=e&&(this.duration=Ne((new Ee).rotate(this.rotation.start),(new Ee).rotate(this.rotation.target),(new Ee).rotate(e),this.rotation.direction)),null!=this.rotation.maxDuration&&this.duration>this.rotation.maxDuration&&(this.duration=this.rotation.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){var e=t/(this.duration+1e-6);t=this.getPercentComplete(e),e=ae(this.rotation.start+this.rotation.delta*t,this.rotation.clipTo),null!=(t=this.element)&&t.setRotation(e)}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(t.transform.updateRotation(ae(this.rotation.target,this.rotation.clipTo)),this.fnExec(t.setTransformCallback,t.transform))}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Hr(t){return(Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Kr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ur(t,e,n){return(Ur="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Gr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Vr(t,e){return(Vr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Gr(t){return(Gr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Yr=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Vr(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Gr(e);return function(t,e){if(e&&("object"===Hr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Gr(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];yt(a=ct.apply(void 0,[{},{type:"position"}].concat(e)),["start","delta","target","velocity","maxDuration"]);var o=i.call(this,a),a=ct.apply(void 0,[{},{start:null,target:null,delta:null,velocity:null,maxDuration:null}].concat(e));return o.scale={},null!=a.start&&(a.start=ue(a.start)),null!=a.target&&(a.target=ue(a.target)),null!=a.delta&&(a.delta=ue(a.delta)),vt(a,o.scale,["start","delta","target","path","velocity","maxDuration"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Kr(t)}(t=Ur(Gr(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Kr(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Kr(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["scale"]);var t}},{key:"_getStateName",value:function(){return"scaleAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(Ur(Gr(r.prototype),"start",this).call(this,t),null===this.scale.start){if(null==this.element)return void(this.duration=0);this.scale.start=this.element.getScale()}null==this.scale.delta&&null!=this.scale.target&&null!=this.scale.start?(n=this.scale.target.sub(this.scale.start),this.scale.delta=n):null!=this.scale.delta&&null!=this.scale.start?this.scale.target=this.scale.start.add(this.scale.delta):this.duration=0;var e=this.scale,n=e.target,i=e.start;null!=(e=e.velocity)&&null!=n&&null!=i&&(e=ue(e),this.duration=Ne((new Ee).scale(i),(new Ee).scale(n),(new Ee).scale(e))),null!=this.scale.maxDuration&&this.duration>this.scale.maxDuration&&(this.duration=this.scale.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration+1e-6,t=this.getPercentComplete(t),null!=this.scale.start&&null!=this.scale.delta&&(t=this.scale.start.toDelta(this.scale.delta,t),null!=this.element&&this.element.setScale(t))}},{key:"setToEnd",value:function(){null!=this.element&&null!=this.scale.target&&this.element.setScale(this.scale.target)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Xr(t){return(Xr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Qr(t,e,n){return(Qr="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Zr(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Jr(t,e){return(Jr=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Zr(t){return(Zr=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var to=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Jr(t,e)}(r,vi);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Zr(e);return function(t,e){if(e&&("object"===Xr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Zr(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t;!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ct.apply(void 0,[{},{type:"position"}].concat(n));return yt(a,["stopAfterDuration","frequency","scale","rotation","translation","angle","min","centerOn","xAlign","yAlign","space","done","num","when","stopAfterDuration","velocity","maxDuration"]),(t=i.call(this,a))._stepType="pulse",void 0===(a=ct.apply(void 0,[{},{scale:2,rotation:null,translation:null,angle:0,duration:1,frequency:0,xAlign:"center",yAlign:"middle",num:1,space:"figure",done:null,progression:"sinusoid",when:"syncNow",type:"pulse",stopAfterDuration:!0}].concat(n))).centerOn&&null!=t.element&&(a.centerOn=t.element),t.pulse={},vt(a,t.pulse,["stopAfterDuration","frequency","scale","rotation","translation","angle","min","centerOn","xAlign","yAlign","space","done","num","when","stopAfterDuration","velocity","maxDuration","duration","elements"]),t.pulse.centerOn=a.centerOn,t.duration=a.duration,t.toStart=!0,t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return $r(t)}(t=Qr(Zr(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return $r(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?$r(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["scale","numLines","frequency","stopAfterDuration","toStart","pulse"]);var t}},{key:"_getStateName",value:function(){return"pulseAnimationStep"}},{key:"setFrame",value:function(){var t;this.toStart&&(null!=(t=this.element)&&t.pulse(this.pulse),this.toStart=!1)}},{key:"setToEnd",value:function(){null!=this.element&&this.pulse.stopAfterDuration&&this.element.stopPulsing()}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function eo(t){return(eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function no(t,e,n){return(no=ao()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&oo(i,n.prototype),i}).apply(null,arguments)}function io(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ro(t,e,n){return(ro="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=so(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function oo(t,e){return(oo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ao(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function so(t){return(so=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var lo=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&oo(t,e)}(r,hi);var t,e,n,i=(e=r,n=ao(),function(){var t,i=so(e);return function(t,e){if(e&&("object"===eo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=so(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e,n={payload:null,duration:0,setToEnd:null,autoDuration:!0},o=arguments.length,a=new Array(1<o?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return"function"==typeof t||"string"==typeof t?(e=ct.apply(void 0,[{},n].concat(a))).callback=t:e=ct.apply(void 0,[{},n,t].concat(a)),(t=i.call(this,e)).element=e.element,t.callback=e.callback,t.payload=e.payload,t.duration=e.duration,t.autoDuration=e.autoDuration,e.setToEnd&&(t.setToEndCallback=e.setToEnd),t.customProperties=e.customProperties,t}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(i)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(i))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return io(t)}(t=ro(so(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return io(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?io(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["callback","payload","customProperties","element"]);var t}},{key:"_getStateName",value:function(){return"triggerAnimationStep"}},{key:"setFrame",value:function(){var t=this.fnExec(this.callback,this.payload,this.customProperties);null!=t&&"number"==typeof t&&this.autoDuration&&(this.duration=t),this.callback=null}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;ro(so(r.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame()}},{key:"setToEnd",value:function(){null!=this.setToEndCallback?this.fnExec(this.setToEndCallback,this.payload,this.customProperties):this.fnExec(this.callback,this.payload,this.customProperties),this.callback=null}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element","timeKeeper"]),t.timeKeeper=this.timeKeeper,t.element=this.element,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function uo(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return no(lo,[t].concat(n))}function co(t){return(co="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ho(t,e,n){return(ho=yo()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&mo(i,n.prototype),i}).apply(null,arguments)}function fo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function po(t,e,n){return(po="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=vo(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function mo(t,e){return(mo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function yo(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function vo(t){return(vo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var go=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mo(t,e)}(r,hi);var t,e,n,i=(e=r,n=yo(),function(){var t,i=vo(e);return function(t,e){if(e&&("object"===co(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=vo(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ct.apply(void 0,[{}].concat(e)),a=i.call(this,o);return o=ct.apply(void 0,[{},{element:null,callback:null,startPercent:0,progression:"linear",duration:1}].concat(e)),a.element=o.element,a.progression=o.progression,"linear"===a.progression?a.progression="tools.math.linear":"easein"===o.progression?a.progression="tools.math.easein":"easeout"===o.progression?a.progression="tools.math.easeout":"easeinout"===o.progression&&(a.progression="tools.math.easeinout"),a.callback=o.callback,a.startPercent=o.startPercent,a.startTimeOffset=a.getPercentComplete(o.startPercent,!0)*o.duration,a.duration=o.duration,a.customProperties=o.customProperties,a}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(i)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(i))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;po(vo(r.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return fo(t)}(t=po(vo(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return fo(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?fo(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["callback","startPercent","progression","customProperties","element"]);var t}},{key:"_getStateName",value:function(){return"customAnimationStep"}},{key:"setFrame",value:function(t){var e;(null==this.duration?this.fnExec(this.callback,t,this.customProperties):(e=t/this.duration,e=this.getPercentComplete(e),this.fnExec(this.callback,e,this.customProperties)))&&(this.duration=t)}},{key:"getPercentComplete",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof this.progression?"function"==typeof this.progression?this.progression(t):0:null==(e=this.fnExec(this.progression,t,e))?0:e}},{key:"setToEnd",value:function(){this.fnExec(this.callback,1,this.customProperties)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function bo(t){return(bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function wo(t,e,n){return(wo=Ao()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&To(i,n.prototype),i}).apply(null,arguments)}function xo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function So(t,e,n){return(So="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ko(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function To(t,e){return(To=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ao(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function ko(t){return(ko=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Oo=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&To(t,e)}(r,hi);var t,e,n,i=(e=r,n=Ao(),function(){var t,i=ko(e);return function(t,e){if(e&&("object"===bo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ko(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e,n={steps:[],duration:0},o=arguments.length,a=new Array(1<o?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return Array.isArray(t)?(e=ct.apply(void 0,[{},n].concat(a))).steps=t:e=ct.apply(void 0,[{},n,t].concat(a)),(t=i.call(this,e)).index=0,t.steps=[],Array.isArray(e.steps)||null==e.steps?null!=e.steps&&(t.steps=e.steps):t.steps=[e.steps],t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return xo(t)}(t=So(ko(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return xo(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?xo(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["steps","index"]);var t}},{key:"_getStateName",value:function(){return"serialAnimationStep"}},{key:"setTimeDelta",value:function(t){So(ko(r.prototype),"setTimeDelta",this).call(this,t),null!=this.steps&&this.steps.forEach((function(e){e.setTimeDelta(t)}))}},{key:"then",value:function(t){return null!=t&&this.steps.push(t),this}},{key:"startWaiting",value:function(){So(ko(r.prototype),"startWaiting",this).call(this),this.steps.forEach((function(t){t.startWaiting()}))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;"animating"!==this.state&&(this.startWaiting(),So(ko(r.prototype),"start",this).call(this,t),(this.index=0)<this.steps.length&&(this.steps[0].start(t),this.steps[0].finishIfZeroDuration())),this.finishIfZeroDuration()}},{key:"finishIfZeroDuration",value:function(){for(var t=0,e=this.steps[0];t<this.steps.length&&"finished"===e.state;)(t+=1)<this.steps.length&&(this.index=t,(e=this.steps[t]).start(this.steps[t-1].startTime),e.finishIfZeroDuration());t===this.steps.length&&this.finish()}},{key:"setTimeSpeed",value:function(t,e,n){So(ko(r.prototype),"setTimeSpeed",this).call(this,t,e,n),this.steps.forEach((function(i){return i.setTimeSpeed(t,e,n)}))}},{key:"nextFrame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;null===this.startTime&&(this.startTime=t-this.startTimeOffset);var n=-1;return null!=this.beforeFrame&&this.beforeFrame(t-this.startTime),this.index<=this.steps.length-1&&(n=this.steps[this.index].nextFrame(t,e),null!=this.afterFrame&&this.afterFrame(t-this.startTime),0<=n)?this.index===this.steps.length-1?(this.finish(),n):(this.index+=1,this.steps[this.index].start(t-n),this.nextFrame(t,e)):n}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(this.state="finished",!(t=null)===this.completeOnCancel&&(t="complete"),!1===this.completeOnCancel&&(t="freeze"),null!=n&&(t=n),this.steps.forEach((function(n){"idle"!==n.state&&"finished"!==n.state&&n.finish(e,t)})),null!=this.onFinish&&this.fnExec(this.onFinish,e,n))}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.steps.length;e+=1){var n=this.steps[e];if(null==n.getTotalDuration())return null;t+=n.getTotalDuration()}return t}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;var e=this.getTotalDuration();return null==e?null:null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:e-(t-this.startTime)}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function _o(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return wo(Oo,[t].concat(n))}function Po(t){return(Po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Eo(t,e,n){return(Eo=Co()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&Bo(i,n.prototype),i}).apply(null,arguments)}function Mo(t,e,n){return(Mo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=jo(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Bo(t,e){return(Bo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Co(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function jo(t){return(jo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ro=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Bo(t,e)}(r,hi);var t,e,n,i=(e=r,n=Co(),function(){var t,i=jo(e);return function(t,e){if(e&&("object"===Po(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=jo(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e={duration:0},n=arguments.length,o=new Array(1<n?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return t=ct.apply(void 0,("number"==typeof t?[{},e,{duration:t}]:[{},e,t]).concat(o)),i.call(this,t)}return t=[{key:"_dup",value:function(){var t=new r;return ht(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Mo(jo(r.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"_getStateName",value:function(){return"delayAnimationStep"}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Fo(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Eo(Ro,[t].concat(n))}var Do=n(477),Io=n.n(Do);function Lo(){return Io()('(()=>{"use strict";var e=function(e){var n=Math.pow(10,1<arguments.length&&void 0!==arguments[1]?arguments[1]:5);return-0!=(e=Math.round(e*n)/n)||0===e&&1/e!=-1/0?e:0};function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||t(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e||NaN===e||"function"==typeof e)return e;if("function"==typeof e._dup)return e._dup();if(Array.isArray(e)){var n=[];return e.forEach((function(e){return n.push(f(e))})),n}var t={};return Object.keys(e).forEach((function(n){var r=f(e[n]);t[n]=r})),t}function a(n,t,r,i){var f=1<arguments.length&&void 0!==t?t:"",o=2<arguments.length&&void 0!==r?r:{},s=3<arguments.length&&void 0!==i?i:null;return"string"==typeof n||"boolean"==typeof n||"function"==typeof n?o["".concat(f)]=n:"number"==typeof n?o["".concat(f)]=null!=s?e(n,s):n:null===n?o["".concat(f)]=null:void 0===n||(Array.isArray(n)?n.forEach((function(e,n){a(e,"".concat(f,"[").concat(n,"]"),o,s)})):Object.keys(n).forEach((function(e){a(n[e],"".concat(f,".").concat(e),o,s)}))),o}function o(e,n,t,r){var f=3<arguments.length&&void 0!==r&&r,a=e[0];if(0!==a.length)if(r=a.match(/\\[[^\\]]*\\]/g),a=a.replace(/\\[.*/,""),1!==e.length||!f||r){if(r){var s=r.map((function(e){return parseInt(e.replace(/\\[|\\]/g,""),10)}));null!=n[a]&&Array.isArray(n[a])||(n[a]=[]);for(var c=n[a],l=0,u=0;u<s.length;u+=1){if(l=s[u],c.length<=l)for(var d=c.length;d<l-c.length+1;d+=1)c.push(void 0);u<s.length-1&&(Array.isArray(c[l])||(c[l]=[]),c=c[l])}return 1===e.length&&f?void(c[l]=void 0):1===e.length?void(c[l]=t):(null!=c[l]&&"object"===i(c[l])||(c[l]={}),void o(e.slice(1),c[l],t,f))}1!==e.length?(null==n[a]&&(n[a]={}),o(e.slice(1),n[a],t,f)):n[a]=t}else delete n[a]}function s(e){var n={};return Object.keys(e).forEach((function(t){var r=t.split(".").filter((function(e){return 0<e.length}));t=e[t],Array.isArray(t)?o(r,n,t.slice(-1)[0]):o(r,n,t)})),n}function c(e){for(var n=f(e),t=function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){var i=r.split(".").filter((function(e){return 0<e.length}));r=e[r],Array.isArray(r)?o(i,n,r.slice(-1)[0],t):o(i,n,r,t)}))},r=arguments.length,i=new Array(1<r?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.forEach((function(e){var n=e.added,r=e.removed;e=e.diff,null!=r&&t(r,!0),null!=n&&t(n),null!=e&&t(e)})),n}function l(e){var n={};return e.diff&&0<Object.keys(e.diff).length&&(n.diff=s(e.diff)),e.added&&0<Object.keys(e.added).length&&(n.added=s(e.added)),e.removed&&0<Object.keys(e.removed).length&&(n.removed=s(e.removed)),n}function u(e){var n={};return e.diff&&0<Object.keys(e.diff).length&&(n.diff=a(e.diff)),e.added&&0<Object.keys(e.added).length&&(n.added=a(e.added)),e.removed&&0<Object.keys(e.removed).length&&(n.removed=a(e.removed)),n}var d=function(){function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;(function(n){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")})(this),this.precision=n,this.reset()}return r=[{key:"toObj",value:function(){var e=this,n={};Object.keys(this.references).forEach((function(t){n[t]={basedOn:e.references[t].basedOn,diff:l(e.references[t].diff)}}));var t=this.diffs.map((function(e){return[e[0],e[1],l(e[2]),e[3]]}));return{baseReference:f(this.baseReference),diffs:t,references:n,precision:this.precision,lastReferenceName:this.lastReferenceName}}},{key:"setFromObj",value:function(e){var n={};Object.keys(e.references).forEach((function(t){n[t]={basedOn:e.references[t].basedOn,diff:u(e.references[t].diff)}})),this.references=n,this.baseReference=f(e.baseReference),this.precision=e.precision,this.diffs=e.diffs.map((function(e){return[e[0],e[1],u(e[2]),e[3]]})),this.lastReferenceName=e.lastReferenceName}},{key:"reset",value:function(){this.baseReference=null,this.references={},this.diffs=[],this.lastReferenceName="__base"}},{key:"setBaseReference",value:function(e){this.baseReference=f(e),this.lastReferenceName="__base"}},{key:"addReference",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"__base";null!=this.baseReference&&"__base"!==n||this.setBaseReference(e),"__base"!==n&&(this.references[n]={diff:this.getDiffToReference(e,t),basedOn:t},this.lastReferenceName=n)}},{key:"getReferenceChain",value:function(e,t){return"__base"===e||null==this.references[e]?t:this.getReferenceChain(this.references[e].basedOn,[this.references[e].diff].concat(n(t)))}},{key:"getReference",value:function(e){return e=this.getReferenceChain(e,[]),c.apply(void 0,[this.baseReference].concat(n(e)))}},{key:"getDiffToReference",value:function(e,t){return t=this.getReferenceChain(t,[]),function(e,t,r,i,f){i=3<arguments.length&&void 0!==i?i:null;var o=4<arguments.length&&void 0!==f&&f,s=(f=e,a(f=0<t.length?c.apply(void 0,[e].concat(n(t))):f,"",{},i)),l=a(r,"",{},i),u={},d={},h={};return Object.keys(s).forEach((function(e){void 0!==l[e]?s[e]!==l[e]&&(d[e]=o?[s[e],l[e]]:l[e]):h[e]=s[e]})),Object.keys(l).forEach((function(e){void 0===s[e]&&(u[e]=l[e])})),i={},0<Object.keys(d).length&&(i.diff=d),0<Object.keys(u).length&&(i.added=u),0<Object.keys(h).length&&(i.removed=h),i}(this.baseReference,t,e,this.precision)}},{key:"getObjFromDiffAndReference",value:function(e,t){return t=this.getReferenceChain(t,[]),e=[].concat(n(t),[e]),c.apply(void 0,[this.baseReference].concat(n(e)))}},{key:"add",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(n),n=this.getDiffToReference(n,t),this.diffs.push([e,t,n,r])}},{key:"addWithWorker",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(n),this.startWorker(),null!=this.worker&&this.worker.postMessage([e,t,n,r])}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new Worker)}},{key:"getFromIndex",value:function(e){if(e>this.diffs.length||0===this.diffs.length)return null;r=3,e=(r=function(e){if(Array.isArray(e))return e}(n=this.diffs[e])||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,i,f=[],a=!0,o=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(f.push(r.value),!n||f.length!==n);a=!0);}catch(e){o=!0,i=e}finally{try{a||null==t.return||t.return()}finally{if(o)throw i}}return f}}(n,r)||t(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1];var n,r=r[2];return this.getObjFromDiffAndReference(r,e)}}],function(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,r),e;var r}(),h=new d;addEventListener("message",(function(e){e=(n=e.data).message;var n=n.payload;"reset"===e?((h=new d).baseReference=n.baseReference,h.references=n.references):"get"===e?postMessage({message:"cache",payload:{baseReferece:h.baseReference,references:h.references,diffs:h.diffs}}):"add"===e?h.add(n.now,n.state,n.reference,n.lastRecordTimeCount):"addReference"===e&&h.addReference(n.state,n.refName,n.basedOn)}))})();',"Worker",void 0,n.p+"figureone.worker.js")}function Wo(t){return function(t){if(Array.isArray(t))return qo(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||No(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zo(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||No(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function No(t,e){if(t){if("string"==typeof t)return qo(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qo(t,e):void 0}}function qo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ho(t,e){if(e<1)return e;for(var n=e,i=!0,r=t[e][0];0<n&&i;)t[n-1][0]!==r?i=!1:--n;return n}function Ko(t,e){for(var n=t[e][0],i=e,r=!0;r;)i!==t.length-1&&t[i+1][0]===n?i+=1:r=!1;return Math.max(i,e)}function Uo(t,e,n,i){var r=2<arguments.length&&void 0!==n?n:0,o=3<arguments.length&&void 0!==i?i:t.length-1;return 0===t.length?[-1,-1]:e===(n=parseFloat(t[r][0]))?[r,r]:e<n?[-1,r]:e===(i=parseFloat(t[o][0]))?[o,o]:i<e?[o,-1]:(n=o-r)<2?[r,o]:(i=r+Math.floor(n/2),e===(n=parseFloat(t[i][0]))?[i,i]:e<n?Uo(t,e,r,i):Uo(t,e,i,o))}function Vo(t,e,n,i,r){return n=2<arguments.length&&void 0!==n?n:0,i=3<arguments.length&&void 0!==i?i:t.length-1,((r=!(4<arguments.length&&void 0!==r)||r)?Ho:Ko)(t,i=Uo(t,e,n,i)[1])}function Go(t,e,n,i,r){return n=2<arguments.length&&void 0!==n?n:0,i=3<arguments.length&&void 0!==i?i:t.length-1,((r=!(4<arguments.length&&void 0!==r)||r)?Ho:Ko)(t,i=Uo(t,e,n,i)[0])}function Yo(t,e){var n=null,i=null;return t.forEach((function(t){var r,o=Go(t,e);o<0||(r=t[o][0],(null==n||n<r)&&(n=r,i=t[o]))})),i}var Xo=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.timeKeeper=e,this.initialize()}var e=[{key:"initialize",value:function(){this.notifications=new jt,this.events={},this.eventsCache={},this.reset(),this.precision=8,this.stateTimeStep=1,this.audio=null,this.worker=null,this.pauseState=null,this.settings={pause:"freeze",play:"instant"},this.queueSeekTime=0,this.queueSeekId=null,this.timeUpdates=100}},{key:"timeStamp",value:function(){return this.timeKeeper.now()}},{key:"now",value:function(){return d((this.timeStamp()-this.videoToNowDelta)/1e3,8)}},{key:"getCurrentTime",value:function(){return"idle"!==this.state?this.now():this.currentTime}},{key:"getDeltaTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return(t=this.getCurrentTime()+t)>this.duration?this.duration:t<0?0:t}},{key:"setCurrentTime",value:function(t){this.currentTime=t,this.notifications.publish("timeUpdate",[t])}},{key:"setVideoToNowDeltaTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;this.videoToNowDelta=this.timeStamp()-1e3*t}},{key:"calcDuration",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=0,i=0,r=0,o=0,a=0;return Object.keys(this.events).forEach((function(e){0<(e=t.events[e]).list.length&&(n=Math.max(n,e.list[e.list.length-1][0]))})),Object.keys(this.eventsCache).forEach((function(e){0<(e=t.eventsCache[e]).list.length&&(i=Math.max(i,e.list[e.list.length-1][0]))})),0<this.states.diffs.length&&(r=zo(this.states.diffs[this.states.diffs.length-1],1)[0]),0<this.statesCache.diffs.length&&(o=zo(this.statesCache.diffs[this.statesCache.diffs.length-1],1)[0]),null==this.audio||isNaN(this.audio.duration)||(a=this.audio.duration),e?Math.max(i,o):Math.max(n,i,r,o,a)}},{key:"reset",value:function(){var t=this;this.states=new Bt(this.precision),this.statesCache=new Bt(this.precision),Object.keys(this.events).forEach((function(e){t.events[e].list=[]})),this.eventsCache={},this.stateIndex=-1,this.eventIndex={},this.stopTimeouts(),this.videoToNowDelta=0,this.state="idle",this.isAudioPlaying=!1,this.setCurrentTime(0),this.duration=0,this.reference="__base",this.lastRecordTimeCount=0,this.lastRecordTime=null,this.eventsToPlay=[],this.lastSeekTime=null,this.referenceIndex=0}},{key:"loadAudioTrack",value:function(t){var e=this;this.audio=t,this.audio.onloadedmetadata=function(){e.duration=e.calcDuration(),e.notifications.publish("durationUpdated",e.duration)},this.audio.oncanplaythrough=function(){e.notifications.publish("audioLoaded")},this.audio.addEventListener("pause",(function(){"playing"===e.state&&e.pausePlayback()})),this.audio.addEventListener("play",(function(){"idle"===e.state&&null==e.audioStartedCallback&&e.resumePlayback()})),t.addEventListener("playing",(function(){return e.audioStarted()}),!1),t.addEventListener("ended",(function(){return e.audioEnded()}),!1)}},{key:"loadEvents",value:function(t){var e=this,n=this.decodeEvents(t,!(1<arguments.length&&void 0!==arguments[1])||arguments[1]);Object.keys(n).forEach((function(t){null!=e.events[t]&&(e.events[t].list=n[t])})),this.duration=this.calcDuration(),this.notifications.publish("eventsLoaded"),this.notifications.publish("durationUpdated",this.duration)}},{key:"loadStates",value:function(t){this.states=this.decodeStates(t,!(1<arguments.length&&void 0!==arguments[1])||arguments[1],!(2<arguments.length&&void 0!==arguments[2])||arguments[2]),this.duration=this.calcDuration(),this.notifications.publish("statesLoaded"),this.notifications.publish("durationUpdated",this.duration)}},{key:"loadSavedData",value:function(t){this.loadStates(t.states,!0,!0),this.loadEvents(t.events,!0),this.notifications.publish("videoLoaded")}},{key:"encodeEvents",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e={},n=st(this.events);return Object.keys(n).forEach((function(t){t.startsWith("_auto")||(e[t]=n[t].list)})),(t?St:st)(e)}},{key:"decodeEvents",value:function(t){return(1<arguments.length&&void 0!==arguments[1]&&!arguments[1]?st:Tt)(t)}},{key:"encodeStates",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.precision;return e=e?this.states.toObj():st(this.states),t?St(e,n):e}},{key:"decodeStates",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],i=t;e&&(i=Tt(t)),n&&((r=new Bt).setFromObj(i),i=r);var r=new Bt;return r.diffs=i.diffs,r.baseReference=i.baseReference,r.references=i.references,r.precision=i.precision,r}},{key:"clearListOrDiffs",value:function(t,e,n){var i=Vo(t,e);return e=Go(t,n),n=[],0<i&&(n=t.slice(0,i)),-1<e&&e+1<=t.length-1?[].concat(Wo(n),Wo(t.slice(e+1))):n}},{key:"clear",value:function(t,e){var n=this;Object.keys(this.events).forEach((function(i){(i=n.events[i]).list=n.clearListOrDiffs(i.list,t,e)})),this.states.diffs=this.clearListOrDiffs(this.states.diffs,t,e)}},{key:"startRecording",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this.state="recording",this.lastSeekTime=null,this.setVideoToNowDeltaTime(t),0<this.states.diffs.length&&this.setToTime(t,!0),this.states.precision=this.precision,0===t&&null==this.states.baseReference&&this.states.setBaseReference(this.figure.getState({precision:this.precision,ignoreShown:!0})),this.recordingStates=!!n,this.startWorker(),null!=this.worker&&this.worker.postMessage({message:"reset",payload:{baseReference:this.states.baseReference,references:this.states.references}}),this.eventsCache={},this.lastRecordTime=null,this.duration=this.calcDuration(),this.recordingStates&&this.queueRecordState(t%this.stateTimeStep),this.eventsToPlay=e,this.startEventsPlayback(t),e=this.startAudioPlayback(t),this.notifications.publish("recordingStarted"),this.startRecordingTime=t,this.startTimeUpdates(),e||this.pausePlayback()}},{key:"startStatesRecording",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.1;this.states.reset(),this.seek(0),this.figure.timeKeeper.setManualFrames(),this.startRecording(0,Object.keys(this.events),!0),this.autoFrame(t)}},{key:"autoFrame",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.1;"recording"===this.state?(this.figure.animateNextFrame(),this.figure.timeKeeper.frame(t),this.getCurrentTime()<=this.duration?setTimeout(this.autoFrame.bind(this,t),5):this.stopStatesRecording()):this.stopStatesRecording()}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new Lo,this.worker.addEventListener("message",this.parseMessage.bind(this)))}},{key:"parseMessage",value:function(t){t=(e=t.data).message;var e=e.payload;"cache"===t&&(this.statesCache=new Bt,this.statesCache.diffs=e.diffs,this.statesCache.baseReference=e.baseReference,this.statesCache.references=e.references,this.mergeEventsCache(),this.mergeStatesCache(),this.duration=this.calcDuration(),this.recordingStates&&(0<this.duration%1&&(t=this.states.diffs.length-1,t=(e=zo(this.states.diffs[t],3))[1],e=e[2],this.states.diffs.push([Math.ceil(this.duration),t,st(e),0]),Math.ceil(this.duration)>this.duration&&(e=this.duration<=this.getCurrentTime(),this.duration=Math.ceil(this.duration),this.notifications.publish("durationUpdated",this.duration),e&&(this.setCurrentTime(this.duration),this.notifications.publish("timeUpdate",[this.duration])))),this.notifications.publish("recordingStatesComplete")),this.duration=this.calcDuration())}},{key:"addCurrentStateAsReference",value:function(){var t;"recording"===this.state&&(this.referenceIndex+=1,this.reference="ref".concat(this.referenceIndex),t=this.figure.getState({precision:this.precision,ignoreShown:!0}),null!=this.worker?this.worker.postMessage({message:"addReference",payload:{state:t,refName:this.reference,basedOn:"__base"}}):this.states.addReference(t,this.reference))}},{key:"getCacheStartTime",value:function(){var t=this,e=null;return 0<this.statesCache.diffs.length&&(e=this.statesCache.diffs[0][0]),Object.keys(this.eventsCache).forEach((function(n){0<(n=t.eventsCache[n]).list.length&&(n=zo(n.list[0],1)[0],e=null==e?n:Math.min(n,e))})),e}},{key:"getCacheEndTime",value:function(){return this.calcDuration(!0)}},{key:"getMergedCacheArray",value:function(t,e){var n=this.startRecordingTime,i=this.currentTime;if(null==n||0===i)return[];var r=Go(t,n);-1<r&&t[r][0]===n&&(r=Ho(t,r)-1)<0&&(r=-1);var o=Vo(t,i);return-1<o&&t[o][0]===i&&(o=Ko(t,o)+1)>t.length-1&&(o=-1),n=[],i=[],0<=r&&(n=t.slice(0,r+1)),0<=o&&(i=t.slice(o)),[].concat(Wo(n),Wo(e),Wo(i))}},{key:"mergeEventsCache",value:function(){var t=this,e={};Object.keys(this.events).forEach((function(t){e[t]=null})),Object.keys(this.eventsCache).forEach((function(t){e[t]=null})),Object.keys(e).forEach((function(e){var n=[];null!=t.eventsCache[e]&&(n=t.eventsCache[e].list);var i=[];null!=t.events[e]&&(i=t.events[e].list),0!==(n=t.getMergedCacheArray(i,n)).length&&(t.events[e].list=n)}))}},{key:"mergeStatesCache",value:function(){var t;!this.recordingStates||0!==(t=this.getMergedCacheArray(this.states.diffs,this.statesCache.diffs)).length&&(this.states.diffs=t,this.states.references=st(this.statesCache.references))}},{key:"stopTimeouts",value:function(){this.timeKeeper.clearTimeout(this.timeoutID),this.timeKeeper.clearTimeout(this.timeUpdatesTimeoutID),this.timeoutID=null,this.timeUpdatesTimeoutID=null}},{key:"stopRecording",value:function(){this.setCurrentTime(this.getCurrentTime()),this.state="idle",this.stopTimeouts(),null!=this.worker&&this.worker.postMessage({message:"get"}),this.audio&&(this.audio.pause(),this.isAudioPlaying=!1),this.lastSeekTime=null,this.notifications.publish("recordingStopped")}},{key:"stopStatesRecording",value:function(){this.stopRecording(),this.figure.timeKeeper.endManualFrames()}},{key:"addEventType",value:function(t,e){this.events[t]={setOnSeek:!(2<arguments.length&&void 0!==arguments[2])||arguments[2],list:[],playbackAction:e},this.eventIndex[t]=-1}},{key:"recordState",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.getCurrentTime();(null==this.lastRecordTime||e>this.lastRecordTime)&&(this.lastRecordTime=e,this.lastRecordTimeCount=0),null!=this.worker&&this.worker.postMessage({message:"add",payload:{now:e,state:t,reference:this.reference,lastRecordTimeCount:this.lastRecordTimeCount}}),this.lastRecordTimeCount+=1,e>this.duration&&!1===this.figure.timeKeeper.manual&&(this.duration=e,this.notifications.publish("durationUpdated",this.duration))}},{key:"recordCurrentState",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getCurrentTime(),e=this.figure.getState({precision:this.precision,ignoreShown:!0});this.recordState(e,t)}},{key:"recordCurrentStateAsReference",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"__base",n=this.figure.getState({precision:this.precision,ignoreShown:!0});null!=this.worker&&this.worker.postMessage({message:"addReference",payload:{state:n,refName:t,basedOn:e}})}},{key:"recordEvent",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.getCurrentTime();null!=this.events[t]&&(null==this.eventsCache[t]&&(this.eventsCache[t]={list:[]}),(null==this.lastRecordTime||n>this.lastRecordTime)&&(this.lastRecordTime=n,this.lastRecordTimeCount=0),this.eventsCache[t].list.push([n,e,this.lastRecordTimeCount]),this.lastRecordTimeCount+=1,n>this.duration&&!1===this.figure.timeKeeper.manual&&(this.duration=n,this.notifications.publish("durationUpdated",this.duration)))}},{key:"queueRecordState",value:function(){function t(){"recording"===e.state&&(e.recordCurrentState(),e.queueRecordState(e.stateTimeStep-e.getCurrentTime()%e.stateTimeStep))}var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;0!==d(n,10)?this.timeoutID=this.timeKeeper.setTimeout((function(){t()}),d(1e3*n,10),"state",!0):t()}},{key:"save",value:function(){var t=(new Date).toISOString().split(".")[0].split("-").join("_"),e=window.location.pathname.split("/").slice(1,-1).join("_"),n={states:this.encodeStates(),events:this.encodeEvents()};Rt("".concat(t,"_").concat(e,".json"),JSON.stringify(n))}},{key:"show",value:function(){function t(t){return(t=(t=JSON.stringify(t,null,2)).replace(/\n/g,"<br>")).replace(/ /g,"&nbsp")}var e=window.open("about:blank","","_blank");e.document.write("<br><br>"),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("<br><br>"),e.document.write(t(this.events),"<br>"),e.document.write("<br><br>"),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("<br><br>"),e.document.write(t(this.states.diffs),"<br>"),e.document.write(t(this.states.references),"<br>")}},{key:"genAutoMouseEvents",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"figure",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]&&!arguments[2]?"".concat(t,".recorder.loadEventData('_autoCursorMove', [\n").concat(this.showEvent("cursorMove",e,2),"\n], false, 2, 2);"):"".concat(t,".recorder.loadEventData('_autoCursorMove', ").concat(this.encodeCursorEvent("cursorMove",e,e),", 'cursor', 2, 2);");return"\n".concat(t,".recorder.loadEventData('_autoCursor', [\n").concat(this.showEvent("cursor",e,2),",\n]);\n").concat(t,".recorder.loadEventData('_autoTouch', [\n").concat(this.showEvent("touch",e,2),",\n]);\n").concat(n,"\n ")}},{key:"showEvent",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=[];return this.events[t].list.forEach((function(t){t=(o=zo(t,2))[0];var r,o=o[1],a=Array.isArray(o)?(a="",r=[],o.forEach((function(t){"string"==typeof t?r.push("'".concat(t,"'")):r.push(d(t,e))})),r.join(", ")):o;i.push("".concat(Array(n+1).join(" "),"[").concat(d(t,4),", [").concat(a,"]]"))})),i.join(",\n")}},{key:"encodeCursorEvent",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:.01,r=[],o=this.events[t].list[0][0],a=0,s=null;return this.events[t].list.forEach((function(t){t=(l=zo(t,2))[0];var l=l[1],u=(t=d(t-o,e),l.map((function(t){return d(t,n)})));if(null==s)return s=u,a=t,void r.push.apply(r,[d(o,e)].concat(Wo(u)));if(!(t<=a+i)){for(var c=!0,h=0;h<u.length;h+=1)u[h]!==s[h]&&(c=!1);if(!c){for(var f=Array(u.length),p=0;p<u.length;p+=1)f[p]=Math.round((u[p]-s[p])*Math.pow(10,n));r.push.apply(r,[Math.round(d(t-a,e)*Math.pow(10,e))].concat(f)),a=t,s=u.slice()}}})),JSON.stringify(r)}},{key:"decodeCursorEvent",value:function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:2,r=e[0],o=e[1],a=e[2],s=[],l=0,u=0;u<e.length;u+=3){var c=e[u]/Math.pow(10,n),h=e[u+1],f=e[u+2];0===u?s.push([r,[h,f]]):(h=o+h/Math.pow(10,i),f=a+f/Math.pow(10,i),s.push([r+l+c,[o=h,a=f]]),l+=c)}return s}},{key:"decodeEvent",value:function(t,e){for(var n=e[0],i=[],r=0,o=0;o<e.length;o+=3){var a=e[o],s=e[o+1],l=e[o+2];0===o?i.push([n,[s,l]]):(i.push([n+r+a,[s,l]]),r+=a)}return i}},{key:"loadEventData",value:function(t,e){var n,i=this,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:2,a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:2;r?!0===r?(n=this.events[t].list).push.apply(n,Wo(this.decodeEvent(t,e))):"cursor"===r&&(r=this.events[t].list).push.apply(r,Wo(this.decodeCursorEvent(t,e,o,a))):(e=e.map((function(t){return[i.convertTime(t[0]),t[1],0]})),(t=this.events[t].list).push.apply(t,Wo(e)))}},{key:"seekToPercent",value:function(t){var e=this.calcDuration();this.seek(e*t)}},{key:"convertTime",value:function(t){var e;return"string"==typeof t?(e=t.split(":"),60*parseInt(e[0],10)+parseFloat(e[1])):t}},{key:"queueSeek",value:function(t){var e=this;this.queueSeekTime=t,this.figure.timeKeeper.clearTimeout(this.queueSeekId),this.queueSeekId=this.figure.timeKeeper.setTimeout((function(){e.seek(e.queueSeekTime)}),100)}},{key:"seek",value:function(t){this.figure.timeKeeper.clearTimeout(this.queueSeekId),this.queueSeekId=null,(t=this.convertTime(t))<0&&(t=0),"recording"===this.state?this.stopRecording():"playing"===this.state&&this.pausePlayback("freeze"),this.pauseState=null,this.setToTime(t),this.lastSeekTime=this.currentTime,this.figure.stop("freeze"),this.notifications.publish("seek",t)}},{key:"setToTime",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];0===t&&0<this.states.diffs.length?this.stateIndex=0:this.stateIndex=Go(this.states.diffs,t);var i,r,o,a,s,l=0,u=0;-1!==this.stateIndex&&(i=zo(this.states.diffs[this.stateIndex],4),l=i[0],u=i[3]),l===this.lastSeekTime&&!n||(o=r=0<l?l:t,a=[],s=[],Object.keys(this.events).forEach((function(t){var n=e.events[t];if(!1!==n.setOnSeek){var i=Go(n.list,r);if(-1!==i)for(var c=Ko(n.list,Go(n.list,o)),h=i;h<=c;h+=1){var f=(d=zo(n.list[h],3))[0],d=d[2];!(-1===e.stateIndex||f<=l)||"slide"!==t&&"_autoSlide"!==t?(l<f||f===l&&u<d)&&s.push([t,h,f,d]):a.push([t,h,f,d])}}})),(t=function(t){return t.sort((function(t,e){return t[2]<e[2]||t[2]===e[2]&&t[3]<e[3]?-1:t[2]>e[2]||t[2]===e[2]&&t[3]>e[3]?1:0}))})(a),t(s),(t=function(t){t.forEach((function(t){t=(n=zo(t,2))[0];var n=n[1];e.setEvent(t,n)}))})(a),-1!==this.stateIndex&&this.setState(this.stateIndex),t(s),this.setCurrentTime(o),this.figure.animateNextFrame())}},{key:"setCursor",value:function(t){var e,n=this.getCursorState(t);null!=n&&(e=n.show,t=n.up,n=n.position,e&&t?this.figure.showCursor("up",n):e&&!1===t?this.figure.showCursor("down",n):this.figure.showCursor("hide"))}},{key:"getCursorState",value:function(t){if(null==this.events.touch||null==this.events.cursor||null==this.events.cursorMove)return null;var e,n,i,r,o,a,s=Yo([this.events.cursor.list,this.events._autoCursor.list],t),l=Yo([this.events.touch.list,this.events._autoTouch.list],t),u=Yo([this.events.cursorMove.list,this.events._autoCursorMove.list],t),c=null,h=null,f=null,d=null,p=null;return null!=l&&(e=(n=zo(l,3))[0],t=(i=zo(n[1],3))[0],l=i[1],i=i[2],n=n[2],"down"===t?(c=!1,d=e,p=n,f=new pe(l,i)):c=!0),null!=s&&(i=(a=zo(s,3))[0],s=(o=zo(a[1],3))[0],r=o[1],o=o[2],a=a[2],"show"===s?(h=!0,(null==d||d<i||i===d&&p<a)&&(d=i,p=a,f=new pe(r,o))):h=!1),null!=u&&(r=(a=zo(u,3))[0],u=(o=zo(a[1],2))[0],o=o[1],a=a[2],(null==d||d<r||r===d&&p<a)&&(f=new pe(u,o))),{show:null!=h&&h,up:null==c||c,position:null==f?new pe(0,0):f}}},{key:"getEvents",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return null!=t&&0<t.length?t:Object.keys(this.events)}},{key:"startPlayback",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.currentTime||0,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];this.notifications.publish("startingPlayback"),this.lastSeekTime=null;var r=this.convertTime(e);(null==e||e>=this.duration)&&(this.seek(0),r=0),this.eventsToPlay=this.getEvents(i),i=this.getStateForTime(r),n&&null!=this.pauseState&&(i=this.pauseState),n=function(){function e(){t.state="playing",t.setCurrentTime(r),t.startTimeUpdates(),t.startEventsPlayback(r),t.figure.animateNextFrame(),!1===t.areEventsPlaying()&&!1===t.isAudioPlaying&&t.finishPlaying(),t.notifications.publish("playbackStarted")}null==t.pauseState?(t.setToTime(r,!0),r=t.currentTime):t.pauseState=null,t.setVideoToNowDeltaTime(r),r=t.getCurrentTime(),null!=t.audio?t.startAudioPlayback(r,e):e()},this.figure.setState(i,this.settings.play),this.figure.state.preparingToSetState?(this.state="preparingToPlay",this.notifications.publish("preparingToPlay"),this.figure.notifications.add("setState",n,1)):n()}},{key:"togglePlayback",value:function(){"recording"!==this.state&&("idle"!==this.state?this.pausePlayback():this.resumePlayback())}},{key:"getPlaySettings",value:function(){var t,e={how:"instant",maxDuration:6,velocity:{position:2,rotation:2*Math.PI/2,scale:1,opacity:.8,color:.8},allDurationsSame:!0,zeroDurationThreshold:1e-5,duration:0};return"string"==typeof this.settings.play?e.how=this.settings.play:e=ct({},e,this.settings.play),"dissolve"===e.how?(t={dissolveIn:.8,dissolveOut:.8,delay:.2},0===e.duration?e.duration=t:"number"==typeof e.duration?e.duration={dissolveOut:e.duration/10*4.5,dissolveIn:e.duration/10*4.5,delay:e.duration/10*1}:e.duration=ct({},t,e.duration)):null!=e.duration&&"number"!=typeof e.duration&&(e.duration=1),e}},{key:"resumePlayback",value:function(){this.startPlayback(this.currentTime,!0)}},{key:"audioStarted",value:function(){null!=this.audioStartedCallback&&(this.audioStartedCallback(),this.audioStartedCallback=null)}},{key:"audioEnded",value:function(){this.isAudioPlaying=!1,"playing"===this.state&&this.finishPlaying()}},{key:"startAudioPlayback",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=this.audio;if(null!=n){if(this.isAudioPlaying=!0,void 0===n.play())return!1;n.currentTime=this.convertTime(t),this.audioStartedCallback=e}return!0}},{key:"startTimeUpdates",value:function(){var t=this;this.timeUpdatesTimeoutID=this.timeKeeper.setTimeout((function(){t.setCurrentTime(t.getCurrentTime()),t.notifications.publish("timeUpdate",[t.getCurrentTime()]),t.startTimeUpdates()}),this.timeUpdates,"timeUpdates")}},{key:"startEventsPlayback",value:function(t){var e=this;this.eventsToPlay.forEach((function(n){var i,r;null!=e.events[n]&&0!==e.events[n].list.length&&(-1===(r=Vo((i=e.events[n]).list,t))||(r=zo(i.list[r],1)[0]===t?Ko(i.list,r)+1:r)>i.list.length-1?e.eventIndex[n]=-1:e.eventIndex[n]=r)}));var n=this.getNextEvent();null!=this.events[n]&&this.playbackEvent(n)}},{key:"getNextEvent",value:function(){var t=this,e="",n=null,i=null;return this.eventsToPlay.forEach((function(r){var o,a;null==t.eventIndex[r]||-1===t.eventIndex[r]||t.events[r].list.length<=t.eventIndex[r]||(o=(a=zo(t.events[r].list[t.eventIndex[r]],3))[0],a=a[2],(null==n||o<n||o===n&&a<i)&&(n=o,i=a,e=r))})),e}},{key:"playbackEvent",value:function(t){var e=this.eventIndex[t];if(0!==this.events[t].list.length){var n=d(this.events[t].list[e][0]-this.getCurrentTime(),8);if(1e-4<n)this.timeoutID=this.timeKeeper.setTimeout(this.playbackEvent.bind(this,t),d(Math.ceil(1e3*n),0),"event: ".concat(t));else{if(this.setEvent(t,e),this.figure.animateNextFrame(),e+1===this.events[t].list.length){if(!(this.eventIndex[t]=-1)===this.areEventsPlaying()&&!1===this.isAudioPlaying)return void this.finishPlaying()}else this.eventIndex[t]=e+1;null!=(e=this.getNextEvent())&&this.events[e]&&this.playbackEvent(e)}}}},{key:"areEventsPlaying",value:function(){for(var t=0;t<this.eventsToPlay.length;t+=1){var e=this.eventsToPlay[t];if(this.eventIndex[e]<this.events[e].list.length&&-1<this.eventIndex[e])return!0}return!1}},{key:"finishPlaying",value:function(){var t=this;if("recording"===this.state)return!1;if(this.areEventsPlaying())return!1;var e=this.duration-this.getCurrentTime();return.001<e?(this.timeoutID=this.timeKeeper.setTimeout((function(){t.finishPlaying()}),d(1e3*e,0),"finishPlaying"),!1):!this.isAudioPlaying&&(this.setCurrentTime(this.getCurrentTime()),this.stop(),!0)}},{key:"stop",value:function(){this.stopTimeouts(),this.audio&&(this.audio.pause(),this.isAudioPlaying=!1),this.state="idle",this.notifications.publish("playbackStopped")}},{key:"pausePlayback",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.settings.pause;this.notifications.publish("startingPause"),this.setCurrentTime(this.getCurrentTime()),this.pauseState=this.figure.getState({precision:this.precision,ignoreShown:!0}),this.stopTimeouts(),this.audio&&(this.state="preparingToPause",this.audio.pause(),this.isAudioPlaying=!1),this.figure.notifications.add("stopped",(function(){t.state="idle",t.notifications.publish("playbackStopped")}),1),this.figure.stop(e),this.figure.state.preparingToStop&&(this.notifications.publish("preparingToPause"),this.state="preparingToPause")}},{key:"setEvent",value:function(t,e){null!=(t=this.events[t])&&(this.figure.setDrawTimeout(.05),t.playbackAction(t.list[e][1],t.list[e][0]))}},{key:"loadVideoTrack",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){};fetch(t,{mode:"no-cors"}).then((function(t){return t.json()})).then((function(t){e.loadSavedData(t),n()})).catch((function(t){throw new Error("Recorder fetch and load error: ".concat(t))}))}},{key:"setState",value:function(t){t>this.states.diffs.length-1||null!=(t=this.states.getFromIndex(t))&&this.figure.setState(t)}},{key:"getState",value:function(t){return t>this.states.diffs.length-1?{}:this.states.getFromIndex(t)}},{key:"getStateForTime",value:function(t){return t=this.convertTime(t),t=0<this.states.diffs.length&&(0===t||t<=this.states.diffs[0][0])?0:Go(this.states.diffs,t),this.getState(t)}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}(),$o=function(){function t(){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.location=new pe(0,0),this.type="drawingObject"}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,[{key:"_dup",value:function(){return this}},{key:"setText",value:function(t){}},{key:"update",value:function(t){}},{key:"drawWithTransformMatrix",value:function(t,e,n){}},{key:"getLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?this.location:this.getLocation().transformBy(t)}},{key:"getPointCountForAngle",value:function(){return 0}},{key:"updateVertices",value:function(t){}},{key:"updateBuffer",value:function(t,e){}},{key:"updateUniform",value:function(t,e){}},{key:"getUniform",value:function(t){}},{key:"change",value:function(t){}},{key:"_getStateProperties",value:function(){return[]}},{key:"_state",value:function(t){return ci(this,this._getStateProperties(),t)}}]),t}();function Qo(t){return(Qo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Jo(t,e){return(Jo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Zo(t){return(Zo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const ta=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Jo(t,e)}(r,$o);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Zo(e);return function(t,e){if(e&&("object"===Qo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Zo(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e,n){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"middle",a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"center";!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var s=i.call(this),l=document.getElementById(e);return l&&(s.element=l),s.id=e,s.location=n,s.yAlign=o,s.xAlign=a,s.parentDiv=t,s.show=!0,s.setBorder(),s.lastMatrix=[0,0,0,0,0,0,0,0,0],s.lastColor=[-1,-1,-1,-1],s}return t=[{key:"_dup",value:function(){var t=new r(this.parentDiv,this.id,this.location._dup(),this.yAlign,this.xAlign);return t.show=this.show,t.border=this.border.map((function(t){return t.map((function(t){return t._dup()}))})),t}},{key:"setBorder",value:function(){var t=this.parentDiv.getBoundingClientRect(),e=this.element.getBoundingClientRect(),n=e.left-t.left,i=n+e.width,r=e.top-t.top;t=r+e.height,(e=[]).push(new pe(n,r)),e.push(new pe(i,r)),e.push(new pe(i,t)),e.push(new pe(n,t)),this.border=[],this.border.push(e)}},{key:"getBoundaries",value:function(){var t=Ce({x:{bottomLeft:0,width:(o=this.parentDiv.getBoundingClientRect()).width},y:{bottomLeft:o.height,height:-o.height}},{x:{bottomLeft:-1,width:2},y:{bottomLeft:-1,height:2}}),e=this.element.getBoundingClientRect(),n=e.left-o.left,i=n+e.width,r=e.top-o.top,o=r+e.height;return(e=[]).push(new pe(n,r)),e.push(new pe(i,r)),e.push(new pe(i,o)),e.push(new pe(n,o)),[e.map((function(e){return e.transformBy(t.matrix())}))]}},{key:"glToPixelSpace",value:function(t){var e=(t.x- -1)/2*this.parentDiv.clientWidth;return t=(1-t.y)/2*this.parentDiv.clientHeight,new pe(e,t)}},{key:"change",value:function(t,e){var n=t;"string"==typeof t&&((n=document.createElement("div")).innerHTML=t),n instanceof HTMLElement&&(this.element.innerHTML="",this.element.appendChild(n),this.transformHtml(e))}},{key:"transformHtml",value:function(t){var e,n,i,r,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;this.show?(r=this.location.transformBy(t),e=this.glToPixelSpace(r),n=this.element.clientWidth,i=this.element.clientHeight,r=t=0,"center"===this.xAlign?t=-n/2:"right"===this.xAlign&&(t=-n),"middle"===this.yAlign?r=-i/2:"bottom"===this.yAlign&&(r=-i),t=e.x+t,r=e.y+r,(r="position: absolute; left: ".concat(t,"px; top: ").concat(r,"px; visibility: visible; opacity: ").concat(o,";"))!==this.element.getAttribute("style")&&this.element.setAttribute("style",r)):this.element.setAttribute("style","position: absolute; left: -10000px; top: -10000px; visibility: hidden; opacity: ".concat(o,";"))}},{key:"drawWithTransformMatrix",value:function(t,e){for(var n=!1,i=0;i<t.length;i+=1)d(t[i],8)!==this.lastMatrix[i]&&(n=!0);!n&&this.lastColor[3]===d(e[3],8)||(this.transformHtml(t,e[3]),this.lastMatrix=d(t,8),this.lastColor=d(e,8))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function ea(t){return(ea="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function na(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ia(t,e,n){return(ia="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=oa(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ra(t,e){return(ra=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function oa(t){return(oa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const aa=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ra(t,e)}(r,$o);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=oa(e);return function(t,e){if(e&&("object"===ea(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=oa(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"withTexture",o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"withTexture";return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),(e=i.call(this)).gl=t.gl,e.glPrimitive=e.gl.TRIANGLES,e.webgl=t,e.z=0,e.programIndex=e.webgl.getProgram(n,o),e.type="glPrimitive",e.buffers={},e.numVertices=0,e.uniforms={},e.texture=null,e}return t=[{key:"setPrimitive",value:function(t){if("TRIANGLES"===t)this.glPrimitive=this.gl.TRIANGLES;else if("LINES"===t)this.glPrimitive=this.gl.LINES;else if("TRIANGLE_FAN"===t)this.glPrimitive=this.gl.TRIANGLE_FAN;else if("TRIANGLE_STRIP"===t)this.glPrimitive=this.gl.TRIANGLE_STRIP;else if("POINTS"===t)this.glPrimitive=this.gl.POINTS;else if("LINE_LOOP"===t)this.glPrimitive=this.gl.LINE_LOOP;else{if("LINE_STRIP"!==t)throw new Error("Primitive type can only be ['TRIANGLES' | 'POINTS' | 'TRIANGLE_FAN' | 'TRIANGLE_STRIP' | 'LINES' | 'LINE_LOOP' | 'LINE_STRIP']. Input primitive type was: '".concat(t,"'"));this.glPrimitive=this.gl.LINE_STRIP}}},{key:"setZ",value:function(t){this.z=t}},{key:"addTextureToBuffer",value:function(t,e,n){function i(t){return 0==(t&t-1)}var r=this.texture,o=this.gl,a=this.webgl;null!=r&&(r=a.textures[r.id].index,o.activeTexture(o.TEXTURE0+r),o.bindTexture(o.TEXTURE_2D,t),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,e),i(e.width)&&i(e.height)?(o.generateMipmap(o.TEXTURE_2D),null!=n&&!0===n?(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.REPEAT),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.REPEAT)):(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE))):(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE)))}},{key:"updateTextureMap",value:function(){var t=this.texture;null!=t&&(null!=t.buffer&&(this.gl.deleteBuffer(t.buffer),t.buffer=this.gl.createBuffer()),this.createTextureMap(t.mapTo.left,t.mapTo.right,t.mapTo.bottom,t.mapTo.top,t.mapFrom.left,t.mapFrom.right,t.mapFrom.bottom,t.mapFrom.top),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t.buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(t.points),this.gl.STATIC_DRAW))}},{key:"addTexture",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new fe(-1,-1,2,2),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new fe(0,0,1,1),r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;null==this.texture&&(this.texture={id:t,mapTo:n,mapFrom:i,repeat:r,src:t,points:[],buffer:this.gl.createBuffer(),type:"image",data:null}),null!=o&&(this.onLoad=o);var a,s,l=this.texture,u=(t=this.gl,this.webgl);null!=l&&(this.updateTextureMap(),!(l.id in u.textures)||l.id in u.textures&&null==u.textures[l.id].glTexture?(a=t.createTexture(),u.addTexture(l.id,a,l.type),t.activeTexture(t.TEXTURE0+u.textures[l.id].index),t.bindTexture(t.TEXTURE_2D,a),(o=l.src)&&null==l.data?(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([0,0,0,0])),(s=new Image).src=o,this.state="loading",u.textures[l.id].state="loading",u.textures[l.id].onLoad.push(this.executeOnLoad.bind(this)),s.addEventListener("load",(function(){l.data=s,e.addTextureToBuffer(a,l.data,l.repeat),u.onLoad(l.id),e.state="loaded",u.textures[l.id].state="loaded"}))):null!=l.data&&this.addTextureToBuffer(a,l.data,l.repeat)):l.id in u.textures&&("loading"===u.textures[l.id].state?(this.state="loading",u.textures[l.id].onLoad.push(this.executeOnLoad.bind(this))):this.state="loaded"))}},{key:"createTextureMap",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:1,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,s=e-t,l=i-n,u=o-r,c=(7<arguments.length&&void 0!==arguments[7]?arguments[7]:1)-a,h=this.texture;if(null!=h){h.points=[];for(var f=0;f<this.points.length;f+=2){var d=this.points[f],p=(this.points[f+1]-n)/l;h.points.push((d-t)/s*u+r),h.points.push(p*c+a)}}}},{key:"addVertices",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"STATIC";this.points=t,this.addBuffer("a_position",2,t,"FLOAT",!1,0,0,e),this.numVertices=t.length/2}},{key:"addBuffer",value:function(t,e,n){var i,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"FLOAT",o=4<arguments.length&&void 0!==arguments[4]&&arguments[4],a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,l=this.gl,u=l.STATIC_DRAW;if("DYNAMIC"===(7<arguments.length&&void 0!==arguments[7]?arguments[7]:"STATIC")&&(u=l.DYNAMIC_DRAW),"FLOAT"===r)i=l.FLOAT;else if("UNSIGNED_BYTE"===r)i=l.UNSIGNED_BYTE;else if("BYTE"===r)i=l.BYTE;else if("SHORT"===r)i=l.SHORT;else{if("UNSIGNED_SHORT"!==r)throw new Error('GLObject addBuffer usage needs to be FLOAT, BYTE, SHORT, UNSIGNED_BYTE or UNSIGNED_SHORT - received: "'.concat(r,'"'));i=l.UNSIGNED_SHORT}this.buffers[t]={buffer:null,size:e,type:i,normalize:o,stride:a,offset:s,usage:u},this.fillBuffer(t,n)}},{key:"fillBuffer",value:function(t,e){var n,i=this.gl,r=(o=this.buffers[t]).type,o=o.usage;r===i.FLOAT?n=new Float32Array(e):r===i.UNSIGNED_BYTE?n=new Uint8Array(e):r===i.BYTE?n=new Int8Array(e):r===i.SHORT?n=new Int16Array(e):r===i.UNSIGNED_SHORT&&(n=new Uint16Array(e)),this.buffers[t].buffer=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,this.buffers[t].buffer),i.bufferData(i.ARRAY_BUFFER,n,o)}},{key:"executeOnLoad",value:function(){null!=this.onLoad&&this.onLoad()}},{key:"resetTextureBuffer",value:function(){var t=this.texture,e=this.webgl,n=this.gl;t&&(null!=e.textures[t.id].glTexture&&(n.activeTexture(n.TEXTURE0+e.textures[t.id].index),n.bindTexture(n.TEXTURE_2D,null),e.textures[t.id].glTexture=null),null!=t.buffer&&(n.deleteBuffer(t.buffer),t.buffer=null))}},{key:"resetBuffers",value:function(){var t=this,e=this.gl;Object.keys(this.buffers).forEach((function(n){e.deleteBuffer(t.buffers[n].buffer),t.buffers[n].buffer=null})),this.buffers={},this.resetTextureBuffer()}},{key:"updateVertices",value:function(t){this.points=t,this.numVertices=t.length/2,this.updateBuffer("a_position",t)}},{key:"updateBuffer",value:function(t,e){this.gl.deleteBuffer(this.buffers[t].buffer),this.buffers[t].buffer=null,this.fillBuffer(t,e)}},{key:"_getStateProperties",value:function(){return function(t){if(Array.isArray(t))return na(t)}(t=ia(oa(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return na(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?na(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var t}},{key:"getUniform",value:function(t){return this.uniforms[t].value}},{key:"addUniform",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"FLOAT",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;this.uniforms[t]={value:Array(e).fill(0),method:this["uploadUniform".concat(e.toString()).concat(n[0].toLowerCase()).concat(n.endsWith("VECTOR")?"v":"")].bind(this)},null!=i&&this.updateUniform(t,i)}},{key:"uploadUniform1f",value:function(t,e){this.gl.uniform1f(t,this.uniforms[e].value[0])}},{key:"uploadUniform2f",value:function(t,e){this.gl.uniform2f(t,this.uniforms[e].value[0],this.uniforms[e].value[1])}},{key:"uploadUniform3f",value:function(t,e){this.gl.uniform3f(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2])}},{key:"uploadUniform4f",value:function(t,e){this.gl.uniform4f(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2],this.uniforms[e].value[3])}},{key:"uploadUniform1fv",value:function(t,e){this.gl.uniform1fv(t,this.uniforms[e].value)}},{key:"uploadUniform2fv",value:function(t,e){this.gl.uniform2fv(t,this.uniforms[e].value)}},{key:"uploadUniform3fv",value:function(t,e){this.gl.uniform3fv(t,this.uniforms[e].value)}},{key:"uploadUniform4fv",value:function(t,e){this.gl.uniform4fv(t,this.uniforms[e].value)}},{key:"uploadUniform1iv",value:function(t,e){this.gl.uniform1iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform2iv",value:function(t,e){this.gl.uniform2iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform3iv",value:function(t,e){this.gl.uniform3iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform4iv",value:function(t,e){this.gl.uniform4iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform1i",value:function(t,e){this.gl.uniform1i(t,this.uniforms[e].value[0])}},{key:"uploadUniform2i",value:function(t,e){this.gl.uniform2i(t,this.uniforms[e].value[0],this.uniforms[e].value[1])}},{key:"uploadUniform3i",value:function(t,e){this.gl.uniform3i(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2])}},{key:"uploadUniform4i",value:function(t,e){this.gl.uniform4i(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2],this.uniforms[e].value[3])}},{key:"updateUniform",value:function(t,e){this.uniforms[t].value=Array.isArray(e)?e:[e]}},{key:"drawWithTransformMatrix",value:function(t,e){var n=this,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.numVertices,r=this.gl,o=this.webgl,a=o.useProgram(this.programIndex);r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),Object.keys(this.buffers).forEach((function(t){var e=(u=n.buffers[t]).buffer,i=u.size,o=u.type,s=u.stride,l=u.offset,u=u.normalize;r.enableVertexAttribArray(a[t]),r.bindBuffer(r.ARRAY_BUFFER,e),r.vertexAttribPointer(a[t],i,o,u,s,l)})),r.uniformMatrix3fv(a.u_matrix,!1,Lt(t)),Object.keys(this.uniforms).forEach((function(t){(0,n.uniforms[t].method)(a[t],t)})),r.uniform1f(a.u_z,this.z),r.uniform4f(a.u_color,e[0],e[1],e[2],e[3]),null!=(t=this.texture)?(e=r.FLOAT,r.enableVertexAttribArray(a.a_texcoord),r.bindBuffer(r.ARRAY_BUFFER,t.buffer),r.vertexAttribPointer(a.a_texcoord,2,e,!1,0,0),r.uniform1i(a.u_use_texture,1),o=o.textures[t.id].index,r.uniform1i(a.u_texture,o)):r.uniform1i(a.u_use_texture,0),r.drawArrays(this.glPrimitive,0,i),t&&r.disableVertexAttribArray(a.a_texcoord),Object.keys(this.buffers).forEach((function(t){r.disableVertexAttribArray(a[t])}))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function sa(t){return function(t){if(Array.isArray(t))return la(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return la(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?la(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function la(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ua(t,e){var n=ct({},{to:[]},e);n.to instanceof Ee&&(n.to=[e.to]);for(var i=[],r=0;r<n.to.length;r+=1)!function(e){var r=n.to[e].matrix();i=[].concat(sa(i),sa(t.map((function(t){return t.transformBy(r)}))))}(r);return i}function ca(t,e){var n={},i=0,r=ce(t);return null==e?r:(t=[],t=Array.isArray(e)?e:[e],n[0]=0,t.forEach((function(t,e){var o;n["".concat(e+1)]=r.length,"string"==typeof t?n[t]=r.length:(o="to",null!=(e=ct({},{start:i,end:"end",original:!0},t)).along&&(o=e.along),t=function(t,e,n,i){var r=[],o=(e=i["".concat(e)],"end"===n?t.length:i["".concat(n)]);null==o&&(o=t.length);for(var a=e;a<o;a+=1)r.push(t[a]._dup());return r}(r,e.start,e.end,n),!1===e.original&&(i=r.length),r=[].concat(sa(r),sa("linear"===o||"x"===o||"y"===o||"number"==typeof o?function(t,e){if(null==e.along)return[];var n=0,i=ct({},{num:1},e);"y"===i.along?n=Math.PI/2:"x"===i.along?n=0:"number"==typeof i.along&&(n=i.along),null==i.step&&(e=Ie(t),i.step=Math.abs(e.height/Math.sin(n)));for(var r=[],o=1;o<i.num+1;o+=1)!function(e){var o=i.step*e;r=[].concat(sa(r),sa(t.map((function(t){return t.add(Re(o,n))}))))}(o);return r}(t,e):"to"===o?null==e.to||Array.isArray(e.to)&&0===e.to.length?t:(e.to instanceof Ee||Array.isArray(e.to)&&e.to[0]instanceof Ee?ua:function(t,e){var n=ct({},{to:[]},e);n.to=ce(n.to);for(var i=0,r=Array(n.to.length*t.length),o=0;o<n.to.length;o+=1)for(var a=0;a<t.length;a+=1)r[i]=new pe(t[a].x+n.to[o].x,t[a].y+n.to[o].y),i+=1;return r})(t,e):"rotation"===o?function(t,e){var n=ct({},{num:1,step:Math.PI/4,center:[0,0]},e);n.center=ue(n.center);for(var i=[],r=n.center,o=1;o<n.num+1;o+=1)!function(e){var o=(new Ee).translate(-r.x,-r.y).rotate(e*n.step).translate(r.x,r.y).matrix();i=[].concat(sa(i),sa(t.map((function(t){return t.transformBy(o)}))))}(o);return i}(t,e):t)))})),sa(r.slice(i)))}function ha(t){return(ha="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function fa(t,e){return(fa=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function da(t,e){if(e&&("object"===ha(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}function pa(t){return(pa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const ma=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&fa(t,e)}(i,aa);var t,e,n=(t=i,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,i=pa(t);return da(this,e?(n=pa(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))});function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new fe(-1,-1,2,2),o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new fe(0,0,1,1),a=4<arguments.length&&void 0!==arguments[4]&&arguments[4];return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),(t=""!==e?n.call(this,t,"withTexture","withTexture"):n.call(this,t,"simple","simple")).points=[],t.copy=[],t.addVertices([]),""!==e&&t.addTexture(e,r,o,a),da(t)}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,[{key:"getPointCountForAngle",value:function(){return 0<arguments.length&&void 0!==arguments[0]||Math.PI,this.numVertices}},{key:"getPointCountForLength",value:function(t){return this.numVertices}},{key:"change",value:function(t){var e=t.points,n=t.drawType,i=t.copy,r=t.texture;t=this.numVertices,null!=e&&(this.vertices=e),null!=n&&(this.glPrimitive="lines"===n?this.gl.LINES:"strip"===n?this.gl.TRIANGLE_STRIP:"fan"===n?this.gl.TRIANGLE_FAN:this.gl.TRIANGLES),null!=i&&(this.copy=i);for(var o=ca(this.vertices,this.copy),a=Array(2*o.length),s=0;s<o.length;s+=1)a[2*s]=o[s].x,a[2*s+1]=o[s].y;this.updateVertices(a),null!=this.texture&&this.numVertices!==t&&this.updateTextureMap(),null!=r&&(null!=r.mapTo&&(r.mapTo=de(r.mapTo)),null!=r.mapFrom&&(r.mapFrom=de(r.mapFrom)),this.texOptions=ct({},this.texOptions,r),this.updateTextureMap())}}]),i}();function ya(t){return(ya="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function va(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Aa(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ga(t,e,n){return(ga="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Sa(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ba(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&wa(t,e)}function wa(t,e){return(wa=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function xa(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=Sa(t);return function(t,e){if(e&&("object"===ya(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Sa(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function Sa(t){return(Sa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ta(t){return function(t){if(Array.isArray(t))return ka(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Aa(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Aa(t,e){if(t){if("string"==typeof t)return ka(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ka(t,e):void 0}}function ka(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Oa(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _a(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Pa(t,e,n){return e&&_a(t.prototype,e),n&&_a(t,n),t}var Ea=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(Oa(this,t),e instanceof t)return this.family=e.family,this.style=e.style,this.size=e.size,this.weight=e.weight,this.opacity=e.opacity,this.setColor(e.color),this.width=e.width,this.descent=e.descent,this.midDescent=e.midDescent,this.maxDescent=e.maxDescent,this.midAscent=e.midAscent,void(this.maxAscent=e.maxAscent);e=ct({},{family:"Times New Roman",style:"normal",size:1,weight:"200",color:null,opacity:1,width:1,descent:.08,midDescent:.2,maxDescent:.5,midAscent:.95,maxAscent:1.4},e),this.family=e.family,this.style=e.style,this.size=e.size,this.weight=e.weight,this.opacity=e.opacity,this.setColor(e.color),this.width=e.width,this.descent=e.descent,this.midDescent=e.midDescent,this.maxDescent=e.maxDescent,this.midAscent=e.midAscent,this.maxAscent=e.maxAscent}return Pa(t,[{key:"setColor",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.color=null==t?t:t.slice()}},{key:"definition",value:function(){var t=null==(t=this.color)?t:t.slice();return{family:this.family,style:this.style,size:this.size,weight:this.weight,color:t,opacity:this.opacity,width:this.width,descent:this.descent,midDescent:this.midDescent,maxDescent:this.maxDescent,midAscent:this.midAscent,maxAscent:this.maxAscent}}},{key:"setFontInContext",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;t.font="".concat(this.style," ").concat(this.weight," ").concat(this.size*e,"px ").concat(this.family)}},{key:"setColorInContext",value:function(t,e){var n=this.color;null!=n?(n=[].concat(Ta(n.slice(0,3)),[null!=e?e[3]:1]),t.fillStyle=Ri(n)):null!=e&&(t.fillStyle=Ri(e))}},{key:"_dup",value:function(){return new t({family:this.family,style:this.style,size:this.size,weight:this.weight,color:this.color,opacity:this.opacity})}}]),t}(),Ma=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new pe(0,0),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new Ea).definition(),o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"left",a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"baseline",s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;Oa(this,t),this.location=ue(n)._dup(),this.locationAligned=this.location._dup(),this.text=i.slice(),this.font=new Ea(r),this.xAlign=o,this.yAlign=a,this.lastDraw=null,this.lastDrawRect=new fe(0,0,1,1),Array.isArray(e)?this.drawContext2D=e:this.drawContext2D=[e],this.touchBorder=s,this.onClick=l}return Pa(t,[{key:"measureAndAlignText",value:function(){this.measureText(),this.alignText()}},{key:"calcBorderAndBounds",value:function(){this.calcBounds(),this.calcBorder(),this.calcTouchBorder()}},{key:"setText",value:function(t){"string"==typeof t?this.text=t.slice():(null!=t.location&&(t.location=ue(t.location)),ct(this,t)),this.measureAndAlignText(),this.calcBorderAndBounds()}},{key:"setFont",value:function(t){t=ct({},this.font.definition(),t),this.font=new Ea(t),this.measureAndAlignText()}},{key:"_dup",value:function(){return new this.constructor(this.drawContext2D,this.location,this.text,this.font.definition(),this.xAlign,this.yAlign)}},{key:"measureText",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.drawContext2D[0].ctx,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:20/this.font.size;this.font.setFontInContext(t,e);var n=t.font.match(/[^ ]*px/),i=null!=n?parseFloat(n[0])/2:t.measureText("a").width,r=i*this.font.maxAscent,o=i*this.font.descent,a=/[gjyqp@Q(){}[\]|]/g;return"Times New Roman"===this.font.family&&"italic"===this.font.style&&(a=/[gjyqp@Q(){}[\]|f]/g),n=this.text.match(/[acemnorsuvwxz*gyqp: ]/g),Array.isArray(n)&&n.length===this.text.length&&(r=i*this.font.midAscent),n=this.text.match(/[;,$]/g),Array.isArray(n)&&0<n.length&&(o=i*this.font.midDescent),a=this.text.match(a),Array.isArray(a)&&0<a.length&&(o=i*this.font.maxDescent),t=t.measureText(this.text).width,this.measure={ascent:r/e,descent:o/e,width:t/e},this.measure}},{key:"alignText",value:function(){var t=this.location._dup();"center"===this.xAlign?t.x-=this.measure.width/2:"right"===this.xAlign&&(t.x-=this.measure.width),"bottom"===this.yAlign?t.y+=this.measure.descent:"middle"===this.yAlign?t.y+=this.measure.descent-(this.measure.ascent+this.measure.descent)/2:"top"===this.yAlign&&(t.y-=this.measure.ascent),this.locationAligned=t._dup()}},{key:"calcBounds",value:function(){this.bounds=new fe(this.locationAligned.x,this.locationAligned.y-this.measure.descent,this.measure.width,this.measure.ascent+this.measure.descent)}},{key:"getBoundary",value:function(t){if(null==t)return this.textBorder;var e=[];return this.textBorder.forEach((function(n){e.push(n.transformBy(t))})),e}},{key:"calcBorder",value:function(){this.textBorder=[new pe(this.bounds.left,this.bounds.bottom),new pe(this.bounds.right,this.bounds.bottom),new pe(this.bounds.right,this.bounds.top),new pe(this.bounds.left,this.bounds.top)]}},{key:"calcTouchBorder",value:function(){De(this.touchBorder)?this.textBorderBuffer=Le(this.textBorder,this.touchBorder):this.textBorderBuffer=this.touchBorder}}]),t}(),Ba=function(){ba(e,Ma);var t=xa(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new pe(0,0),r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new Ea).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"left",s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"baseline",l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;return Oa(this,e),(u=t.call(this,n,i,r,o,a,s,l,u)).measureAndAlignText(),u.calcBorderAndBounds(),u}return e}(),Ca=function(){ba(e,Ma);var t=xa(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new pe(0,0),r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new Ea).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new pe(0,0),s=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null,c=8<arguments.length&&void 0!==arguments[8]&&arguments[8],h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:0,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:0;return Oa(this,e),(u=t.call(this,n,i,r,o,"left","baseline",l,u)).offset=ue(a),u.inLine=s,u.followOffsetY=c,u.lSpace=h,u.rSpace=f,u.measureAndAlignText(),u.calcBorderAndBounds(),u}return Pa(e,[{key:"alignText",value:function(){var t=this.location._dup();this.locationAligned=t.add(this.offset)}},{key:"_dup",value:function(){return new e(this.drawContext2D,this.location,this.text,this.font.definition(),this.offset,this.inLine,this.touchBorder,this.onClick,this.followOffsetY,this.rSpace,this.lSpace)}}]),e}(),ja=function(){ba(e,Ca);var t=xa(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new pe(0,0),r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new Ea).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new pe(0,0),s=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],l=6<arguments.length?arguments[6]:void 0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:0,c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:null,h=9<arguments.length&&void 0!==arguments[9]&&arguments[9],f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:0,d=11<arguments.length&&void 0!==arguments[11]?arguments[11]:0;return Oa(this,e),(d=t.call(this,n,i,r,o,a,s,u,c,h,f,d)).line=l,d}return Pa(e,[{key:"_dup",value:function(){return new e(this.drawContext2D,this.location,this.text,this.font.definition(),this.offset,this.inLine,this.line,this.touchBorder,this.onClick,this.followOffsetY,this.lSpace,this.rSpace)}}]),e}(),Ra=function(){ba(e,$o);var t=xa(e);function e(n){var i;return Oa(this,e),i=t.call(this),Array.isArray(n)?i.drawContext2D=n:i.drawContext2D=[n],i.lastDrawTransform=[1,0,0,0,1,0,0,0,1],i.text=[],i.fixColor=!1,i}return Pa(e,[{key:"loadText",value:function(t){this.calcScalingFactor(),this.layoutText()}},{key:"setTextLocations",value:function(){}},{key:"click",value:function(t,e){this.text.forEach((function(n){null!=n.onClick&&t.isInPolygon(n.textBorderBuffer)&&e.exec(n.onClick,e)}))}},{key:"calcScalingFactor",value:function(){var t,e=1;0<this.text.length&&(t=this.text[0].font.size,this.text.forEach((function(e){0<e.font.size&&e.font.size<t&&(t=e.font.size)})),e=20/t),this.scalingFactor=e}},{key:"setText",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;this.clear(),this.text[e].setText(t),this.setBorder(),this.setTouchBorder()}},{key:"_dup",value:function(){return new e(this.drawContext2D)}},{key:"setFont",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.clear(),null===e)for(var n=0;n<this.text.length;n+=1)this.text[n].setFont(t);else this.text[e].setFont(t);this.layoutText()}},{key:"setOpacity",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.clear(),null===e)for(var n=0;n<this.text.length;n+=1)this.setFont({opacity:t},n);else this.setFont({opacity:t},e)}},{key:"setColor",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(!this.fixColor)if(null===e)for(var n=0;n<this.text.length;n+=1)this.text[n].font.color=t.slice();else this.text[e].font.color=t.slice()}},{key:"layoutText",value:function(){this.setTextLocations(),this.text.forEach((function(t){t.calcBorderAndBounds()})),this.setBorder(),this.setTouchBorder()}},{key:"setBorder",value:function(){var t=this;this.textBorder=[],this.text.forEach((function(e){t.textBorder.push(e.textBorder)}))}},{key:"setTouchBorder",value:function(){var t=this;this.textBorderBuffer=[],this.text.forEach((function(e){t.textBorderBuffer.push(e.textBorderBuffer)}))}},{key:"drawWithTransformMatrix",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[1,1,1,1],n=this.drawContext2D[0],i=this.drawContext2D[0].ctx;i.save();var r=this.scalingFactor,o=n.canvas.offsetWidth/2,a=n.canvas.offsetHeight/2,s=It([o,0,n.canvas.offsetWidth/2,0,a,n.canvas.offsetHeight/2,0,0,1],[t[0],-t[1],t[2],-t[3],t[4],-1*t[5],0,0,1]),l=It(s,[1/r,0,0,0,1/r,0,0,0,1]),u=l[0];o=l[3],a=l[1],n=l[4],t=l[2],s=l[5],i.transform(u,o,a,n,t,s),this.lastDrawTransform=l.slice();var c=e.slice();this.text.forEach((function(t){t.lastDraw={x:t.locationAligned.x*r,y:t.locationAligned.y*-r,width:t.bounds.width*r,height:t.bounds.height*r},t.font.setFontInContext(i,r),t.font.setColorInContext(i,c),i.fillText(t.text,t.locationAligned.x*r,t.locationAligned.y*-r)})),i.restore()}},{key:"clear",value:function(){var t=this.drawContext2D[0].ctx,e=this.lastDrawTransform;t.save(),t.transform(e[0],e[3],e[1],e[4],e[2],e[5]),this.text.forEach((function(e){var n,i,r,o;null!=e.lastDraw&&(n=(o=e.lastDraw).x,i=o.y,r=o.width,o=o.height,t.clearRect(n-+r,i+.5*o,3*r,2*-o),e.lastDraw=null)})),t.restore()}},{key:"_getStateProperties",value:function(){return Ta(ga(Sa(e.prototype),"_getStateProperties",this).call(this))}}]),e}(),Fa=function(){ba(e,Ra);var t=xa(e);function e(){return Oa(this,e),t.apply(this,arguments)}return Pa(e,[{key:"loadText",value:function(t){var e=this,n=t.text;Array.isArray(n)||(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor);var i=[];n.forEach((function(n){var r,o,a,s,l,u="string"==typeof n?n:(r=n.font,c=n.location,o=n.xAlign,a=n.yAlign,l=n.touchBorder,s=n.onClick,n.text),c=(n=null==c?new pe(0,0):ue(c),t.font);null!=r&&(c=r),null!=l&&Array.isArray(l)&&!De(l)&&(l=va(nn(l),1)[0]),c=ct({},t.font,c),i.push(new Ba(e.drawContext2D,n,u,c,o||t.xAlign,a||t.yAlign,l||t.defaultTextTouchBorder,s))})),this.text=i,this.calcScalingFactor(),this.layoutText()}},{key:"_dup",value:function(){var t=new e(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.layoutText(),t}}]),e}();function Da(t,e){var n=1<arguments.length&&void 0!==e?e:new pe(0,0),i=0,r=0;return t.forEach((function(t){var e;t.location=n.add(t.offset).add(t.lSpace),t.inLine&&(n=t.followOffsetY?t.location.add(t.measure.width+t.rSpace,0):t.location.add(t.measure.width+t.rSpace,-t.offset.y),e=t.location.y+t.measure.ascent,t=t.location.y-t.measure.descent,i<e&&(i=e),t<r&&(r=t))})),{width:+n.x,minY:r,maxY:i}}function Ia(t,e,n,i,r,o){var a=new pe(0,0);"center"===e?a.x-=i/2:"right"===e&&(a.x-=i),"bottom"===n?a.y-=r:"middle"===n?a.y+=-r-(o-r)/2:"top"===n&&(a.y-=o),t.forEach((function(t){t.locationAligned=t.location.add(a)}))}var La=function(){ba(e,Ra);var t=xa(e);function e(){return Oa(this,e),t.apply(this,arguments)}return Pa(e,[{key:"loadText",value:function(t){var e=this,n=t.text;Array.isArray(n)||(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor);var i=[];n.forEach((function(n){var r,o,a,s,l,u,c,h;"string"==typeof n?o=n:(c=n.font,f=n.offset,h=n.inLine,u=n.touchBorder,a=n.onClick,r=n.followOffsetY,s=n.lSpace,l=n.rSpace,o=n.text,null!=u&&Array.isArray(u)&&!De(u)&&(u=va(nn(u),1)[0])),n=null==f?new pe(0,0):ue(f);var f=t.font;null!=c&&(f=c),null==(f=ct({},t.font,f)).color&&null!=t.color&&(f.color=t.color),i.push(new Ca(e.drawContext2D,new pe(0,0),o,f,n,h,u||t.defaultTextTouchBorder,a,r,s,l))})),this.text=i,this.xAlign=t.xAlign,this.yAlign=t.yAlign,this.calcScalingFactor(),this.layoutText()}},{key:"setText",value:function(t){this.text[1<arguments.length&&void 0!==arguments[1]?arguments[1]:1].setText(t),this.layoutText()}},{key:"setTextLocations",value:function(){var t=(n=Da(this.text)).width,e=n.minY,n=n.maxY;Ia(this.text,this.xAlign,this.yAlign,t,e,n)}},{key:"_dup",value:function(){var t=new e(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.xAlign=this.xAlign,t.yAlign=this.yAlign,t.layoutText(),t}}]),e}(),Wa=function(){ba(e,Ra);var t=xa(e);function e(){return Oa(this,e),t.apply(this,arguments)}return Pa(e,[{key:"loadText",value:function(t){var e=this,n=t.text;"string"==typeof n&&(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor),this.modifiers=t.modifiers||{},this.lines=[];var i=[],r={style:"italic"};null!=t.defaultAccent&&(r=ct({},r,t.defaultAccent)),n.forEach((function(n,o){var a,s,l,u=t.justify,c=t.lineSpace,h=t.font;"string"!=typeof n?(a=n.font,s=n.justify,l=n.lineSpace,d=n.text,null!=a&&(h=ct({},{color:t.color},t.font,a)),null!=l&&(c=l),null!=s&&(u=s)):d=n;var f=[],d=(n=va(Ft(d,"|","/"),2))[0],p=n[1];d.forEach((function(n,a){var s,l,u=n,c=h,d=new pe(0,0),m=!0,y=!1,v=0,g=0;a%2===p&&(null!=(n=null!=e.modifiers[n]?e.modifiers[n]:{text:n,font:r}).text&&(u=n.text),null!=n.font&&(c=ct({},h,n.font)),null!=n.inLine&&(m=n.inLine),null!=n.offset&&(d=n.offset),null!=n.touchBorder&&null!=(l=n.touchBorder)&&Array.isArray(l)&&!De(l)&&(l=va(nn(l),1)[0]),null!=n.onClick&&(s=n.onClick),null!=n.followOffsetY&&(y=n.followOffsetY),null!=n.lSpace&&(g=n.lSpace),null!=n.rSpace&&(v=n.rSpace)),v=new ja(e.drawContext2D,new pe(0,0),u,c,d,m,o,l||t.defaultTextTouchBorder,s,y,g,v),i.push(v),f.push(v)})),e.lines.push({justify:u,space:c,text:f,width:0})})),this.text=i,this.xAlign=t.xAlign,this.yAlign=t.yAlign,this.calcScalingFactor(),this.layoutText()}},{key:"setText",value:function(t){this.text[1<arguments.length&&void 0!==arguments[1]?arguments[1]:0].setText(t),this.layoutText()}},{key:"setTextLocations",value:function(){var t=(n=this.createLines()).width,e=n.minY,n=n.maxY;Ia(this.text,this.xAlign,this.yAlign,t,e,n)}},{key:"createLines",value:function(){var t=0,e=0,n=0,i=0;return this.lines.forEach((function(r,o){0<o&&0<r.text.length?i-=r.space:0<o&&0===r.text.length&&(i-=r.space/3);var a=(s=Da(r.text,new pe(0,i))).width,s=(o=s.minY,s.maxY);e=o<e?o:e,t=t<s?s:t,n=n<a?a:n,r.width=a})),this.lines.forEach((function(t){var e=new pe(0,0);"center"===t.justify?e.x+=n/2-t.width/2:"right"===t.justify&&(e.x+=n-t.width),t.text.forEach((function(t){t.location=t.location.add(e)}))})),{width:n,minY:e,maxY:t}}},{key:"_dup",value:function(){var t=new La(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.xAlign=this.xAlign,t.yAlign=this.yAlign,t.layoutText(),t}}]),e}();const za=function(){function t(){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.requestNextAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,this.reset()}var e,n,i,r;function o(t){return i.apply(this,arguments)}function a(t,e){return r.apply(this,arguments)}return e=t,n=[{key:"reset",value:function(){this.syncNowTimeout=100,this.drawQueue=[],this.nextDrawQueue=[],this.lastDrawTime=null,this.idCounter=0,this.speed=1,this.lastTime=performance.now(),this.nowTime=this.lastTime,this.clearTimeouts(),null!=this.syncNowTimer&&this.clearTimeout(this.syncNowTimer),this.timeoutId=null,this.updateSyncNow=!0,this.manual=!1,this.animateOnFrame=!1}},{key:"clearTimeouts",value:function(){var t=this;null!=this.timers&&Object.keys(this.timers).map((function(e){return t.timers[e]})).forEach((function(t){null!=t.id&&clearTimeout(t.id)})),this.timers={}}},{key:"getWhen",value:function(t){return"now"===t?this.now():"prevFrame"===t?this.lastDrawTime:"syncNow"===t?this.syncNow():null}},{key:"syncNow",value:function(){var t=this;return this.updateSyncNow&&(this.updateSyncNow=!1,this.synchronizedNow=this.now(),this.syncNowTimer=this.setTimeout((function(){t.updateSyncNow=!0}),this.syncNowTimeout)),this.synchronizedNow}},{key:"updateNow",value:function(){var t,e;this.manual||(e=(t=performance.now())-this.lastTime,this.nowTime+=e*this.speed,this.lastTime=t)}},{key:"now",value:function(){return this.manual||this.updateNow(),this.nowTime}},{key:"setSpeed",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;if(e<=0)throw new Error("speedFactor ".concat(e," is not greater than 0"));Object.keys(this.timers).forEach((function(n){var i=t.timers[n];n=(i.timeout-t.nowTime)/e,null!=i.id&&clearTimeout(i.id),t.manual||(i.id=setTimeout(i.callback,n))})),this.speed=e}},{key:"setManualFrames",value:function(){this.updateNow(),this.manual=!0}},{key:"endManualFrames",value:function(){this.manual=!1,this.lastTime=performance.now()}},{key:"frame",value:function(t){t=this.nowTime+1e3*t,this.incrementTimers(t),this.nowTime=t,this.lastTime=t,this.animateOnFrame=!0,this.animateNextFrame()}},{key:"incrementTimers",value:function(t){if(null==this.timers||0===Object.keys(this.timers).length)return 0;for(var e=Object.keys(this.timers),n=null,i=0;i<e.length;i+=1){var r=e[i],o=this.timers[r];o.timeout<=t&&(null==n||o.timeout<n.timer.timeout||o.timeout===n.timer.timeout&&n.timer.stateTimer)&&(n={id:r,timer:o})}if(null==n)return 0;var a=(s=n.timer).callback,s=s.timeout;return this.nowTime=s,this.lastTime=s,a(),this.draw(),delete this.timers[n.id],this.incrementTimers(t)}},{key:"setTimeout",value:(r=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return this.manual||this.updateNow(),this.timers["".concat(this.idCounter)]={timeout:this.nowTime+e,description:n,stateTimer:i,id:null,callback:t},this.manual||(this.timers["".concat(this.idCounter)].id=setTimeout(t,e/this.speed)),this.idCounter+=1,this.idCounter-1},a.toString=function(){return r.toString()},a)},{key:"clearTimeout",value:(i=function(t){var e;null==t||null!=(e=this.timers["".concat(t)])&&(null!=e.id&&clearTimeout(e.id),delete this.timers["".concat(t)])},o.toString=function(){return i.toString()},o)},{key:"draw",value:function(){this.animationId=null,this.clearTimeout(this.syncNowTimer),this.updateSyncNow=!0,this.drawQueue=this.nextDrawQueue,this.nextDrawQueue=[],this.updateNow();for(var t=.001*this.now(),e=0;e<this.drawQueue.length;e+=1)this.drawQueue[e](t);this.drawQueue=[],this.lastDrawTime=1e3*t}},{key:"queueNextFrame",value:function(t){this.nextDrawQueue.push(t),1===this.nextDrawQueue.length&&this.animateNextFrame()}},{key:"animateNextFrame",value:function(){if(this.manual)return this.animateOnFrame&&null==this.animationId&&(this.animateOnFrame=!1,this.animationId=this.requestNextAnimationFrame.call(window,this.draw.bind(this))),void(this.animateOnFrame=!1);null==this.animationId&&(this.animationId=this.requestNextAnimationFrame.call(window,this.draw.bind(this)))}},{key:"_dup",value:function(){return this}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(e.prototype,n),t}();function Na(t){return(Na="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qa(t,e,n){return(qa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Va(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ha(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ka(t,e)}function Ka(t,e){return(Ka=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ua(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=Va(t);return function(t,e){if(e&&("object"===Na(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Va(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function Va(t){return(Va=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ga(t){return function(t){if(Array.isArray(t))return $a(t)}(t)||Xa(t)||Ya(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ya(t,e){if(t){if("string"==typeof t)return $a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$a(t,e):void 0}}function Xa(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function $a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Qa(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ja(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Za(t,e,n){return e&&Ja(t.prototype,e),n&&Ja(t,n),t}function ts(t,e){if(0===e.length)return t;for(var n=[],i=0;i<t.length;i+=1)for(var r=0;r<e.length;r+=1)n.push(It(t[i],e[r]));return n}function es(t,e){var n=[];return 0===e.length?t.map((function(t){return t._dup()})):(t.forEach((function(t){e.forEach((function(e){n.push(Be(t).transform(Be(e)))}))})),0<n.length?n:t.map((function(t){return t._dup()})))}var ns=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ee,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new fe(-1,-1,2,2),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:dt("element_"),o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new za;Qa(this,t),this.name=r,this.uid=(1e18*Math.random()).toString(36),this.isShown=!0,this.simple=!1,this.transform=e._dup(),this.dependantTransform=!1,this.fnMap=new G,this.notifications=new jt(this.fnMap),this.isMovable=!1,this.isTouchable=!1,this.touchPriority=!1,this.isInteractive=void 0,this.hasTouchableElements=!1,this.color=[1,1,1,1],this.lastDrawOpacity=1,this.dimColor=[.5,.5,.5,1],this.defaultColor=this.color.slice(),this.opacity=1,this.setTransformCallback=null,this.beforeDrawCallback=null,this.afterDrawCallback=null,this.internalSetTransformCallback=null,this.lastDrawTransform=this.transform._dup(),this.parentTransform=[new Ee],this.lastDrawPulseTransform=this.transform._dup(),this.onClick=null,this.lastDrawElementTransformPosition={parentCount:0,elementCount:0},this.custom={},this._custom={},this.customState={},this.parent=i,this.drawPriority=1,this.stateProperties=[],this.lastDrawTime=0,this.cancelSetTransform=!1,this.onAdd=null,this.timeKeeper=o,this.pulseDefault={scale:2,rotation:null,translation:null,angle:0,duration:1,frequency:0,xAlign:"center",yAlign:"middle",centerOn:"this",num:1,space:"figure",done:null,progression:"sinusoid",when:"syncNow"},n instanceof fe?this.figureLimits=n:null!=n&&(this.figureLimits=this.figure.limits._dup()),this.move={bounds:"none",sizeInBounds:!1,maxVelocity:5,freely:{zeroVelocityThreshold:1e-4,deceleration:5,callback:null,bounceLoss:.5},canBeMovedAfterLosingTouch:!0,type:"translation",element:null,transformClip:null},this.scenarios={},this.fnMap.add("_elementPulseSettingsTransformMethod",(function(t,e,n){return"scale"===n?null==e?(new Ee).translate(0,0).scale(t,t).translate(0,0):(new Ee).translate(-e.x,-e.y).scale(t,t).translate(e.x,e.y):"rotation"===n?(new Ee).translate(-e.x,-e.y).rotate(t).translate(e.x,e.y):(e=t*Math.cos(n),n=t*Math.sin(n),(new Ee).translate(e,n))})),this.fnMap.add("tools.math.easeinout",b),this.fnMap.add("tools.math.linear",v),this.fnMap.add("tools.math.sinusoid",S),this.fnMap.add("tools.math.sinusoidAbs",T),this.fnMap.add("tools.math.triangle",g),this.pulseSettings={time:1,frequency:.5,A:1,B:.5,C:0,progression:"tools.math.sinusoid",num:1,delta:new pe(0,0),transformMethod:"_elementPulseSettingsTransformMethod",callback:function(){},allowFreezeOnStop:!1,type:"scale"},this.state={isBeingMoved:!1,isMovingFreely:!1,isChanging:!1,movement:{previousTime:null,previousTransform:this.transform._dup(),velocity:this.transform.zero()},isPulsing:!1,pulse:{startTime:null},preparingToStop:!1},this.interactiveLocation=new pe(0,0),this.animationFinishedCallback=null,this.animations=new ss({element:this,finishedCallback:this.animationFinished.bind(this),timeKeeper:this.timeKeeper}),this.tieToHTML={element:null,scale:"fit",window:this.figureLimits,updateOnResize:!0},this.isRenderedAsImage=!1,this.unrenderNextDraw=!1,this.renderedOnNextDraw=!1,this.pulseTransforms=[],this.frozenPulseTransforms=[],this.copyTransforms=[],this.drawTransforms=[]}return Za(t,[{key:"animationFinished",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"animation";this.fnMap.exec(this.animationFinishedCallback),this.notifications.publish("animationFinished",t)}},{key:"animateNextFrame",value:function(){null!=this.figure&&this.figure.animateNextFrame(!0,this.name)}},{key:"setProperties",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];null==t.move||null!=t.move.bounds&&"figure"!==t.move.bounds&&"none"!==t.move.bounds&&function(i){"string"==typeof n?n=[n,"move.".concat(i)]:n.push("move.".concat(i));var r=Ye(t.move[i],"transform",e.transform);if(r instanceof $e){for(var o=0;o<r.boundary.length;o+=1){var a=r.boundary[o],s=r.order[o];null!=r.boundary[o]&&a instanceof Ue&&("t"===s||"s"===s)&&(r.boundary[o]=new Ve({left:a.boundary.min,bottom:a.boundary.min,right:a.boundary.max,top:a.boundary.max}))}e.move[i]=r}}("bounds"),ut({except:n},this,t)}},{key:"_getStateProperties",value:function(t){return null==(t=t.ignoreShown)&&(t=!1),this.isShown||t?["animations","color","opacity","dimColor","defaultColor","transform","_custom","isShown","isMovable","isTouchable","state","pulseSettings","setTransformCallback","move","notifications","pulseTransforms","frozenPulseTransforms","customState"].concat(Ga(this.stateProperties)):["isShown","transform","customState"]}},{key:"_getStatePropertiesMin",value:function(){return this.isShown?["color","transform","isShown"]:["isShown"]}},{key:"_state",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.notifications.publish("getState");var e=t.returnF1Type;return(e=null==e||e)?{f1Type:"de",state:this.getPath()}:(t=ct({},t,{returnF1Type:!0})).min?ci(this,this._getStatePropertiesMin(),t):ci(this,this._getStateProperties(t),t)}},{key:"stateSet",value:function(){this.notifications.publish("setState")}},{key:"setFigure",value:function(t){null!=(this.figure=t)&&(this.recorder=t.recorder,this.animationFinishedCallback=t.animationFinished,this.timeKeeper=t.timeKeeper,this.animations.timeKeeper=t.timeKeeper,this.animations.recorder=t.recorder),this.isTouchable&&this.setTouchable(),this.isMovable&&this.setMovable()}},{key:"setTimeDelta",value:function(t){"animating"===this.animations.state&&this.animations.setTimeDelta(t),this.state.isPulsing&&null!=this.state.pulse.startTime&&(this.state.pulse.startTime+=t),null!=this.state.movement.previousTime&&(this.state.movement.previousTime+=t)}},{key:"updateHTMLElementTie",value:function(t){var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y;null!=(e="string"==typeof this.tieToHTML.element?document.getElementById(this.tieToHTML.element):e)&&(n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),r=this.figureLimits,h=this.tieToHTML.window,o=i.width/i.height,a=r.width/r.height,s=n.width/n.height,l=h.width/h.height,u=(y=new pe(n.left-i.left,n.top-i.top)).add(new pe(n.width,n.height)),c=this.figureTransforms.pixelToFigure,d=y.transformBy(c.m()),t=(f=u.transformBy(c.m())).x-d.x,y=d.y-f.y,u=d.add(new pe(t/2,-y/2)),c=this.tieToHTML.scale.trim().toLowerCase(),d=f=1,t=r.width/h.width,y=r.height/h.height,c.endsWith("em")&&(f=(h=parseFloat(c))*(m=parseFloat(getComputedStyle(e).fontSize))*(p=r.width/.2)/i.width,d=h*m*p/a/i.height),c.endsWith("px")&&(m=parseFloat(c),d=1<l?(f=(p=m/i.width)*t,p*o/a*t):(f=(m/=i.height)/o*a*y,m*y)),"stretch"===c&&(f=n.width/i.width*t,d=n.height/i.height*y),"max"!==c&&"fit"!==c||(y=new pe(n.height/i.height/o*a*y,n.height/i.height*y),t=new pe(n.width/i.width*t,n.width/i.width*o/a*t),d="max"===c&&l<s||"fit"===c&&s<l?(f=t.x,t.y):(f=y.x,y.y)),this.setScale(f,d),this.setPosition(u.x-f*(this.tieToHTML.window.left+this.tieToHTML.window.width/2),u.y-d*(this.tieToHTML.window.bottom+this.tieToHTML.window.height/2)),this.setFirstTransform(this.getParentLastDrawTransform()))}},{key:"setFirstTransform",value:function(t){}},{key:"clearFrozenPulseTransforms",value:function(){this.frozenPulseTransforms=[]}},{key:"freezePulseTransforms",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];(t&&0===this.pulseTransforms.length||!t&&0<this.pulseTransforms.length)&&(this.frozenPulseTransforms=this.pulseTransforms.map((function(t){return t._dup()})))}},{key:"animateToState",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r={};(this.isShown!==t.isShown&&1===this.opacity||1!==this.opacity)&&(r.isShown=t.isShown),Di(this.color,t.color,.001)||(r.color=t.color);var o=Be(t.transform);this.transform.isWithinDelta(o,.001)||!1!==this.dependantTransform&&!1!==n||(r.transform=o);var a,s=null;return n=0,0<Object.keys(r).length&&(a=ct({},e,{target:r}),s=this.animations.scenario(a)),o=null,this.arePulseTransformsSame(t,.001)||(r=this.pulseTransforms.map((function(t){return t._dup()})),0===this.pulseTransforms.length&&(r=this.frozenPulseTransforms.map((function(t){return t._dup()}))),0===(a=0===(a=t.pulseTransforms.map(Be)).length&&0<t.frozenPulseTransforms.length?t.frozenPulseTransforms.map(Be):a).length&&0<r.length&&(a=[r[0].identity()]),o=this.animations.pulseTransform(ct({},e,{start:r,target:a}))),null==s&&null==o||this.animations.new().inParallel([s,o]).start(i),null!=s&&(n=Math.max(n,s.getTotalDuration()||0)),null!=o?Math.max(n,o.getTotalDuration()||0):n}},{key:"dissolveInToState",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.8,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return!1===t.isShown?0:(this.transform=Be(t.transform),this.color=t.color.slice(),this.frozenPulseTransforms=[],t.pulseTransforms.forEach((function(t){return e.frozenPulseTransforms.push(Be(t))})),this.show(),this.animations.new().opacity({target:t.opacity,start:.001,duration:n}).trigger({callback:function(){e.frozenPulseTransforms=[]}}).start(i),n)}},{key:"isStateSame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=this.getPath();if(-1<n.indexOf(i))return!0;if(this.isShown!==t.isShown||.001<Math.abs(this.opacity-t.opacity))return!1;if(!Di(this.color,t.color,.001))return!1;if(!this.transform.isWithinDelta(Be(t.transform),.001))return!1;if(e)return!!this.arePulseTransformsSame(t,.001);if(t.pulseTransforms.length!==this.pulseTransforms.length)return!1;for(var r=0;r<this.pulseTransforms.length;r+=1)if(!this.pulseTransforms[r].isWithinDelta(Be(t.pulseTransforms[r]),.001))return!1;return!0}},{key:"arePulseTransformsSame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.001,n=[],i=es([this.transform._dup()],t.pulseTransforms);if(i=es(i,t.frozenPulseTransforms),n=es([this.transform._dup()],this.pulseTransforms),(n=es(n,this.frozenPulseTransforms)).length!==i.length)return!1;for(var r=0;r<n.length;r+=1)if(!n[r].isWithinDelta(i[r],e))return!1;return!0}},{key:"getDrawTransforms",value:function(t){return 0<this.copyTransforms.length&&(t=es(t,this.copyTransforms)),0<this.pulseTransforms.length&&(t=es(t,this.pulseTransforms)),0<this.frozenPulseTransforms.length?es(t,this.frozenPulseTransforms):t}},{key:"getDrawTransformsMatrix",value:function(t){return 0<this.copyTransforms.length&&(t=ts(t,this.copyTransforms.map((function(t){return t.mat})))),0<this.pulseTransforms.length&&(t=ts(t,this.pulseTransforms.map((function(t){return t.mat})))),0<this.frozenPulseTransforms.length?ts(t,this.frozenPulseTransforms.map((function(t){return t.mat}))):t}},{key:"exec",value:function(t){var e,n;Array.isArray(t)?(n=(e=function(t){if(Array.isArray(t))return t}(n=t)||Xa(n)||Ya(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],e=e.slice(1)):n=t,null!=this[n]&&"function"==typeof this[n]&&(void 0===e?this[n]():this[n].apply(this,Ga(e)))}},{key:"getElement",value:function(){return this}},{key:"getElements",value:function(){return[this]}},{key:"highlight",value:function(){this.undim()}},{key:"setPosition",value:function(t){var e="number"==typeof t?new pe(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0):ue(t);(t=this.transform._dup()).updateTranslation(e),this.setTransform(t)}},{key:"setRotation",value:function(t){var e=this.transform._dup();e.updateRotation(t),this.setTransform(e)}},{key:"setScale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;e="number"==typeof t?new pe(t,"number"==typeof e?e:t):ue(t),(t=this.transform._dup()).updateScale(e),this.setTransform(t)}},{key:"setTransform",value:function(t){var e,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];null!=this.move.transformClip?(e=this.fnMap.exec(this.move.transformClip,t))instanceof Ee&&(this.notifications.publish("beforeSetTransform",[e]),!1===this.cancelSetTransform?this.transform=e:this.cancelSetTransform=!1):"none"!==this.move.bounds&&null!=this.move.bounds?(e=this.getMoveBounds().clip(t),this.notifications.publish("beforeSetTransform",[e]),!1===this.cancelSetTransform?this.transform=e:this.cancelSetTransform=!1):(this.notifications.publish("beforeSetTransform",[t]),this.transform=t),!1===this.simple&&this.updateDrawTransforms(this.parentTransform,!1),this.internalSetTransformCallback&&this.fnMap.exec(this.internalSetTransformCallback,this.transform),n&&(this.notifications.publish("setTransform",[this.transform]),this.fnMap.exec(this.setTransformCallback,this.transform))}},{key:"nextMovingFreelyFrame",value:function(t){var e;this.state.isMovingFreely&&(null!=this.state.movement.previousTime?(Array.isArray(this.state.movement.velocity)&&(this.state.movement.velocity=Be(this.state.movement.velocity)),e=t-this.state.movement.previousTime,e=this.decelerate(e),this.state.movement.velocity=e.velocity,this.state.movement.previousTime=t,this.state.movement.velocity.isZero()&&(this.state.movement.velocity=this.state.movement.velocity.zero(),this.stopMovingFreely("complete")),this.setTransform(e.transform)):this.state.movement.previousTime=t)}},{key:"clear",value:function(){}},{key:"willStartAnimating",value:function(){return!!this.animations.willStartAnimating()}},{key:"setColor",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.color=null!=t?t.slice():[0,0,0,0],e&&(this.defaultColor=this.color.slice()),this.notifications.publish("color"),this.animateNextFrame()}},{key:"dim",value:function(){this.setColor(this.dimColor,!1),this.animateNextFrame()}},{key:"setDimColor",value:function(t){this.dimColor=null!=t?t.slice():[0,0,0,0]}},{key:"undim",value:function(){this.setColor(this.defaultColor,!1),this.animateNextFrame()}},{key:"setOpacity",value:function(t){this.opacity=t,this.animateNextFrame()}},{key:"getScenarioTarget",value:function(t){var e,n,i;return null==t?{}:(null!=(t="string"==typeof t?t in this.scenarios?this.scenarios[t]:{}:t).transform&&(e=Be(t.transform)),null!=t.position&&(e=null==e?this.transform._dup():e).updateTranslation(ue(t.position)),null!=t.translation&&(e=null==e?this.transform._dup():e).updateTranslation(ue(t.translation)),null!=t.rotation&&(e=null==e?this.transform._dup():e).updateRotation(t.rotation),null!=t.scale&&(e=null==e?this.transform._dup():e).updateScale(he(t.scale)),{transform:e,color:n=t.color?t.color.slice():n,isShown:i=null!=t.isShown?t.isShown:i})}},{key:"setScenario",value:function(t){null!=(t=this.getScenarioTarget(t)).transform&&this.setTransform(t.transform._dup()),null!=t.isShown&&(t.isShown?this.show():this.hide()),null!=t.color&&this.setColor(t.color)}},{key:"setScenarios",value:function(t){var e=this;t=t,(t=Array.isArray(t)?t:[t]).forEach((function(t){null!=e.scenarios[t]&&e.setScenario(t)}))}},{key:"saveScenario",value:function(t){var e=this.getCurrentScenario(1<arguments.length&&void 0!==arguments[1]?arguments[1]:["transform","color","isShown"]);0<Object.keys(e).length&&(this.scenarios[t]=e)}},{key:"getCurrentScenario",value:function(){var t=this,e={};return(0<arguments.length&&void 0!==arguments[0]?arguments[0]:["transform","color","isShown"]).forEach((function(n){"transform"===n?e.transform=t.transform._dup():"position"===n?e.position=t.getPosition():"rotation"===n?e.rotation=t.getRotation():"scale"===n?e.scale=t.getScale():"color"===n?e.color=t.color.slice():"isShown"===n&&(e.isShown=t.isShown)})),e}},{key:"saveScenarios",value:function(t,e){this.saveScenario(t,e)}},{key:"getAllElementsWithScenario",value:function(t){return null!=this.scenarios[t]?[this]:[]}},{key:"getMovingFreelyEnd",value:function(){return this.decelerate(null)}},{key:"getRemainingMovingFreelyTime",value:function(){return this.state.isMovingFreely?this.decelerate(null).duration:0}},{key:"decelerate",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=this.getMoveBounds();return{velocity:(e=this.transform.decelerate(this.state.movement.velocity,this.move.freely.deceleration,t,e,this.move.freely.bounceLoss,this.move.freely.zeroVelocityThreshold)).velocity,transform:e.transform,duration:e.duration}}},{key:"updateLastDrawTransform",value:function(){var t=this;this.getTransform().order.forEach((function(e,n){t.lastDrawTransform.order[n]=e._dup()})),this.lastDrawTransform.calcAndSetMatrix()}},{key:"getParentLastDrawTransform",value:function(){var t=this.lastDrawElementTransformPosition.parentCount;return new Ee(this.lastDrawTransform.order.slice(-t))}},{key:"getPath",value:function(){return null==this.parent||"figureRoot"===this.parent.name||null==this.parent.parent?this.name:"".concat(this.parent.getPath(),".").concat(this.name)}},{key:"startBeingMoved",value:function(){this.animations.cancelAll("freeze"),this.stopMovingFreely("freeze"),this.state.movement.velocity=this.transform.zero(),this.state.movement.previousTransform=this.transform._dup(),this.state.movement.previousTime=this.timeKeeper.now()/1e3,this.state.isBeingMoved=!0,this.unrender(),this.notifications.publish("startBeingMoved"),"recording"===this.recorder.state&&this.recorder.recordEvent("startBeingMoved",[this.getPath()])}},{key:"moved",value:function(t){var e,n=this.transform._dup();this.setTransform(t._dup()),(e=null!=this.move.bounds&&"none"!==this.move.bounds?this.move.bounds.getTranslation():e)instanceof Ve&&e.boundary.right>e.boundary.left&&e.boundary.top>e.boundary.bottom?this.calcVelocity(n,t):this.calcVelocity(n,this.transform)}},{key:"stopBeingMoved",value:function(){var t;this.state.isBeingMoved&&(t=this.timeKeeper.now()/1e3,null!=this.state.movement.previousTime&&.05<t-this.state.movement.previousTime&&(this.state.movement.velocity=this.transform.zero()),this.notifications.publish("stopBeingMoved"),"recording"===this.recorder.state&&this.state.isBeingMoved&&this.recorder.recordEvent("stopBeingMoved",[this.getPath(),this.transform._state(),this.state.movement.velocity._state()]),this.state.isBeingMoved=!1,this.state.movement.previousTime=null)}},{key:"calcVelocity",value:function(t,e){var n,i=this.timeKeeper.now()/1e3;null!=this.state.movement.previousTime?(n=i-this.state.movement.previousTime)<1e-4||(this.state.movement.velocity=e.velocity(t,n,this.move.freely.zeroVelocityThreshold,this.move.maxVelocity),this.state.movement.previousTime=i):this.state.movement.previousTime=i}},{key:"simulateStartMovingFreely",value:function(t,e){this.transform=t,this.state.movement.velocity=e,this.startMovingFreely()}},{key:"startMovingFreely",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.animations.cancelAll("freeze"),this.stopBeingMoved(),t&&(this.move.freely.callback=t),this.state.isMovingFreely=!0,this.state.movement.previousTime=this.timeKeeper.now()/1e3,Array.isArray(this.state.movement.velocity)&&(this.state.movement.velocity=Be(this.state.movement.velocity)),this.state.movement.velocity=this.state.movement.velocity.clipMag(this.move.freely.zeroVelocityThreshold,this.move.maxVelocity),this.notifications.publish("startMovingFreely"),"recording"===this.recorder.state&&this.recorder.recordEvent("startMovingFreely",[this.getPath(),this.transform._state(),this.state.movement.velocity._state()]),this.animateNextFrame()}},{key:"stopMovingFreely",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel";"animateToComplete"!==n&&(!(t=!1)===this.state.isMovingFreely&&(t=!0),"complete"===n&&t&&(e=this.getMovingFreelyEnd(),this.setTransform(e.transform)),this.state.isMovingFreely=!1,this.state.movement.previousTime=null,this.move.freely.callback&&(this.fnMap.exec(this.move.freely.callback,n),this.move.freely.callback=null),t&&(this.fnMap.exec(this.animationFinishedCallback),this.animationFinished("movingFreely"),this.notifications.publish("stopMovingFreely")),this.animateNextFrame())}},{key:"getRemainingPulseTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3;return!1===this.state.isPulsing?0:null==this.state.pulse.startTime?this.pulseSettings.time:this.pulseSettings.time-(t-this.state.pulse.startTime)}},{key:"getPulseTransforms",value:function(t){var e=[];if(this.state.isPulsing){null==this.state.pulse.startTime&&(this.state.pulse.startTime=t);var n=t-this.state.pulse.startTime;n>=this.pulseSettings.time&&0!==this.pulseSettings.time&&(this.stopPulsing("complete"),n=this.pulseSettings.time);for(var i=0;i<this.pulseSettings.num;i+=1){var r=this.fnMap.exec(this.pulseSettings.progression,n,this.pulseSettings.frequency,this.pulseSettings.A instanceof Array?this.pulseSettings.A[i]:this.pulseSettings.A,this.pulseSettings.B instanceof Array?this.pulseSettings.B[i]:this.pulseSettings.B,this.pulseSettings.C instanceof Array?this.pulseSettings.C[i]:this.pulseSettings.C);null!=(r=this.fnMap.exec(this.pulseSettings.transformMethod,r,ue(this.pulseSettings.delta),this.pulseSettings.type))&&e.push(r)}}return e}},{key:"pulse",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if("function"==typeof this.pulseDefault||"string"==typeof this.pulseDefault){var n=null;return"function"==typeof e?n=e:null!=e&&null!=e.done&&(n=e.done),void this.fnMap.exec(this.pulseDefault,n)}var i=this.pulseDefault,r="function"==typeof e||"string"==typeof e?(y=ct({},i),e):null==e?(y=ct({},i),null):(y=ct({},i,e)).done;"sinusoid"===y.progression?y.progression="tools.math.sinusoid":"sinusoidAbs"===y.progression?y.progression="tools.math.sinusoidAbs":"triangle"===y.progression&&(y.progression="tools.math.triangle");var o,a=(h=y).centerOn,s=h.xAlign,l=h.yAlign,u=h.space,c=null==a?new pe(0,0):"this"===a?this.getPositionInBounds("figure",s,l).transformBy(this.spaceTransformMatrix("figure","draw")):a instanceof t?a.getPositionInBounds("figure",s,l).transformBy(this.spaceTransformMatrix("figure","draw")):ue(a).transformBy(this.spaceTransformMatrix(u,"draw")),h=(n=(p=y).duration,i=p.scale,e=p.progression,p.when),f=p.num,p=(s=p.rotation,l=p.angle,a=p.translation,(u=y).min),m=u.start,y=u.frequency;if(0!==y&&null!=y||(y=0===n?1:1/n),u=(o=null!=a?(m=null==m?0:m,a):null!=s?(m=null==m?0:m,s):(m=null==m?1:m,i))-(p=null==p?m:p),1<f){for(var v=u/(f-1),g=[],b=[],w=[],x=0;x<f;x+=1){var S,T=o-x*v;T<m?(S=m-T,b.push(Math.PI/2),w.push(m-S/2),g.push(S/2)):(T-=m,b.push(-Math.PI/2),w.push(m+T/2),g.push(T/2))}this.pulseSettings.A=w,this.pulseSettings.B=g,this.pulseSettings.C=b}else i=u/2+p,p=0!=u?(m-i)/(u/2):m,this.pulseSettings.A=i,this.pulseSettings.B=u/2,this.pulseSettings.C=Math.asin(d(p,10));this.pulseSettings.time=n,this.pulseSettings.frequency=y,this.pulseSettings.num=f,this.pulseSettings.delta=c,this.pulseSettings.callback=r,this.pulseSettings.progression=e,this.pulseSettings.type="scale",null!=s&&(this.pulseSettings.type="rotation"),null!=a&&(this.pulseSettings.type=l),this.startPulsing(h),this.animateNextFrame()}},{key:"startPulsing",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"nextFrame";this.state.isPulsing=!0,t=this.timeKeeper.getWhen(t),this.state.pulse.startTime=null==t?t:t/1e3,this.unrender(),this.frozenPulseTransforms=[],this.animateNextFrame()}},{key:"stopPulsing",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=this.state.isPulsing;"animateToComplete"!==e&&("freeze"===e&&this.state.isPulsing&&(this.frozenPulseTransforms=this.pulseTransforms.map((function(t){return t._dup()})),this.pulseTransforms=[]),"cancel"!==e&&"complete"!==e||(this.pulseTransforms=[]),this.state.isPulsing=!1,this.pulseSettings.num=1,this.pulseSettings.callback&&(t=this.pulseSettings.callback,this.pulseSettings.callback=null,this.fnMap.exec(t,e)),n&&(this.animationFinished("pulse"),this.notifications.publish("stopPulsing")),this.animateNextFrame())}},{key:"stop",value:function(){function t(){--i<=0&&(e.state.preparingToStop=!1,e.notifications.publish("stopped"))}var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",i=0;"animateToComplete"!==n&&"dissolveToComplete"!==n||(this.animations.isAnimating()&&(this.state.preparingToStop=!0,i+=1,this.animations.notifications.add("finished",t,1)),this.state.isPulsing&&(this.state.preparingToStop=!0,i+=1,this.notifications.add("stopPulsing",t,1)),this.state.isMovingFreely&&(this.state.preparingToStop=!0,i+=1,this.notifications.add("stopMovingFreely",t,1))),this.state.preparingToStop&&this.notifications.publish("preparingToStop"),this.stopAnimating(n),this.stopMovingFreely(n),this.stopBeingMoved(),this.stopPulsing(n)}},{key:"stopAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"freeze"===t?this.animations.cancel(e,"freeze"):"cancel"===t?this.animations.cancel(e,null):"complete"===t&&this.animations.cancel(e,"complete")}},{key:"getRemainingAnimationTime",value:function(){return this.animations.getRemainingTime(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"getNextAnimationFinishTime",value:function(){if(this.simple)return this.state.isMovingFreely||this.state.isChanging||"animating"===this.animations.state?.1:0;var t,e=this.getRemainingMovingFreelyTime(),n=this.getRemainingPulseTime(),i=this.animations.getNextAnimationFinishTime();return null!=e&&0<e&&(t=e),null!=n&&0<n&&(void 0===t||n<t)&&(t=n),void 0===(t=null!=i&&0<i&&(void 0===t||i<t)?i:t)?null===e||null===n||null===i?null:0:t}},{key:"updateLimits",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.figureTransforms;this.figureLimits=t,this.figureTransforms=e}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;t&&this.tieToHTML.updateOnResize&&this.updateHTMLElementTie(t)}},{key:"getPixelToVertexSpaceScale",value:function(){var t=this.figureTransforms.pixelToFigure.matrix(),e=this.spaceTransformMatrix("figure","draw"),n=t[0]*e[0];return e=t[4]*e[4],new pe(n,e)}},{key:"getVertexToPixelSpaceScale",value:function(){var t=this.getPixelToVertexSpaceScale();return new pe(1/t.x,1/t.y)}},{key:"spaceTransformMatrix",value:function(t,e){return t===e?(new Ee).identity().matrix():"draw"===t&&"pixel"===e?It(this.figure.spaceTransforms.glToPixel.matrix(),this.lastDrawTransform.matrix()):"draw"===t&&"gl"===e?this.lastDrawTransform.matrix():"draw"===t&&"figure"===e?this.lastDrawTransform.calcMatrix(0,-3):"draw"===t&&"local"===e?this.getTransform().matrix():"pixel"===t&&"draw"===e?It(Gt(this.lastDrawTransform.matrix()),this.figure.spaceTransforms.pixelToGL.matrix()):"gl"===t&&"draw"===e?Gt(this.lastDrawTransform.matrix()):"figure"===t&&"draw"===e?Gt(this.lastDrawTransform.calcMatrix(0,-3)):"local"===t&&"draw"===e?Gt(this.getTransform().matrix()):"local"===t&&"pixel"===e?It(this.figure.spaceTransforms.glToPixel.matrix(),this.lastDrawTransform.calcMatrix(this.transform.order.length)):"local"===t&&"gl"===e?this.lastDrawTransform.calcMatrix(this.transform.order.length):"local"===t&&"figure"===e?this.lastDrawTransform.calcMatrix(this.transform.order.length,-3):"pixel"===t&&"local"===e?It(Gt(this.lastDrawTransform.calcMatrix(this.transform.order.length)),this.figure.spaceTransforms.pixelToGL.matrix()):"gl"===t&&"local"===e?Gt(this.lastDrawTransform.calcMatrix(this.transform.order.length)):"figure"===t&&"local"===e?Gt(this.lastDrawTransform.calcMatrix(this.transform.order.length,-3)):("figure"===t&&"gl"===e?this.figure.spaceTransforms.figureToGL:"figure"===t&&"pixel"===e?this.figure.spaceTransforms.figureToPixel:"gl"===t&&"figure"===e?this.figure.spaceTransforms.glToFigure:"pixel"===t&&"figure"===e?this.figure.spaceTransforms.pixelToFigure:"gl"===t&&"pixel"===e?this.figure.spaceTransforms.glToPixel:"pixel"===t&&"gl"===e?this.figure.spaceTransforms.pixelToGL:(new Ee).identity()).matrix()}},{key:"pointFromSpaceToSpace",value:function(t,e,n){return ue(t).transformBy(this.spaceTransformMatrix(e,n))}},{key:"getBorderPoints",value:function(){return[[]]}},{key:"getBorder",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=this.getBorderPoints(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border");if("draw"===t)return e;var n=[],i=Array.isArray(t)?It(t,this.getTransform().matrix()):this.spaceTransformMatrix("draw",t);return e.forEach((function(t){n.push(t.map((function(t){return t.transformBy(i)})))})),n}},{key:"getBoundingRect",value:function(){return Ie(this.getBorder(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border"))}},{key:"getRelativeBoundingRect",value:function(){var t=this.getBoundingRect(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border"),e=this.getPosition(e);return new fe(t.left-e.x,t.bottom-e.y,t.width,t.height)}},{key:"getCenterFigurePosition",value:function(){var t=this.getBoundingRect("figure","border");return new pe(t.left+t.width/2,t.bottom+t.height/2)}},{key:"getScale",value:function(){var t=this.transform.s(),e=new pe(1,1);return null!=t?t._dup():e}},{key:"getRotation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=this.transform.r();return""!==t&&null!=e?ae(e,t):null!=e?e:0}},{key:"getPositionInBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location",i=this.getBoundingRect(t,3<arguments.length&&void 0!==arguments[3]?arguments[3]:"border");return t=this.getPosition(t),"left"===e?t.x=i.left:"right"===e?t.x=i.right:"center"===e?t.x=i.left+i.width/2:"number"==typeof e?t.x=i.left+i.width*e:null!=e&&"o"===e.slice(-1)[0]&&(e=parseFloat(e),t.x=i.left+e),"top"===n?t.y=i.top:"bottom"===n?t.y=i.bottom:"middle"===n?t.y=i.bottom+i.height/2:"number"==typeof n?t.y=i.bottom+i.height*n:null!=n&&"o"===n.slice(-1)[0]&&(n=parseFloat(n),t.y=i.bottom+n),t}},{key:"getPosition",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location";return"location"!==e||"location"!==n?this.getPositionInBounds(t,e,n):"draw"===t?new pe(0,0):new pe(0,0).transformBy(this.spaceTransformMatrix("draw",t))}},{key:"setFigurePosition",value:function(t){var e=Ce({x:{bottomLeft:this.figureLimits.left,width:this.figureLimits.width},y:{bottomLeft:this.figureLimits.bottom,height:this.figureLimits.height}},{x:{bottomLeft:-1,width:2},y:{bottomLeft:-1,height:2}});t=t.transformBy(e.matrix()),e=new Ee(this.lastDrawTransform.order.slice(this.transform.order.length)),e=t.transformBy(Gt(e.matrix())),this.setPosition(e._dup())}},{key:"setFigurePositionToElement",value:function(t){t=t.getPosition("figure"),this.setFigurePosition(t._dup())}},{key:"setPositionToElement",value:function(t){var e;t.parent!==this.parent?(e=t.getPosition("figure").transformBy(this.spaceTransformMatrix("figure","local")),this.setPosition(e)):null!=(t=t.transform.t())&&this.setPosition(t._dup())}},{key:"checkMoveBounds",value:function(){"figure"!==this.move.bounds?"none"!==this.move.bounds&&null!==this.move.bounds?this.move.bounds instanceof $e||this.setMoveBounds(this.move.bounds):this.setMoveBounds("none"):this.setMoveBounds("figure")}},{key:"setMoveBounds",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"none";e instanceof $e?this.move.bounds=e:null!==e&&"none"!==e?"figure"!==e?(t=Ye(e,"transform",this.transform))instanceof $e&&(this.move.bounds=t):(this.move.bounds instanceof $e||(this.move.bounds=new $e(this.transform)),this.move.sizeInBounds=!0,e=this.spaceTransformMatrix("figure","local"),t=new pe(this.figureLimits.left,this.figureLimits.bottom).transformBy(e),e=new pe(this.figureLimits.right,this.figureLimits.top).transformBy(e),this.move.bounds.updateTranslation(new Ve({left:t.x,bottom:t.y,right:e.x,top:e.y}))):this.move.bounds=new $e(this.transform)}},{key:"getMoveBounds",value:function(){if(this.checkMoveBounds(),this.move.bounds.isUnbounded())return this.move.bounds;if(this.move.sizeInBounds){var t=this.getRelativeBoundingRect("local"),e=this.move.bounds._dup(),n=e.getTranslation();if(null!=n)return n.boundary.left-=t.left,n.boundary.bottom-=t.bottom,n.boundary.right-=t.right,n.boundary.top-=t.top,e.updateTranslation(n),e}return this.move.bounds}},{key:"getShown",value:function(){return this.isShown?[[this.getPath(),this.uid,this]]:[]}},{key:"getUid",value:function(t){return t===this.uid?this:null}},{key:"show",value:function(){this.isShown=!0,0===this.opacity&&this.setOpacity(1),null!=this.parent&&(this.parent.isShown||this.parent.show()),this.notifications.publish("show"),this.notifications.publish("visibility"),this.animateNextFrame()}},{key:"setTouchable",value:function(){0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?this.hasTouchableElements=!0:this.isTouchable=!0,null!=this.parent&&this.parent.setTouchable(!1)}},{key:"setMovable",value:function(){0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.isMovable=!1,this.isTouchable=!1):(this.isMovable=!0,this.setTouchable(!0))}},{key:"clearRender",value:function(){var t,e="";"string"==typeof this.tieToHTML.element&&(e=this.tieToHTML.element,t=document.getElementById(this.tieToHTML.element)),t&&(null!=(t=document.getElementById("".concat(e,"_webgl")))&&(t.style.display="none"),null!=(e=document.getElementById("".concat(e,"_2d")))&&(e.style.display="none"))}},{key:"setRenderedOnNextDraw",value:function(){this.renderedOnNextDraw=!0}},{key:"unrender",value:function(){this.isRenderedAsImage&&(this.unrenderNextDraw=!0,this.isRenderedAsImage=!1),null!=this.parent&&this.parent.unrender()}},{key:"showAll",value:function(){this.show()}},{key:"hide",value:function(){this.isShown=!1,this.notifications.publish("hide"),this.notifications.publish("visibility"),this.animateNextFrame()}},{key:"hideAll",value:function(){this.hide()}},{key:"toggleShow",value:function(){this.isShown?this.hide():this.show()}},{key:"click",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0),e=t.transformBy(this.spaceTransformMatrix("gl","draw"));null!=this.onClick&&("recording"===this.recorder.state&&this.recorder.recordEvent("elementClick",[this.getPath(),t.x,t.y]),this.fnMap.exec(this.onClick,e,this)),this.notifications.publish("onClick",[e,this])}},{key:"getTransform",value:function(){return this.transform}},{key:"isMoving",value:function(){return!!this.state.isChanging||!1!==this.isShown&&(!!this.isAnimating()||!!this.state.isBeingMoved)}},{key:"isAnimating",value:function(){return!1!==this.isShown&&!!(this.state.isMovingFreely||this.state.isPulsing||this.animations.isAnimating())}},{key:"isAnyElementMoving",value:function(){return this.isMoving()}},{key:"isBeingTouched",value:function(t){if(!this.isTouchable)return!1;for(var e=t.transformBy(this.spaceTransformMatrix("gl","draw")),n=this.getBorder("draw","touchBorder"),i=this.getBorder("draw","holeBorder"),r=0;r<n.length;r+=1){var o=n[r];if(2<o.length&&e.isInPolygon(o)){var a=!0;if(this.cannotTouchHole)for(var s=0;s<i.length;s+=1){var l=i[s];2<l.length&&Array.isArray(l)&&2<l.length&&e.isInPolygon(l)&&(a=!1,s=i.length)}if(a)return!0}}return!1}},{key:"getTouched",value:function(t){return this.isTouchable&&this.isBeingTouched(t)?[this]:[]}},{key:"updateDrawTransforms",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[new Ee],e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(e)return e;var n=es(t,[this.getTransform()._dup()]);return this.parentTransform=t,this.lastDrawElementTransformPosition={parentCount:t[0].order.length,elementCount:this.transform.order.length},this.pulseTransforms=this.getPulseTransforms(this.timeKeeper.now()/1e3),this.drawTransforms=this.getDrawTransforms(n),this.lastDrawTransform=n[0],this.lastDrawPulseTransform=this.drawTransforms[0],e}}]),t}(),is=function(){Ha(e,ns);var t=Ua(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Ee,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[.5,.5,.5,1],o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new fe(-1,-1,2,2),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:dt("element_"),l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:new za;return Qa(this,e),(l=t.call(this,i,o,a,s,l)).drawingObject=n,l.color=null!=r?r.slice():[0,0,0,0],l.defaultColor=l.color.slice(),l.dimColor=[.5,.5,.5,1],l.pointsToDraw=-1,l.angleToDraw=-1,l.lengthToDraw=-1,l.cannotTouchHole=!1,l.type="primitive",l.pointsDefinition={},l.setPointsFromDefinition=null,l.border="draw",l.touchBorder="draw",l.holeBorder=[[]],l}return Za(e,[{key:"_getStateProperties",value:function(t){var n=t.ignoreShown;return null==n&&(n=!1),this.isShown||n?[].concat(Ga(qa(Va(e.prototype),"_getStateProperties",this).call(this,t)),["pointsToDraw","angleToDraw","lengthToDraw","cannotTouchHole","drawingObject","pointsDefinition"]):qa(Va(e.prototype),"_getStateProperties",this).call(this,t)}},{key:"setAngleToDraw",value:function(){this.angleToDraw=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1}},{key:"click",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0);qa(Va(e.prototype),"click",this).call(this,t),this.drawingObject instanceof Ra&&(this.drawingObject.click(t.transformBy(this.spaceTransformMatrix("gl","draw")),this.fnMap),"recording"===this.recorder.state&&this.recorder.recordEvent("elementTextClick",[this.getPath(),t.x,t.y]))}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=new e(this.drawingObject._dup());return ht(this,n,["parent","figure","recorder","pulseDefault.centerOn","timeKeeper"]),null!=t&&(n.transform=t._dup()),"string"!=typeof this.pulseDefault&&"function"!=typeof this.pulseDefault?n.pulseDefault.centerOn=this.pulseDefault.centerOn:n.pulseDefault=this.pulseDefault,n.recorder=this.recorder,n.timeKeeper=this.timeKeeper,n}},{key:"clear",value:function(){this.drawingObject instanceof Ra&&this.drawingObject.clear(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,this.pulseTransforms)}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.resizeHtmlObject(),qa(Va(e.prototype),"resize",this).call(this,t),"vertexText"===this.drawingObject.type&&(t=this.getPixelToVertexSpaceScale(),this.drawingObject.drawTextIntoBuffer(new pe(t.x,Math.abs(t.y))))}},{key:"setColor",value:function(t){var n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.color=null!=t?t.slice():[0,0,0,0],n&&(this.defaultColor=this.color.slice()),this.notifications.publish("color"),this instanceof e&&(this.drawingObject instanceof Ra&&this.drawingObject.setColor(this.color),this.drawingObject instanceof ta&&(this.drawingObject.element.style.color=Ri(this.color)))}},{key:"setOpacity",value:function(t){this.opacity=t,this instanceof e&&(this.drawingObject instanceof Ra&&this.drawingObject.setOpacity(t),this.drawingObject instanceof ta&&(this.drawingObject.element.style.opacity="".concat(t))),this.animateNextFrame()}},{key:"show",value:function(){qa(Va(e.prototype),"show",this).call(this),this.drawingObject instanceof ta&&(this.drawingObject.show=!0,this.drawingObject.transformHtml(this.lastDrawTransform.matrix()))}},{key:"hide",value:function(){qa(Va(e.prototype),"hide",this).call(this),this.drawingObject instanceof ta&&(this.drawingObject.show=!1,this.drawingObject.transformHtml(this.lastDrawTransform.matrix()))}},{key:"setFont",value:function(t){this.drawingObject instanceof Ra&&this.drawingObject.setFont(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"resizeHtmlObject",value:function(){this.drawingObject instanceof ta&&this.drawingObject.transformHtml(this.lastDrawTransform.matrix())}},{key:"getBorderPoints",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border";return"border"===t?"draw"===this.border?this.drawBorder:"buffer"===this.border?this.drawBorderBuffer:"rect"===this.border?[Le(this.drawBorder)]:De(this.border)?[Le(this.drawBorder,this.border)]:this.border:"touchBorder"===t?"draw"===this.touchBorder?this.drawBorder:"buffer"===this.touchBorder?this.drawBorderBuffer:"border"===this.touchBorder?this.getBorderPoints("border"):"rect"===this.touchBorder?[Le(this.getBorderPoints("border"))]:De(this.touchBorder)?[Le(this.getBorderPoints("border"),this.touchBorder)]:this.touchBorder:this.holeBorder}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(this.isShown){if(this.lastDrawTime=t,!0===this.isRenderedAsImage){if(!this.willStartAnimating())return;this.unrender()}this.notifications.publish("beforeDraw",[t]),null!=this.beforeDrawCallback&&this.fnMap.exec(this.beforeDrawCallback,t),0<this.animations.animations.length&&this.animations.nextFrame(t),this.state.isMovingFreely&&this.nextMovingFreelyFrame(t)}}},{key:"draw",value:function(t){var e,n,i=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[new Ee],o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;this.isShown&&(e=-1,this.drawingObject instanceof ma?(e=this.drawingObject.numVertices,-1!==this.angleToDraw&&(e=this.drawingObject.getPointCountForAngle(this.angleToDraw)),-1!==this.lengthToDraw&&(e=this.drawingObject.getPointCountForLength(this.lengthToDraw)),-1!==this.pointsToDraw&&(e=this.pointsToDraw)):e=this.drawingObject instanceof aa?this.drawingObject.numVertices:1,n=[this.color[0],this.color[1],this.color[2],this.color[3]*this.opacity*o],this.lastDrawOpacity=n[3],o=es(r,[this.getTransform()]),this.parentTransform=r,this.lastDrawElementTransformPosition={parentCount:r[0].order.length,elementCount:this.transform.order.length},this.pulseTransforms=this.getPulseTransforms(t),this.drawTransforms=this.getDrawTransforms(o),this.lastDrawTransform=o[0],this.lastDrawPulseTransform=this.drawTransforms[0],0<e&&this.drawTransforms.forEach((function(t){i.drawingObject.drawWithTransformMatrix(t.matrix(),n,e)})))}},{key:"setFirstTransform",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ee;this.lastDrawElementTransformPosition={parentCount:t.order.length,elementCount:this.transform.order.length},this.parentTransform=[t],t=t.transform(this.getTransform()),this.lastDrawTransform=t._dup(),this.drawingObject instanceof ta&&this.drawingObject.transformHtml(t.matrix()),this.checkMoveBounds()}},{key:"increaseBorderSize",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=e instanceof pe?(t=e.x,e.y):(t=e,null==n?t:n);if(this.drawingObject instanceof ma)for(var r=0;r<this.drawingObject.border.length;r+=1)for(var o=this.drawingObject.border[r],a=0;a<o.length;a+=1)o[a].x*=t,o[a].y*=i}}]),e}(),rs=function(){Ha(e,ns);var t=Ua(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};Qa(this,e);var i=ct({},{transform:new Ee,limits:new fe(-1,1,2,2),parent:null,border:"children",touchBorder:"children",holeBorder:[[]],color:[0,0,0,1],name:dt("collection_"),timeKeeper:new za},n);return n=t.call(this,Be(i.transform),i.limits,i.parent,i.name,i.timeKeeper),null!=i.position&&n.transform.updateTranslation(ue(i.position)),n.elements={},n.drawOrder=[],n.childrenCanAnimate=!0,n.eqns={},n.type="collection",n.setColor(i.color),null!=i.border&&(De(i.border)?n.border=i.border:n.border=nn(i.border)),null!=i.touchBorder&&(De(i.touchBorder)?n.touchBorder=i.touchBorder:n.touchBorder=nn(i.touchBorder)),null!=i.holeBorder&&(n.holeBorder=nn(i.holeBorder)),n}return Za(e,[{key:"_getStateProperties",value:function(t){var n=t.ignoreShown;return null==n&&(n=!1),this.isShown||n?[].concat(Ga(qa(Va(e.prototype),"_getStateProperties",this).call(this,t)),["hasTouchableElements"]):Ga(qa(Va(e.prototype),"_getStateProperties",this).call(this,t))}},{key:"_getStatePropertiesMin",value:function(){return Ga(qa(Va(e.prototype),"_getStatePropertiesMin",this).call(this))}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=new e({}),i=this.drawOrder.map((function(t){return"_".concat(t)}));ht(this,n,["elements","drawOrder","parent","recorder","figure","collections","pulseDefault.centerOn"].concat(Ga(i),Ga(t)));for(var r=0;r<this.drawOrder.length;r+=1){var o=this.drawOrder[r];n.add(o,this.elements[o]._dup())}return n.recorder=this.recorder,"string"!=typeof this.pulseDefault&&"function"!=typeof this.pulseDefault?n.pulseDefault.centerOn=this.pulseDefault.centerOn:n.pulseDefault=this.pulseDefault,n}},{key:"toFront",value:function(t){var e=t;Array.isArray(t)&&"string"!=typeof t||(e=[t]);var n=[];e.forEach((function(t){"string"==typeof t?n.push(t):n.push(t.name)}));var i=[];this.drawOrder.forEach((function(t){-1===n.indexOf(t)&&i.push(t)})),this.drawOrder=[].concat(i,n)}},{key:"toBack",value:function(t){var e=t;"string"!=typeof t&&Array.isArray(t)||(e=[t]);var n=[];e.forEach((function(t){"string"==typeof t?n.push(t):n.push(t.name)}));var i=[];this.drawOrder.forEach((function(t){-1===n.indexOf(t)&&i.push(t)})),this.drawOrder=[].concat(Ga(n.reverse()),i)}},{key:"isAnyElementMoving",value:function(){if(!1===this.isShown)return!1;if(this.isMoving())return!0;for(var t=0;t<this.drawOrder.length;t+=1)if(this.elements[this.drawOrder[t]].isAnyElementMoving())return!0;return!1}},{key:"addElementWithName",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1;return(e.parent=this).elements[t]=e,this.elements[t].name=t,this["_".concat(t)]=this.elements[t],-1!==n?this.drawOrder=[].concat(Ga(this.drawOrder.slice(0,n)),[t],Ga(this.drawOrder.slice(n))):this.drawOrder.push(t),null!=this.figure&&e.setFigure(this.figure),e.setFirstTransform(this.lastDrawTransform),this.animateNextFrame(),e}},{key:"add",value:function(t){var n=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof t){if(null==i)throw new Error("Adding element ".concat(t," fail: Element is null"));return this.addElementWithName(t,i)}i=Array.isArray(t)?t:[t];var r=this,o=[];return i.forEach((function(t,i){if(t instanceof ns)o.push(n.add(t.name,t));else{if(null==t)throw Error("Add elements index ".concat(i," does not exist in layout"));var a,s=t.name||dt("primitive_"),l=t.path,u=null!=t.options?t.options:t,c=t.elements,h=t.make,f=t.mods,d=t.scenario,p=null==l||""===l?r:r.getElement(l);if(null==s||""===s)throw new Error("Figure addElement ERROR at index ".concat(i," in collection ").concat(r.name,": missing name property in ").concat(t));if(null==h||""===h)throw new Error("Figure addElement ERROR at index ".concat(i," in collection ").concat(r.name,": missing method property in ").concat(t));if(!(p instanceof e))throw new Error("Figure addElement ERROR at index ".concat(i," in collection ").concat(r.name,": missing or incorrect path property in ").concat(t));if(l=h.split("/"),"function"==typeof(t=n.getMethod(h))){if("function"!=typeof t)throw new Error("Layout addElement at index ".concat(i," in collection ").concat(r.name,": incorrect method property"));if(l.slice(-1)[0].startsWith("add")){if(null==(a=t(p,s,u)))return;null!=f&&f!=={}&&a.setProperties(f)}else{if(null==(a=Array.isArray(u)?t.apply(void 0,Ga(u)):t(u)))return;null!=f&&f!=={}&&a.setProperties(f),p instanceof e&&(p.add(s,a),o.push(a))}null!=d&&d in a.scenarios&&a.setScenario(d),"_".concat(s)in r&&null!=c&&c!=={}&&!h.endsWith("equation")&&a.add(c)}}})),Array.isArray(t)||1!==o.length?o:o[0]}},{key:"getMethod",value:function(t){function e(t,n){return n[0]in t?1===n.length?t[n[0]]:e(t[n[0]],n.slice(1)):null}var n=this.collections,i=n.primitives,r={collection:n.collection.bind(n),polyline:i.polyline.bind(i),polygon:i.polygon.bind(i),rectangle:i.rectangle.bind(i),ellipse:i.ellipse.bind(i),gl:i.gl.bind(i),morph:i.morph.bind(i),arc:i.arc.bind(i),triangle:i.triangle.bind(i),generic:i.generic.bind(i),grid:i.grid.bind(i),arrow:i.arrow.bind(i),line:i.line.bind(i),star:i.star.bind(i),text:i.text.bind(i),textLine:i.textLine.bind(i),textLines:i.textLines.bind(i),"text.line":i.textLine.bind(i),"text.lines":i.textLines.bind(i),textGL:i.textGL.bind(i),textHTML:i.htmlText.bind(i),htmlImage:i.htmlImage.bind(i),opolyline:n.polyline.bind(n),oline:n.line.bind(n),angle:n.angle.bind(n),addEquation:n.addEquation.bind(n),equation:n.equation.bind(n)};return t in r?r[t]:null==(t=e(i={primitives:i,shapes:i,collections:n},n=t.split(".")))?null:t.bind(e(i,n.slice(0,-1)))}},{key:"setFigure",value:function(t){qa(Va(e.prototype),"setFigure",this).call(this,t),null!=this.onAdd&&this.fnMap.exec(this.onAdd);for(var n=0,i=this.drawOrder.length;n<i;n+=1){var r=this.elements[this.drawOrder[n]];r.setFigure(t),null!=r.onAdd&&this.fnMap.exec(r.onAdd)}}},{key:"willStartAnimating",value:function(){if(qa(Va(e.prototype),"willStartAnimating",this).call(this))return!0;for(var t=0,n=this.drawOrder.length;t<n;t+=1)if(this.elements[this.drawOrder[t]].willStartAnimating())return!0;return!1}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.isShown){if(this.lastDrawTime=t,!0===this.isRenderedAsImage){if(!this.willStartAnimating())return;this.unrender()}if(null!=this.beforeDrawCallback&&this.fnMap.exec(this.beforeDrawCallback,t),this.animations.nextFrame(t),this.nextMovingFreelyFrame(t),this.isShown&&this.childrenCanAnimate)for(var n=0,i=this.drawOrder.length;n<i;n+=1)this.elements[this.drawOrder[n]].setupDraw(t,e)}}},{key:"draw",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[new Ee],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;if(this.isShown){this.lastDrawElementTransformPosition={parentCount:e[0].order.length,elementCount:this.transform.order.length};var r=es(e,[this.getTransform()]);this.lastDrawTransform=r[0],this.parentTransform=e,this.pulseTransforms=this.getPulseTransforms(t),this.drawTransforms=this.getDrawTransforms(r),this.lastDrawPulseTransform=this.drawTransforms[0];var o=this.color[3]*this.opacity*n;this.lastDrawOpacity=o;for(var a=0,s=this.drawOrder.length;a<s;a+=1)this.elements[this.drawOrder[a]].draw(t,this.drawTransforms,o,i);this.unrenderNextDraw&&(this.clearRender(),this.unrenderNextDraw=!1),this.renderedOnNextDraw&&(this.isRenderedAsImage=!0,this.renderedOnNextDraw=!1),null!=this.afterDrawCallback&&this.fnMap.exec(this.afterDrawCallback,t)}}},{key:"exec",value:function(t){var n=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;null!=i?Array.isArray(i)&&0===i.length||i.forEach((function(e){null!=(e="string"==typeof e?n.getElement(e):e)&&e.exec(t)})):qa(Va(e.prototype),"exec",this).call(this,t)}},{key:"pulse",value:function(){var t,n,i,r,o,a,s,l,u=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,h=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;null!=c&&"function"!=typeof c&&"string"!=typeof c?(Array.isArray(c)||null==c.centerOn||"string"!=typeof c.centerOn||null!=(t=this.getElement(c.centerOn))&&(c.centerOn=t),Array.isArray(c)||null!=c.elements&&0!==c.elements.length?(Array.isArray(c)?(n={},r=h,i=c):(i=(n=ct({},c)).elements,r=n.done,null==c.scale&&(n.scale=void 0),null==c.frequency&&(n.frequency=void 0),null==c.duration&&(n.duration=void 0)),n.elements=null,o=0,n.done=function(){(o+=1)===i.length&&null!=r&&r()},a=this.spaceTransformMatrix("draw","figure"),s=n.translation,l=n.min,i.forEach((function(t){var e="string"==typeof t?u.getElement(t):t;null!=e&&(null!=n.translation&&(t=e.spaceTransformMatrix("figure","draw")[0]/a[0],n.translation*=t,null!=n.min&&(n.min*=t)),e.pulse(n),null!=s&&(n.translation=s),null!=l&&(n.min=l))}))):qa(Va(e.prototype),"pulse",this).call(this,c)):qa(Va(e.prototype),"pulse",this).call(this,c)}},{key:"getElement",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?this:"string"!=typeof t||t instanceof ns?t:function t(e,n){var i=e.split(".");if(null!=(e=null==(e=n.elements[i[0]])?n[i[0]]:e))return 1<i.length?t(i.slice(1).join("."),e):e}(t,this)}},{key:"getElements",value:function(t){var e=this;if(null==t)return[];t=function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e)return["".concat(n).concat(e)];if(e instanceof ns)return[e];if(Array.isArray(e)){var i=[];return e.forEach((function(e){i.push.apply(i,Ga(t(e,n)))})),i}var r=[];return Object.keys(e).forEach((function(i){r.push.apply(r,Ga(t(e[i],"".concat(n).concat(i,"."))))})),r}(t);var n=[];return t.forEach((function(t){null!=(t=e.getElement(t))&&n.push(t)})),n}},{key:"getShown",value:function(){var t=this;if(!1===this.isShown)return[];var e=[[this.getPath(),this.uid,this]];return this.drawOrder.forEach((function(n){n=t.elements[n],e.push.apply(e,Ga(n.getShown()))})),e}},{key:"get",value:function(t){return"string"==typeof t?this.getElement(t):this.getElements(t)}},{key:"getUid",value:function(t){if(t===this.uid)return this;for(var e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]].getUid(t);if(null!==n)return n}return null}},{key:"show",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];qa(Va(e.prototype),"show",this).call(this),this.getElements(t).forEach((function(t){t.showAll()}))}},{key:"showOnly",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];this.hideAll(),this.show(t)}},{key:"showAll",value:function(){qa(Va(e.prototype),"show",this).call(this);for(var t=0,n=this.drawOrder.length;t<n;t+=1)this.elements[this.drawOrder[t]].showAll()}},{key:"hide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t?this.getElements(t).forEach((function(t){t.hide()})):qa(Va(e.prototype),"hide",this).call(this)}},{key:"hideAll",value:function(){this.hide();for(var t=0,e=this.drawOrder.length;t<e;t+=1){var n=this.elements[this.drawOrder[t]];n.hide(),"function"==typeof n.hideAll&&n.hideAll()}}},{key:"hideOnly",value:function(t){this.showAll(),this.hide(t)}},{key:"resizeHtmlObject",value:function(){for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].resizeHtmlObject()}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;qa(Va(e.prototype),"resize",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].resize(t)}},{key:"clear",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].clear(t)}},{key:"updateDrawTransforms",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[new Ee],n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];qa(Va(e.prototype),"updateDrawTransforms",this).call(this,t,n);for(var i=0,r=this.drawOrder.length;i<r;i+=1)this.elements[this.drawOrder[i]].updateDrawTransforms(this.drawTransforms,n)}},{key:"setFirstTransform",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ee,e=t.transform(this.getTransform());this.lastDrawTransform=e._dup(),this.parentTransform=[t];for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setFirstTransform(e);this.checkMoveBounds()}},{key:"getBorderPoints",value:function(){function t(t){var n=[],o=i;return 0===(o=null==o?Object.keys(e.elements):o).length?[[]]:(o.forEach((function(i){null==(i=e.getElement(i))||r&&!1===i.isShown||n.push.apply(n,Ga(i.getBorder("local",t,null,r)))})),n)}var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border",i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];return"border"===n?"children"===this.border?t("border"):"rect"===this.border?[Le(t("border"))]:De(this.border)?[Le(t("border"),this.border)]:this.border:"touchBorder"===n?"border"===this.touchBorder?this.getBorderPoints("border",i,r):"children"===this.touchBorder?t("touchBorder"):"rect"===this.touchBorder?[Le(t("touchBorder"))]:De(this.touchBorder)?[Le(t("touchBorder"),this.touchBorder)]:this.touchBorder:"children"===this.holeBorder?t("holeBorder"):this.holeBorder}},{key:"getBorder",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];if(i&&!1===this.isShown)return[[]];var r=Array.isArray(t)?It(t,this.getTransform().matrix()):this.spaceTransformMatrix("draw",t);return this.getBorderPoints(e,n,i).map((function(t){return t.map((function(t){return ue(t).transformBy(r)}))}))}},{key:"getBoundingRect",value:function(){return Ie(this.getBorder(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,!(3<arguments.length&&void 0!==arguments[3])||arguments[3]))}},{key:"getRelativeBoundingRect",value:function(){var t=this.getBoundingRect(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,!(3<arguments.length&&void 0!==arguments[3])||arguments[3]),e=this.getPosition(e);return new fe(t.left-e.x,t.bottom-e.y,t.width,t.height)}},{key:"getPositionInBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return i=this.getBoundingRect(t,4<arguments.length&&void 0!==arguments[4]?arguments[4]:"border",i,!(5<arguments.length&&void 0!==arguments[5])||arguments[5]),t=this.getPosition(t),"left"===e?t.x=i.left:"right"===e?t.x=i.right:"center"===e?t.x=i.left+i.width/2:"number"==typeof e&&(t.x=i.left+i.width*e),"top"===n?t.y=i.top:"bottom"===n?t.y=i.bottom:"middle"===n?t.y=i.bottom+i.height/2:"number"==typeof n&&(t.y=i.bottom+i.height*n),t}},{key:"updateLimits",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.figureTransforms,n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].updateLimits(t,e);this.figureLimits=t,this.figureTransforms=e}},{key:"updateHTMLElementTie",value:function(t){qa(Va(e.prototype),"updateHTMLElementTie",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].updateHTMLElementTie(t)}},{key:"getTouched",value:function(t){if(!this.isTouchable&&!this.hasTouchableElements)return[];var n=[];if(this.isTouchable)return qa(Va(e.prototype),"getTouched",this).call(this,t);for(var i=this.drawOrder.length-1;0<=i;--i){var r=this.elements[this.drawOrder[i]];!0===r.isShown&&(n=n.concat(r.getTouched(t)))}return n}},{key:"stop",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(qa(Va(e.prototype),"stop",this).call(this,t),!n)for(var i=0;i<this.drawOrder.length;i+=1)this.elements[this.drawOrder[i]].stop(t,n)}},{key:"setFont",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].setFont(t)}},{key:"setColor",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[0,0,0,1],e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=null!=t?t:[0,0,0,0],i=0;i<this.drawOrder.length;i+=1)this.elements[this.drawOrder[i]].setColor(n,e);this.color=n.slice(),this.notifications.publish("color"),e&&(this.defaultColor=this.color.slice())}},{key:"setDimColor",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[0,0,0,1],e=null!=t?t:[0,0,0,0],n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setDimColor(e);this.dimColor=e.slice()}},{key:"undim",value:function(t){var e=this;(t=null!=t?this.getElements(t):(this.color=this.defaultColor.slice(),this.drawOrder.map((function(t){return e.elements[t]})))).forEach((function(t){return t.undim()}))}},{key:"dim",value:function(t){var e=this;(t=null!=t?this.getElements(t):(this.color=this.dimColor.slice(),this.drawOrder.map((function(t){return e.elements[t]})))).forEach((function(t){return t.dim()}))}},{key:"highlight",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t?(t=this.getElements(t),this.dim(),this.exec("undim",t)):this.undim()}},{key:"getElementTransforms",value:function(){for(var t={},e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];t[n.name]=n.transform._dup()}return t}},{key:"setElementTransforms",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];n.name in t&&(n.transform=t[n.name],n.internalSetTransformCallback&&this.fnMap.exec(n.internalSetTransformCallback,n.transform))}}},{key:"reorder",value:function(){var t=this;this.drawOrder.sort((function(e,n){return e=t.elements[e],t.elements[n].drawPriority-e.drawPriority}));for(var n=0;n<this.drawOrder.length;n+=1){var i=this.elements[this.drawOrder[n]];i instanceof e&&i.reorder()}}},{key:"animateToTransforms",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"",a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:"tools.math.easeinout",s=r,l=0,u=0;u<this.drawOrder.length;u+=1){var c=this.elements[this.drawOrder[u]];c.name in t&&(c.isShown?t[c.name].isEqualTo(c.transform)||(c.animations.new(o).delay(n).transform({target:t[c.name],duration:e,rotDirection:i,progression:a,onFinish:s}).start(),s=null,l=e+n):(c.transform=t[c.name]._dup(),c.internalSetTransformCallback&&this.fnMap.exec(c.internalSetTransformCallback,c.transform)))}return 0===l&&null!=s&&this.fnMap.exec(s,!0),l}},{key:"getAllPrimitives",value:function(){for(var t=[],n=0;n<this.drawOrder.length;n+=1){var i=this.elements[this.drawOrder[n]];i instanceof e?t=[].concat(Ga(t),Ga(i.getAllPrimitives())):t.push(i)}return t}},{key:"getAllElements",value:function(){for(var t=[this],n=0;n<this.drawOrder.length;n+=1){var i=this.elements[this.drawOrder[n]];i instanceof e?t.push.apply(t,Ga(i.getAllElements())):t.push(i)}return t}},{key:"getChildren",value:function(){for(var t=[],e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];t.push(n)}return t}},{key:"getAllElementsWithScenario",value:function(t){for(var n=qa(Va(e.prototype),"getAllElementsWithScenario",this).call(this,t),i=0;i<this.drawOrder.length;i+=1){var r=this.elements[this.drawOrder[i]];n=[].concat(Ga(n),Ga(r.getAllElementsWithScenario(t)))}return n}},{key:"getNextAnimationFinishTime",value:function(){if(this.simple)return this.state.isMovingFreely||this.state.isChanging||"animating"===this.animations.state?.1:0;var t=null,n=qa(Va(e.prototype),"getNextAnimationFinishTime",this).call(this),i=!1;null===n?i=!0:0<n&&(t=n);for(var r,o=0;o<this.drawOrder.length;o+=1)this.elements[this.drawOrder[o]].simple||(null===(r=this.elements[this.drawOrder[o]].getNextAnimationFinishTime())?i=!0:(0<r&&null==t||0<r&&r<t)&&(t=r));return null==t?i?null:0:t}},{key:"getRemainingAnimationTime",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=this.getAllElements(),i=qa(Va(e.prototype),"getRemainingAnimationTime",this).call(this,t),r=0;r<n.length;r+=1){var o=n[r].animations.getRemainingTime(t);if(null==o)return null;i<o&&(i=o)}return i}},{key:"getAllPossiblyInteractiveElements",value:function(){for(var t=[],n=0;n<this.drawOrder.length;n+=1){var i=this.elements[this.drawOrder[n]];i instanceof e&&(i.isTouchable||i.isMovable||!i.hasTouchableElements||i.isInteractive&&null!=i.isInteractive||(t=[].concat(Ga(t),Ga(i.getAllPossiblyInteractiveElements())))),(void 0!==i.isInteractive||i.isTouchable||i.isMovable)&&t.push(i)}return t}},{key:"goToStep",value:function(t){var e=document.getElementById("id__figureone_item_selector_0"),n=[];if(null!=e&&0<e.children.length)for(var i=0;i<e.children.length;i+=1)n.push(e.children[i]);n.forEach((function(e,n){n===t?e.classList.add("figureone__item_selector_selected"):e.classList.remove("figureone__item_selector_selected")}))}},{key:"setMovable",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];qa(Va(e.prototype),"setMovable",this).call(this,t),t&&(this.hasTouchableElements=!0)}},{key:"setupWebGLBuffers",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].setupWebGLBuffers(t)}},{key:"changeWebGLInstance",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)var n=this.elements[this.drawOrder[e]].changeWebGLInstance(t);return n}},{key:"getLoadingElements",value:function(){for(var t=[],e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];n instanceof is?"loading"===n.drawingObject.state&&t.push(n):t=[].concat(Ga(t),Ga(n.getLoadingElements()))}return t}},{key:"setPointsFromDefinition",value:function(){for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];null!=e.setPointsFromDefinition&&e.setPointsFromDefinition()}}},{key:"setPrimitiveColors",value:function(){for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];e instanceof is?(e.setColor(e.color,!1),e.setOpacity(e.opacity)):e.setPrimitiveColors()}}},{key:"unrenderAll",value:function(){this.unrender();for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];e instanceof is?e.unrender():e.unrenderAll()}}},{key:"setScenarios",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];qa(Va(e.prototype),"setScenarios",this).call(this,t);for(var i=0;i<this.drawOrder.length;i+=1){var r=this.elements[this.drawOrder[i]];(n&&r.isShown||!1===n)&&r.setScenarios(t,n)}}},{key:"saveScenarios",value:function(t,n){qa(Va(e.prototype),"saveScenarios",this).call(this,t,n);for(var i=0;i<this.drawOrder.length;i+=1)this.elements[this.drawOrder[i]].saveScenarios(t,n)}},{key:"animateToState",value:function(t,n){var i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,o=0;if(o=qa(Va(e.prototype),"animateToState",this).call(this,t,n,i,r),!1===this.dependantTransform||!1===i)for(var a=0;a<this.drawOrder.length;a+=1){var s=this.elements[this.drawOrder[a]];null==t.elements||null==t.elements[this.drawOrder[a]]||o<(s=s.animateToState(t.elements[this.drawOrder[a]],n,i,r))&&(o=s)}return o}},{key:"dissolveInToState",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.8,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=0;if(0===(r=qa(Va(e.prototype),"dissolveInToState",this).call(this,t,n,i)))return 0;for(var o=0;o<this.drawOrder.length;o+=1){var a=this.elements[this.drawOrder[o]];null==t.elements||null==t.elements[this.drawOrder[o]]||r<(a=a.dissolveInToState(t.elements[this.drawOrder[o]],n,i))&&(r=a)}return r}},{key:"setTimeDelta",value:function(t){qa(Va(e.prototype),"setTimeDelta",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setTimeDelta(t)}},{key:"isStateSame",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];if(!1===qa(Va(e.prototype),"isStateSame",this).call(this,t,n,i))return!1;for(var r=0;r<this.drawOrder.length;r+=1){var o=this.elements[this.drawOrder[r]];if(null!=t.elements&&null!=t.elements[this.drawOrder[r]]&&!1===o.isStateSame(t.elements[this.drawOrder[r]],n,i))return!1}return!0}},{key:"clearFrozenPulseTransforms",value:function(){qa(Va(e.prototype),"clearFrozenPulseTransforms",this).call(this);for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].clearFrozenPulseTransforms()}},{key:"freezePulseTransforms",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];qa(Va(e.prototype),"freezePulseTransforms",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].freezePulseTransforms(t)}},{key:"isAnimating",value:function(){if(!1===this.isShown)return!1;if(qa(Va(e.prototype),"isAnimating",this).call(this))return!0;for(var t=0;t<this.drawOrder.length;t+=1)if(this.elements[this.drawOrder[t]].isAnimating())return!0;return!1}},{key:"remove",value:function(t){var e;null!=this.elements[t]&&((e=this.elements[t]).animations.cancelAll("freeze",!0),e.stop(),e.parent=null,e.animations=null,e.move.element=null,e.recorder=null,e.figure=null,delete this.elements["_".concat(t)],delete this.elements[t],-1!==(t=this.drawOrder.indexOf(t))&&this.drawOrder.splice(t,1))}},{key:"stopAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];if(qa(Va(e.prototype),"stopAnimating",this).call(this,t,n),i)for(var r=0;r<this.drawOrder.length;r+=1)this.elements[this.drawOrder[r]].stopAnimating(t,n,i)}},{key:"stateSet",value:function(){qa(Va(e.prototype),"stateSet",this).call(this);for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].stateSet()}},{key:"_state",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(this.notifications.publish("getState"),e=null==(e=t.returnF1Type)||e)return{f1Type:"de",state:this.getPath()};var e=(e=ct({},t,{returnF1Type:!0})).min?ci(this,this._getStatePropertiesMin(),e):ci(this,this._getStateProperties(e),e);return t=ci(this.elements,Object.keys(this.elements),t),e.elements=t,e}},{key:"align",value:function(t,e){var n=this.getBoundingRect("draw"),i=new pe(0,0);i.x="left"===t?-n.left:"center"===t?-n.left+n.width/2:"right"===t?-n.right:-n.left+n.width*t,i.y="bottom"===e?-n.bottom:"middle"===e?-n.bottom+n.height/2:"top"===e?-n.top:-n.bottom+n.height*e;for(var r=0;r<this.drawOrder.length;r+=1){var o=this.elements[this.drawOrder[r]],a=o.transform.t();o.transform.updateTranslation(a.add(i))}}}]),e}();function os(t,e,n){return(os=function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),1}catch(t){return}}}()?Reflect.construct:function(t,e,n){var i=[null];return i.push.apply(i,e),i=new(Function.bind.apply(t,i)),n&&as(i,n.prototype),i}).apply(null,arguments)}function as(t,e){return(as=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var ss=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);for(var n,i={finishedCallback:null},r=arguments.length,o=new Array(1<r?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return e instanceof ns?(n=ct.apply(void 0,[{},i].concat(o))).element=e:n=ct.apply(void 0,[{},i,e].concat(o)),this.timeKeeper=n.timeKeeper,this.recorder=n.recorder,this.element=n.element,this.animations=[],this.state="idle",this.options={translation:{}},this.fnMap=new G,this.finishedCallback=n.finishedCallback,this.notifications=new jt,this.customSteps=[],this.animationSpeed=1,this}var e=[{key:"new",value:function(t){var e={customSteps:this.customSteps,timeKeeper:this.timeKeeper};return null!=this.element&&(e.element=this.element),null!=t&&(e.name=t),e=new ms(e),this.animations.push(e),null!=this.element&&this.element.animateNextFrame(),e}},{key:"setTimeSpeed",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;this.animations.forEach((function(n){n.setTimeSpeed(t.animationSpeed,e,t.timeKeeper.now()/1e3)})),this.animationSpeed=e}},{key:"builder",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return os(ms,[this.element,{customSteps:this.customSteps,timeKeeper:this.timeKeeper}].concat(e))}},{key:"rotation",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="number"==typeof t?{target:t}:t),this.getStep(t,"RotationAnimationStep")}},{key:"scale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return t="number"==typeof t&&null==e?{target:[t,t]}:"number"==typeof t?{target:[t,e]}:en(t)?{target:ue(t)}:t,t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ScaleAnimationStep")}},{key:"trigger",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="function"==typeof t||"string"==typeof t?{callback:t}:t),new lo(t)}},{key:"custom",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="string"==typeof t||"function"==typeof t?{callback:t}:t),new go(t)}},{key:"delay",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),new Ro(t)}},{key:"translation",value:function(t){this.position(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"position",value:function(t){return t="number"==typeof t?{target:[t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0]}:en(t)?{target:ue(t)}:t,t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"PositionAnimationStep")}},{key:"color",value:function(t){return t=Array.isArray(t)?{target:t}:t,t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ColorAnimationStep")}},{key:"opacity",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="number"==typeof t?{target:t}:t),this.getStep(t,"OpacityAnimationStep")}},{key:"transform",value:function(t){return t=Me(t)?{target:Be(t)}:t,t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"TransformAnimationStep")}},{key:"pulseTransform",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{element:this.element,timeKeeper:this.timeKeeper}].concat(e));return this.getStep(i,"PulseTransformAnimationStep")}},{key:"pulse",value:function(t){return(t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="number"==typeof t?{scale:t}:t)).centerOn?new to(t):this.getStep(t,"PulseAnimationStep")}},{key:"dissolveIn",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DissolveInAnimationStep")}},{key:"dissolveOut",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DissolveOutAnimationStep")}},{key:"dim",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DimAnimationStep")}},{key:"undim",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"UndimAnimationStep")}},{key:"getStep",value:function(t,e){if(t.timeKeeper=this.timeKeeper,"string"==typeof t.element&&null!=this.element&&(t.element=this.element.getElement(t.element)),null==t.elements||null==t.element)return new u[e](t);var n=t.element.getElements(t.elements),i=[];return t.elements=void 0,n.forEach((function(n){t.element=n,i.push(new u[e](t))})),new Ki(t,{steps:i})}},{key:"scenario",value:function(t){return t="string"==typeof t||void 0!==t.transform||void 0!==t.position||void 0!==t.rotation||void 0!==t.scale||void 0!==t.translation||void 0!==t.color||void 0!==t.isShown?{target:t}:t,t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ScenarioAnimationStep")}},{key:"scenarios",value:function(t){var e="string"==typeof t?{target:t}:t,n=(e=(t=ct({},{element:this.element,timeKeeper:this.timeKeeper},e)).element.getAllElementsWithScenario(t.target),[]),i={};return ht(t,i,["steps","element"]),e.forEach((function(t){n.push(t.animations.scenario(i))})),new Ki(i,{steps:n})}},{key:"_state",value:function(t){return ci(this,["animations","state","options","element"],t)}},{key:"setTimeDelta",value:function(t){this.animations.forEach((function(e){e.setTimeDelta(t)}))}},{key:"willStartAnimating",value:function(){if("animating"===this.state)return!0;var t=!1;return this.animations.forEach((function(e){"waitingToStart"!==e.state&&"animating"!==e.state||(t=!0)})),t}},{key:"isAnimating",value:function(){if("animating"===this.state||"waitingToStart"===this.state)return!0;for(var t=0;t<this.animations.length;t+=1){var e=this.animations[t];if("waitingToStart"===e.state||"animating"===e.state)return!0}return!1}},{key:"nextFrame",value:function(t){var e=this,n=[],i=null,r=!1;this.animations.forEach((function(o,a){var s,l=!1;"waitingToStart"!==o.state&&"animating"!==o.state||((s=o.nextFrame(t,e.animationSpeed))<(i=null===i?s:i)&&(i=s),l=!0),"finished"===o.state&&o.removeOnFinish&&(l=!1,n.push(a)),l&&(r=!0)}));var o=null;r?this.state="animating":("animating"===this.state&&(this.state="idle",o=this.finishedCallback,this.notifications.publish("finished")),this.state="idle");for(var a=n.length-1;0<=a;--a)this.animations.splice(n[a],1);return this.fnMap.exec(o),i}},{key:"cleanAnimations",value:function(){for(var t=[],e=!1,n=0;n<this.animations.length;n+=1){var i=this.animations[n];"finished"===i.state&&i.removeOnFinish?t.push(n):"animating"!==i.state&&"waitingToStart"!==i.state||(e=!0)}for(var r=t.length-1;0<=r;--r)this.animations.splice(t[r],1);e?this.state="animating":("animating"===this.state&&(this.state="idle",this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),this.state="idle")}},{key:"cancel",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(null==t)this.cancelAll(e);else{for(var n=0;n<this.animations.length;n+=1){var i=this.animations[n];i.name===t&&i.cancel(e)}this.cleanAnimations()}}},{key:"get",value:function(t){for(var e=0;e<this.animations.length;e+=1)if(this.animations[e].name===t)return this.animations[e];return null}},{key:"cancelAll",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=0;n<this.animations.length;n+=1)!e&&this.animations[n].name.startsWith("_noStop_")||this.animations[n].cancel(t);this.cleanAnimations()}},{key:"getFrameTime",value:function(t){this.timeKeeper.getWhen(t)}},{key:"start",value:function(t){var e=(t=ct({},t,{name:null,startTime:"nextFrame"})).name,n=(t=t.startTime,this.getFrameTime(t));if(null==e)this.startAll(t);else for(var i=0;i<this.animations.length;i+=1){var r=this.animations[i];r.name===e&&"animating"!==r.state&&(r.start(n),r.finishIfZeroDuration(),"animating"===r.state&&(this.state="animating"))}"idle"===this.state&&(this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),null!=this.element&&this.element.animateNextFrame()}},{key:"startAll",value:function(t){t=ct({},t,{startTime:"nextFrame"}).startTime;for(var e=this.getFrameTime(t),n=0;n<this.animations.length;n+=1){var i=this.animations[n];"animating"!==i.state&&(i.start(e),i.finishIfZeroDuration(),"animating"===i.state&&(this.state="animating"))}"idle"===this.state&&(this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),null!=this.element&&this.element.animateNextFrame()}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.animations.length;e+=1){var n=this.animations[e].getTotalDuration();if(null==n)return null;t<n&&(t=n)}return t}},{key:"getRemainingTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.timeKeeper.now()/1e3,n=0,i=[];return i="string"==typeof t?[t]:t,this.animations.forEach((function(t){0<i.length&&-1===i.indexOf(t.name)||(t=t.getRemainingTime(e),n<t&&(n=t))})),n}},{key:"getNextAnimationFinishTime",value:function(){for(var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3,n=!1,i=0;i<this.animations.length;i+=1){var r=this.animations[i].getRemainingTime(e);null===r?n=!0:(0<r&&void 0===t||0<r&&r<t)&&(t=r)}return void 0===t?n?null:0:t}},{key:"addTo",value:function(t){for(var e=0;e<this.animations.length;e+=1){var n=this.animations[e];if(n.name===t)return n}return this.new(t)}},{key:"newFromStep",value:function(t){return this.animations.push(t),t}},{key:"_dup",value:function(){var e=new t;return ht(this,e,["element","recorder","timeKeeper"]),e.element=this.element,e.recorder=this.recorder,e.timeKeeper=this.timeKeeper,e}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function ls(t){return(ls="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function us(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function cs(t,e,n){return(cs="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ps(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function hs(t,e){return(hs=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function fs(t,e){if(e&&("object"===ls(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return ds(t)}function ds(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ps(t){return(ps=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ms=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&hs(t,e)}(r,Oo);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=ps(e);return fs(this,n?(t=ps(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var n,o={customSteps:[]},a=arguments.length,s=new Array(1<a?a-1:0),l=1;l<a;l++)s[l-1]=arguments[l];return e instanceof ns?(n=ct.apply(void 0,[{},o].concat(s))).element=e:n=ct.apply(void 0,[{},o,e].concat(s)),(t=i.call(this,n)).element=n.element,t._stepType="builder",n.customSteps.forEach((function(e){t[e.name]=function(){for(var n={element:t.element},i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return n=ct.apply(void 0,[{},n].concat(r)),t.then(e.step(n)),ds(t)}})),fs(t,ds(t))}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(i)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(i))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return us(t)}(t=cs(ps(r.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return us(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?us(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["element"]);var t}},{key:"_getStateName",value:function(){return"animationBuilder"}},{key:"custom",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="string"==typeof t||"function"==typeof t?{callback:t}:t),this.then(new go(t)),this}},{key:"rotation",value:function(t){return this.addStep("rotation",t)}},{key:"position",value:function(t){return this.addStep("position",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"translation",value:function(t){return this.position(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"scale",value:function(t){return this.addStep("scale",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)}},{key:"transform",value:function(t){return this.addStep("transform",t)}},{key:"pulseTransforms",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.addStep.apply(this,["pulseTransform"].concat(e))}},{key:"scenario",value:function(t){return this.addStep("scenario",t)}},{key:"scenarios",value:function(t){return this.addStep("scenarios",t)}},{key:"color",value:function(t){return this.addStep("color",t)}},{key:"opacity",value:function(t){return this.addStep("opacity",t)}},{key:"dissolveOut",value:function(){return this.addStep("dissolveOut",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dissolveIn",value:function(){return this.addStep("dissolveIn",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"addStep",value:function(t){if(null!=this.element){for(var e,n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.then((e=this.element.animations)[t].apply(e,i))}return this}},{key:"dim",value:function(){return this.addStep("dim",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"undim",value:function(){return this.addStep("undim",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"delay",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ct({},{timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.then(Fo(t)),this}},{key:"trigger",value:function(t){return t=ct({},{element:this.element,timeKeeper:this.timeKeeper},t="function"==typeof t||"string"==typeof t?{callback:t}:t),this.then(uo(t)),this}},{key:"inParallel",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.then(Ui.apply(u,[t,{timeKeeper:this.timeKeeper}].concat(n))),this}},{key:"inSerial",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return this.then(_o.apply(u,[t,{timeKeeper:this.timeKeeper}].concat(n))),this}},{key:"pulse",value:function(t){return this.addStep("pulse",t)}},{key:"reset",value:function(){this.steps=[],this.state="idle"}},{key:"_dup",value:function(){var t=new r;return ht(this,t,["element"]),ht(this,t,["element","timeKeeper"]),t.timeKeeper=this.timeKeeper,t.element=this.element,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();const ys=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.figure=e,this.start=this.figure.touchDownHandlerClient.bind(this.figure),this.end=this.figure.touchUpHandler.bind(this.figure),this.move=this.figure.touchMoveHandlerClient.bind(this.figure),this.free=this.figure.touchFreeHandler.bind(this.figure),this.toggleCursor=this.figure.toggleCursor.bind(this.figure),this.binds={mouseDownHandler:this.mouseDownHandler.bind(this),mouseUpHandler:this.mouseUpHandler.bind(this),mouseMoveHandler:this.mouseMoveHandler.bind(this),touchStartHandler:this.touchStartHandler.bind(this),touchEndHandler:this.touchEndHandler.bind(this),touchMoveHandler:this.touchMoveHandler.bind(this)},this.addEvent("mousedown",this.binds.mouseDownHandler,!1),this.addWindowEvent("mouseup",this.binds.mouseUpHandler,!1),this.addEvent("mousemove",this.binds.mouseMoveHandler,!1),this.addEvent("touchstart",this.binds.touchStartHandler,!1),this.addWindowEvent("touchend",this.binds.touchEndHandler,!1),this.addEvent("touchmove",this.binds.touchMoveHandler,!1),this.enable=!0}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,[{key:"addEvent",value:function(t,e,n){this.figure.gestureCanvas.addEventListener(t,e.bind(this),n)}},{key:"addWindowEvent",value:function(t,e,n){window.addEventListener(t,e.bind(this),n)}},{key:"removeEvent",value:function(t,e,n){this.figure.gestureCanvas.removeEventListener(t,e.bind(this),n)}},{key:"startHandler",value:function(t){return!!this.enable&&(this.mouseDown=!0,this.previousPoint=t,this.start(t))}},{key:"endHandler",value:function(){this.mouseDown=!1,this.end(!1,!0)}},{key:"moveHandler",value:function(t,e){this.enable&&this.mouseDown?(this.move(this.previousPoint,e)&&t.preventDefault(),this.previousPoint=e):this.free(e)}},{key:"touchStartHandler",value:function(t){var e=t.touches[0];this.startHandler(new pe(e.clientX,e.clientY))&&t.preventDefault()}},{key:"mouseDownHandler",value:function(t){this.startHandler(new pe(t.clientX,t.clientY))&&t.preventDefault()}},{key:"touchMoveHandler",value:function(t){var e=t.touches[0];this.moveHandler(t,new pe(e.clientX,e.clientY))}},{key:"mouseMoveHandler",value:function(t){this.moveHandler(t,new pe(t.clientX,t.clientY))}},{key:"mouseUpHandler",value:function(){this.endHandler()}},{key:"touchEndHandler",value:function(){this.endHandler()}},{key:"destroy",value:function(){this.removeEvent("mousedown",this.binds.mouseDownHandler,!1),this.removeEvent("mouseup",this.binds.mouseUpHandler,!1),this.removeEvent("mousemove",this.binds.mouseMoveHandler,!1),this.removeEvent("touchstart",this.binds.touchStartHandler,!1),this.removeEvent("touchend",this.binds.touchEndHandler,!1),this.removeEvent("touchmove",this.binds.touchMoveHandler,!1)}}]),t}(),vs=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.canvas=e,this.ctx=this.canvas.getContext("2d");var n=this.ctx.webkitBackingStorePixelRatio||this.ctx.mozBackingStorePixelRatio||this.ctx.msBackingStorePixelRatio||this.ctx.oBackingStorePixelRatio||this.ctx.backingStorePixelRatio||1;1===(e=window.devicePixelRatio||1)&&(e=2),this.ratio="number"==typeof n?e/n:1,this.resize()}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,[{key:"resize",value:function(){this.ctx.setTransform(1,0,0,1,0,0),this.canvas.width=this.canvas.clientWidth*this.ratio,this.canvas.height=this.canvas.clientHeight*this.ratio,this.ctx.scale(this.ratio,this.ratio)}},{key:"_dup",value:function(){return this}}]),t}();function gs(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function bs(t,e){var n="",i="";return null!=(e=1<arguments.length&&void 0!==e?e:null)&&(i=' style="margin-top:'.concat(e,'%"')),Array.isArray(t)?t.forEach((function(t,e){t.startsWith("<")?n+=t:n+=(0===e?'<p style="margin-top:'.concat(i,'">'):"<p>").concat(t,"</p>")})):n=t,n}function ws(){var t=bs(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",0);return'<div style="display: table; height: 100%; width: 100%;">\n <div style="display: table-cell; vertical-align: middle; height: 100%; width: 100%;">\n '.concat(t,"</div></div>")}function xs(){var t=bs(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"");return'<div style="text-align:center;">\n '.concat(t,"</div>")}var Ss=function(t,e){return'<span class="figureone__unit_deg">'.concat(t,'</span><span class="figureone__unit_rad">').concat(e,"</span>\n ")};function Ts(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r="";return e&&(r=' id="'.concat(e,'"')),e="",n&&(e=' class="'.concat(n,'"')),n="",i&&(n=' style="color:'.concat(Ri(i),';"')),{replacementText:"<span".concat(r).concat(e,'"').concat(n,">").concat(t.replace(RegExp(/_/,"gi")," ").trim(),"</span>")}}function As(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i="action_word",r=null,o=s={color:null,id:"figureone__id_".concat(dt()),interactive:!0,classes:"",text:null};Array.isArray(n)?r=n:null!=n&&(o=ct(s,n));var a=o,s=a.interactive,l=(n=a.color,a.id),u=(o=a.classes,a.text);return null!=n&&(r=n),s&&(i="".concat(i," interactive_word")),""!==o&&(i="".concat(i," ").concat(o)),{replacementText:function(t){return Ts(u||t,l,i,r)},id:function(){return l},actionMethod:t,bind:e}}function ks(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",r=document.getElementById(t);r&&(r.classList.add("action_word_enabled"),i.split(" ").forEach((function(t){t&&r.classList.add(t)})),r.onclick=function(){var t;e.bind.apply(e,function(t){if(Array.isArray(t))return gs(t)}(t=n)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return gs(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?gs(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())()})}function Os(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"highlight_word",i=3<arguments.length&&void 0!==arguments[3]&&arguments[3],r=t;return Object.keys(e).forEach((function(t){var n=e[t],i=r,o=t,a=n;t=new RegExp("\\|".concat(o,"\\|"),"gi"),n="string"==typeof a?a:("string"==typeof a.replacementText?a:a.replacementText(o)).replacementText,r=i.replace(t,n)})),t=RegExp(/\|([^|]*)\|/gi),r=r.replace(t,'<span class="'.concat(n,'">$1</span>')),i&&(i=RegExp(/style="color:rgba\([^)]*\);"/gi),r=r.replace(i,""),i=RegExp(/highlight_word/gi),r=r.replace(i,""),i=RegExp(/interactive_word/gi),r=r.replace(i,""),i=RegExp(/id="[^"]*"/gi),r=r.replace(i,"")),r}function _s(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";Object.keys(t).forEach((function(n){var i=t[n];"string"!=typeof i&&"actionMethod"in i&&ks("string"==typeof i.id?i.id:i.id(n),i.actionMethod,i.bind,e)}))}function Ps(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";e=Os(e,n),t.innerHTML=e,_s(n,i)}function Es(t){return(Es="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ms(t,e){return(Ms=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Bs(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Cs(t){return(Cs=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var js=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ms(t,e)}(i,is);var t,e,n=(t=i,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,i=Cs(t);return function(t,e){if(e&&("object"===Es(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Bs(t)}(this,e?(n=Cs(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))});function i(){var t;!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e,r,o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return r=function(e){return"string"==typeof e?t.shapeNameMap[e]:e},"getIndex"in(e=Bs(t=n.call.apply(n,[this].concat(a))))?Object.defineProperty(e,"getIndex",{value:r,enumerable:!0,configurable:!0,writable:!0}):e.getIndex=r,t}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,[{key:"setPointsBetween",value:function(t,e,n){this.drawingObject.updateUniform("u_from",this.getIndex(t)),this.drawingObject.updateUniform("u_to",this.getIndex(e)),this.drawingObject.updateUniform("u_percent",n)}},{key:"setPoints",value:function(t){this.drawingObject.updateUniform("u_from",this.getIndex(t)),this.drawingObject.updateUniform("u_to",this.getIndex(t)),this.drawingObject.updateUniform("u_percent",0)}}]),i}();function Rs(t){return(Rs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fs(t,e){return(Fs=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ds(t){return(Ds=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Is=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Fs(t,e)}(r,ma);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Ds(e);return function(t,e){if(e&&("object"===Rs(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ds(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){var n;return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),(n=i.call(this,t,"withTexture","text")).glPrimitive=t.gl.TRIANGLE_FAN,e=ct({},{text:"DEFAULT_TEXT",size:"20px",family:"Helvetica",style:"normal",weight:400,xAlign:"center",yAlign:"alphabetic",id:dt("vertexText")},e),n.size=e.size,n.text=e.text,n.family=e.family,n.xAlign=e.xAlign,n.yAlign=e.yAlign,n.style=e.style,n.weight=e.weight,n.canvas=document.createElement("canvas"),n.canvas.id=e.id,n.ctx=n.canvas.getContext("2d"),n.texture={id:e.id,mapTo:new fe(-1,-1,2,2),mapFrom:new fe(0,0,1,1),repeat:!1,src:"",points:[],buffer:n.gl.createBuffer(),type:"image",data:null},n.type="vertexText",n.drawTextIntoBuffer(),n}return t=[{key:"resizeText",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(1,1),n=this.canvas.width*e.x,i=this.canvas.height*e.y,r=new pe(0,0);"center"===this.xAlign?r.x=-n/2:"right"===this.xAlign&&(r.x=-n),"baseline"===this.yAlign?r.y=.25*-i:"top"===this.yAlign?r.y=-i:"middle"===this.yAlign&&(r.y=-i/2),e=[r,new pe(r.x,r.y+i),new pe(r.x+n,r.y+i),new pe(r.x+n,r.y)],this.width=n,this.height=i,this.calcAscentDescent(),this.points=[],e.forEach((function(e){t.points.push(e.x),t.points.push(e.y)})),this.border=[[new pe(r.x,-this.descent),new pe(r.x,this.ascent),new pe(r.x+n,this.ascent),new pe(r.x+n,-this.descent)]],null!=(n=this.texture)&&(n.points=[0,0,0,1,1,1,1,0],n.data=this.ctx.canvas,n.buffer&&this.resetBuffers())}},{key:"calcAscentDescent",value:function(){var t=.75,e=0,n=this.text.match(/[,.]/g);Array.isArray(n)&&n.length===this.text.length&&(t=.1),n=this.text.match(/[acemnorsuvwxz*gyq:><;p=]/g),Array.isArray(n)&&n.length===this.text.length&&(t=.5),n=this.text.match(/[;,$]/g),Array.isArray(n)&&0<n.length&&(e=.1),n=this.text.match(/[gjyqp@Q(){}[\]|]/g),Array.isArray(n)&&0<n.length&&(e=.25),this.ascent=t*this.height,this.descent=e*this.height}},{key:"drawTextIntoBuffer",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(1,1),e=20;(e="string"==typeof this.size&&this.size.endsWith("px")?parseInt(this.size,10):d(("string"==typeof this.size?parseFloat(this.size):this.size)/t.x,0))<1&&(e=1),this.ctx.font="".concat(this.style," ").concat(this.weight," ").concat(e,"px ").concat(this.family);var n=this.ctx.measureText(this.text).width+.3*e,i=1.15*e;this.canvas.width=Math.max(n,1),this.canvas.height=Math.max(i,1),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.font="".concat(this.style," ").concat(this.weight," ").concat(e,"px ").concat(this.family),this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",this.ctx.fillStyle="white",i=.75*this.canvas.height,this.ctx.fillText(this.text,.3*e/2,i),this.resizeText(t)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ls(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ws(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return zs(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zs(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zs(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ns(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function qs(t,e,n,i){var r=!(2<arguments.length&&void 0!==n)||n,o=3<arguments.length&&void 0!==i?i:"negative";if("number"!=typeof e)return e;if(0===e)return t;var a=[];return t.forEach((function(t){for(var n,i=[],s=[],l=0;l<t.length;l+=1){var u=0===l?t[t.length-1]:t[l-1];u=We(l===t.length-1?(function(t){if(Array.isArray(t))return t}(n=t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,i,r=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(r.push(n.value),1!==r.length);o=!0);}catch(t){a=!0,i=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw i}}return r}}(n)||function(t){if(t){if("string"==typeof t)return Ns(t,1);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ns(t,1):void 0}}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]:t[l+1],t[l],u),(r&&u<Math.PI||!1===r)&&(0===i.length||t[l].isNotEqualTo(i[i.length-1]))&&(i.push(t[l]),s.push(l))}for(var c=[],h=[],f=0;f<i.length;f+=1){var d=void 0;d=0===f?new Se(i[i.length-1],i[0]):new Se(i[f-1],i[f]),h.push(d.offset(o,e))}for(var p=0;p<h.length;p+=1){var m,y=void 0,v=(y=0===p?h[h.length-1]:h[p-1],h[p]),g=v.intersectsWith(y);null!=g.intersect&&(m=void 0,m=0===p?i[i.length-1]:i[p-1],g.intersect.distance(m)>1.2*e?(m=new Se(m,g.intersect),m=new Se(m.pointAtLength(1.2*e),1,m.angle()+Math.PI/2),y=y.intersectsWith(m),m=v.intersectsWith(m),null!=y.intersect&&null!=m.intersect?(c.push(y.intersect),c.push(m.intersect)):c.push(g.intersect)):c.push(g.intersect))}a.push(c)})),a}function Hs(t){return function(t){if(Array.isArray(t))return Vs(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Us(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ks(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Us(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Us(t,e){if(t){if("string"==typeof t)return Vs(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vs(t,e):void 0}}function Vs(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Gs(t,e){function n(e){var n,i=t[e];null!=i&&"string"!=typeof i&&"number"!=typeof i&&(n=function t(e){for(var n=0;n<e.length;n+=1)Array.isArray(e[n])&&"number"!=typeof e[n][0]?e[n]=t(e[n]):e[n]=ue(e[n]);return e},Array.isArray(i)&&"number"!=typeof i[0]?t[e]=n(i):t[e]=ue(i))}"string"==typeof e?n(e):e.forEach(n)}function Ys(t,e){null!=e.pulse&&"function"!=typeof t.pulseDefault&&"string"!=typeof t.pulseDefault&&("number"==typeof e.pulse?t.pulseDefault.scale=e.pulse:t.pulseDefault=ct({},t.pulseDefault,e.pulse))}var Xs=function(){function t(e,n,i,r,o,a,s,l,u,c,h,f,d){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),Array.isArray(e)?this.webgl=e:this.webgl=[e],Array.isArray(n)?this.draw2D=n:this.draw2D=[n],this.htmlCanvas=i,this.limits=r,this.animateNextFrame=a,this.spaceTransforms=o,this.defaultColor=s,this.defaultDimColor=l,this.defaultFont=u,this.defaultLineWidth=c,this.defaultLength=h,this.timeKeeper=f,this.recorder=d}var e=[{key:"gl",value:function(){for(var t={name:dt("primitive_"),color:this.defaultColor,vertexShader:"simple",fragShader:"simple",texture:{src:"",mapTo:new fe(-1,-1,2,2),mapFrom:new fe(0,0,1,1),repeat:!1,onLoad:this.animateNextFrame},glPrimitive:"TRIANGLES"},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];(t=ct.apply(void 0,[{},t].concat(n))).transform=Be(t.transform),null!=t.position&&(t.position=ue(t.position),t.transform.updateTranslation(t.position));var r=new aa(this.webgl[0],t.vertexShader,t.fragShader);r.setPrimitive(t.glPrimitive),null!=t.vertices&&r.addVertices(t.vertices.data,t.vertices.usage),null!=t.buffers&&(t.buffers.forEach((function(t){t=ct({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:2},t),r.addBuffer(t.name,t.size,t.data,t.type,t.normalize,t.stride,t.offset,t.usageIn)})),null!=t.uniforms&&t.uniforms.forEach((function(t){t=ct({},{type:"FLOAT",length:1},t),r.addUniform(t.name,t.length,t.type)})),""!==t.texture.src&&(o=t.texture,r.addTexture(o.src,o.mapTo,o.mapFrom,o.repeat,o.onLoad)));var o=new is(r,t.transform,t.color,this.limits,null,t.name);return o.custom.updateBuffer=o.drawingObject.updateBuffer.bind(o.drawingObject),o.custom.updateVertices=o.drawingObject.updateVertices.bind(o.drawingObject),o.custom.updateUniform=o.drawingObject.updateUniform.bind(o.drawingObject),o.custom.getUniform=o.drawingObject.getUniform.bind(o.drawingObject),o.dimColor=this.defaultDimColor.slice(),o.timeKeeper=this.timeKeeper,o.recorder=this.recorder,Ys(o,t),o}},{key:"morph",value:function(){for(var t=this,e={name:dt("primitive_"),color:this.defaultColor,points:[],glPrimitive:"TRIANGLES",transform:new Ee("morph").scale(1,1).rotate(0).translate(0,0),position:[0,0]},n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];var o=ct.apply(void 0,[{},e].concat(i));o.transform=Be(o.transform),null!=o.position&&(o.position=ue(o.position),o.transform.updateTranslation(o.position));var a=!1;e="simple",Array.isArray(o.color[0])&&(a=!0,e="vertexColor");var s=new aa(this.webgl[0],["morpher",o.points.length,a],e);s.setPrimitive(o.glPrimitive);var l={};null!=o.names&&o.names.forEach((function(t,e){l[t]=e})),o.points.forEach((function(t,e){var n="a_pos".concat(e);s.numVertices=t.length/2,e=ct({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:2}),s.addBuffer(n,e.size,t,e.type,e.normalize,e.stride,e.offset,e.usageIn)})),a&&(o.color.forEach((function(t,e){if(4===(n=t).length)for(var n=Array(4*s.numVertices),i=0;i<n.length;i+=4)n[i]=t[0],n[i+1]=t[1],n[i+2]=t[2],n[i+3]=t[3];var r="a_col".concat(e);e=ct({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:4}),s.addBuffer(r,e.size,n,e.type,e.normalize,e.stride,e.offset,e.usageIn)})),o.color=this.defaultColor),s.addUniform("u_from",1,"INT"),s.addUniform("u_to",1,"INT"),s.addUniform("u_percent",1,"FLOAT");var u=new js(s,o.transform,o.color,this.limits,null,o.name);return u.shapeNameMap=l,u.setPoints(0),u.fnMap.add("_morphCallback",(function(t,e){var n=e.start;e=e.target,u.setPointsBetween(n,e,t)})),u.animations.morph=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},{progression:"easeinout",element:u}].concat(n));return r.customProperties={start:null==r.start?0:r.start,target:null==r.target?1:r.target},r.callback="_morphCallback",r.timeKeeper=t.timeKeeper,new go(r)},u.animations.customSteps.push({step:u.animations.morph.bind(this),name:"morph"}),u.timeKeeper=this.timeKeeper,u.recorder=this.recorder,Ys(u,o),u}},{key:"generic",value:function(){for(var t={name:dt("primitive_"),color:this.defaultColor,transform:new Ee("generic").standard(),texture:{src:"",mapTo:new fe(-1,-1,2,2),mapFrom:new fe(0,0,1,1),repeat:!1,onLoad:this.animateNextFrame}},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];(t=ct.apply(void 0,[{},t].concat(n))).transform=Be(t.transform),null!=t.position&&(t.position=ue(t.position),t.transform.updateTranslation(t.position));var r=function(t,e,n,i,r,o,a,s,l,u){return r=4<arguments.length&&void 0!==r?r:"",o=5<arguments.length&&void 0!==o?o:new fe(-1,-1,2,2),a=6<arguments.length&&void 0!==a?a:new fe(0,0,1,1),s=7<arguments.length&&void 0!==s&&s,l=8<arguments.length&&void 0!==l?l:null,u=9<arguments.length&&void 0!==u?u:"",s=new ma(t,r,de(o),de(a),s),r&&(s.onLoad=l),l=new Ee,l=n instanceof pe?l.translate(n.x,n.y):n._dup(),new is(s,l,e,i,null,u)}(this.webgl[0],t.color,t.transform,this.limits,t.texture.src,t.texture.mapTo,t.texture.mapFrom,t.texture.repeat,t.texture.onLoad,t.name);return r.dimColor=this.defaultDimColor.slice(),r.custom.updateGeneric=function(t){null==t.copy||Array.isArray(t.copy)||(t.copy=[t.copy]),null!=t.points&&(t.points=ce(t.points)),null!=t.drawBorder?r.drawBorder=nn(t.drawBorder):null!=t.points&&(r.drawBorder=[t.points]),null!=t.drawBorderBuffer?r.drawBorderBuffer=nn(t.drawBorderBuffer):r.drawBorderBuffer=r.drawBorder,null!=t.border&&(r.border=nn(t.border)),null!=t.touchBorder&&(r.touchBorder=nn(t.touchBorder)),null!=t.holeBorder&&(r.holeBorder=nn(t.holeBorder)),r.drawingObject.change(t)},r.custom.updateGeneric(t),r.custom.updatePoints=r.custom.updateGeneric,r.timeKeeper=this.timeKeeper,r.recorder=this.recorder,Ys(r,t),r}},{key:"getPolylineTris",value:function(t){var e,n,i,r;!1===(t=ct({},{points:[[0,0],[1,0]],width:this.defaultLineWidth,color:this.defaultColor,close:!1,widthIs:"mid",cornerStyle:"auto",cornerSize:.01,cornerSides:10,cornersOnly:!1,cornerLength:.1,minAutoCornerAngle:Math.PI/7,dash:[],linePrimitives:!1,lineNum:1,drawBorder:"negative",holeBorder:[[]],drawBorderBuffer:0,simple:!1},t)).linePrimitives&&(t.lineNum=2),Gs(t,["points","border","holeBorder","touchBorder"]),o=t.simple?(e=(r=Ks(Kn(t.points,t.width,t.close),4))[0],n=r[1],i=r[2],r[3]):t.cornersOnly?(e=(r=Ks(qn(t.points,t.width,t.close,t.cornerLength,t.widthIs,t.cornerStyle,t.cornerSize,t.cornerSides,t.minAutoCornerAngle,t.linePrimitives,t.lineNum,t.drawBorderBuffer),4))[0],n=r[1],i=r[2],r[3]):(e=(o=Ks(Nn(t.points,t.width,t.close,t.widthIs,t.cornerStyle,t.cornerSize,t.cornerSides,t.minAutoCornerAngle,t.dash,t.linePrimitives,t.lineNum,t.drawBorder,t.drawBorderBuffer,t.hole,t.arrow),4))[0],n=o[1],i=o[2],o[3]),Array.isArray(t.drawBorderBuffer)&&(i=nn(t.drawBorderBuffer)),Array.isArray(t.drawBorder)&&(n=nn(t.drawBorder)),null==i&&(i=n),null==t.holeBorder&&(t.holeBorder=o);var o="triangles";return t.linePrimitives&&(o="lines"),[t,e,n,i,o=t.simple?"strip":o]}},{key:"polyline",value:function(){for(var t=this,e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{}].concat(n)),o=this.generic.apply(this,[{transform:new Ee("polyline").standard(),border:"draw",touchBorder:"border",holeBorder:[[]]}].concat(n));return o.custom.options={points:[[0,0],[1,0]],width:this.defaultLineWidth,color:this.defaultColor,close:!1,widthIs:"mid",cornerStyle:"auto",cornerSize:.01,cornerSides:10,cornersOnly:!1,cornerLength:.1,minAutoCornerAngle:Math.PI/7,dash:[],linePrimitives:!1,lineNum:1,drawBorder:"line",holeBorder:[[]],drawBorderBuffer:0},o.custom.updatePoints=function(e){var n=(a=Ks(t.getPolylineTris(ct({},o.custom.options,e)),5))[0],i=a[1],r=a[2],a=(e=a[3],a[4]);o.custom.options=n,o.custom.updateGeneric(ct({},n,{points:i,drawBorder:r,drawBorderBuffer:e,drawType:a}))},o.custom.updatePoints(r),o}},{key:"getPolygonBorder",value:function(t){var e=t;Gs(e,["offset"]),null!=e.angleToDraw&&(e.sidesToDraw=Math.floor(e.angleToDraw/(2*Math.PI/e.sides))),null==e.sidesToDraw&&(e.sidesToDraw=e.sides),e.sidesToDraw>e.sides&&(e.sidesToDraw=e.sides);var n,i,r=pn(e),o=0;return null!=e.line?(e.line=ct({},{width:this.defaultLineWidth,widthIs:"mid"},e.line),"inside"===e.line.widthIs&&1===e.direction?e.line.widthIs="positive":"inside"===e.line.widthIs&&-1===e.direction&&(e.line.widthIs="negative"),"outside"===e.line.widthIs&&1===e.direction?e.line.widthIs="negative":"outside"===e.line.widthIs&&-1===e.direction&&(e.line.widthIs="positive"),i=(n=e.line).width,t=n.widthIs,1===(n=e.direction)&&("negative"===t||"outside"===t)||-1===n&&("positive"===t||"inside"===t)?o=i:"mid"===t&&(o=i/2),0<o&&(i=(e.sides-2)*Math.PI/e.sides,o/=Math.sin(i/2)),e.sidesToDraw===e.sides?e.line.close=!0:e.line.close=!1):e.sidesToDraw!==e.sides&&null==e.line&&r.push(e.offset),[e,r,0===o?[r]:[pn(ct({},e,{radius:e.radius+o}))],"triangles"]}},{key:"genericBase",value:function(t,e,n){var i=this,r=this.generic({transform:new Ee(t).standard(),border:"draw",touchBorder:"border",holeBorder:[[]]},n);return r.custom.options=e,r.custom.getFill=function(){return[]},r.custom.close=!0,r.custom.skipConcave=!0,r.custom.bufferOffset="negative",r.custom.getLine=function(t){return r.custom.close||null!=t.drawBorder||(t.drawBorder="line"),i.getPolylineTris(t)},r.custom.getBorder=function(){return[]},r.custom.updatePoints=function(t){var e,n,i,o=ct({},r.custom.options,t),a=Ks(r.custom.getBorder(o),2);t=a[0],o=a[1],null==t.line?(e=(i=Ks(r.custom.getFill(o,t),2))[0],n=i[1],r.custom.options=t,r.custom.updateGeneric(ct({},t,{points:e,drawBorder:o,drawBorderBuffer:qs([o],t.drawBorderBuffer,r.custom.skipConcave,r.custom.bufferOffset),drawType:n}))):(null==t.line.widthIs&&(t.line.widthIs="mid"),r.custom.close&&(t.line.close=!0),a="negative","positive"===r.custom.bufferOffset&&t.line.close&&(a=t.line.drawBorder="positive"),e=(i=Ks(r.custom.getLine(ct({},t.line,{points:o})),5))[0],n=i[1],o=i[2],i=i[4],r.custom.options=t,r.custom.options.line=e,"positive"===r.custom.bufferOffset&&o.reverse(),a=qs(o,t.drawBorderBuffer,r.custom.skipConcave,a),r.custom.updateGeneric(ct({},t,{points:n,drawBorder:o,drawBorderBuffer:a,drawType:i})))},r}},{key:"polygon",value:function(){for(var t=this,e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=this.genericBase("polygon",{radius:1,sides:4,direction:1,rotation:0,offset:new pe(0,0)},ct.apply(void 0,[{}].concat(n)));return r.custom.getBorder=function(e){var n=t.getPolygonBorder(e);return e.sidesToDraw!==e.sides?r.custom.close=!1:r.custom.close=!0,r.custom.skipConcave=!1,-1===e.direction?r.custom.bufferOffset="positive":r.custom.bufferOffset="negative",n},r.custom.getFill=function(t,e){return[mn(e.offset,t,e.sides,e.sidesToDraw),"triangles"]},r.drawingObject.getPointCountForAngle=function(t){var e=r.custom.options;return t=Math.floor(d(t,8)/d(2*Math.PI,8)*e.sides),null==e.line?3*t:e.line&&e.line.linePrimitives?t*e.line.lineNum*2:6*t},r.custom.updatePoints(ct.apply(void 0,[{}].concat(n))),r}},{key:"star",value:function(){for(var t=this,e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=this.genericBase("star",{radius:1,sides:5,direction:1,rotation:0,offset:new pe(0,0)},ct.apply(void 0,[{}].concat(n)));return r.custom.getBorder=function(e){return null==e.innerRadius&&(e.innerRadius=e.radius/3),e.rotation+=Math.PI/2,e.sidesToDraw=e.sides,(e=t.getPolygonBorder(e))[0].rotation-=Math.PI/2,e},r.custom.getFill=function(t,e){return[mn(e.offset,t,e.sides,e.sidesToDraw),"triangles"]},r.custom.updatePoints(ct.apply(void 0,[{}].concat(n))),r}},{key:"rectangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.genericBase("rectangle",{width:this.defaultLength,height:this.defaultLength/2,xAlign:"center",yAlign:"middle",corner:{radius:0,sides:1},offset:[0,0]},ct.apply(void 0,[{}].concat(e)));return i.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),null!=t.offset&&(t.offset=ue(t.offset)),[t,(e=t.width,n=t.height,i=t.xAlign,r=t.yAlign,a=o=0,"center"===i?o=-e/2:"right"===i?o=-e:"number"==typeof i&&(o=-e*i),"middle"===r?a=-n/2:"top"===r?a=-n:"number"==typeof r&&(a=-n*r),r=(i=t.corner).radius,function(t,e,n,i,r,o,a){var s=6<arguments.length&&void 0!==a?a:new pe(0,0);if(i<1e-9)return[new pe(r+s.x,o+s.y),new pe(r+t+s.x,o+s.y),new pe(r+t+s.x,o+e+s.y),new pe(r+s.x,o+e+s.y)];var l=[],u=Math.PI/2/n,c=Math.min(t/2,e/2,i);return[[r+c,o+c,Math.PI],[r-c+t,o+c,Math.PI/2*3],[r-c+t,o-c+e,0],[r+c,o-c+e,Math.PI/2]].forEach((function(t){for(var e,i=(t=function(t){if(Array.isArray(t))return t}(e=t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,i,r=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(r.push(n.value),3!==r.length);o=!0);}catch(t){a=!0,i=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw i}}return r}}(e)||function(t){if(t){if("string"==typeof t)return Ls(t,3);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ls(t,3):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],r=t[1],o=t[2],a=0;a<n+1;a+=1)l.push(new pe(i+c*Math.cos(a*u+o),r+c*Math.sin(a*u+o)).add(s))})),l}(e,n,i.sides,r,o,a,t.offset))];var e,n,i,r,o,a},i.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"triangles"]},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"ellipse",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.genericBase("ellipse",{width:this.defaultLength,height:this.defaultLength/2,xAlign:"center",yAlign:"middle",sides:20},ct.apply(void 0,[{}].concat(e)));return i.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),[t,(e=t.width,n=t.height,o=r=0,"left"===(i=t.xAlign)?r=e/2:"right"===i?r=-e/2:"number"==typeof i&&(r=e/2-e*i),"bottom"===(i=t.yAlign)?o=n/2:"top"===i?o=-n/2:"number"==typeof i&&(o=n/2-n*i),function(t,e,n,i,r){for(var o=[],a=2*Math.PI/n,s=0;s<n;s+=1)o.push(new pe(t/2*Math.cos(a*s)+i,e/2*Math.sin(a*s)+r));return o}(e,n,t.sides,r,o))];var e,n,i,r,o},i.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"triangles"]},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"arc",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.genericBase("arc",{radius:this.defaultLength/2,sides:20,startAngle:0,angle:1,offset:[0,0],fillCenter:!1},ct.apply(void 0,[{}].concat(e)));return i.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),null!=t.offset&&(t.offset=ue(t.offset)),i.custom.close=!1,[t,function(t){var e=[],n=t.radius,i=t.startAngle,r=t.angle,o=t.offset,a=t.sides,s=a/r*Math.PI*2,l=n*Math.cos(Math.PI/s),u=(s=r/a,0<=r?i:i+r),c=0<=r?s:-s;null==t.line&&t.fillCenter&&e.push(o._dup()),e.push(new pe(l*Math.cos(u),l*Math.sin(u)).add(o));for(var h=0;h<a;h+=1)e.push(new pe(n*Math.cos(u+c/2+c*h)+o.x,n*Math.sin(u+c/2+c*h)+o.y));return e.push(new pe(l*Math.cos(u+c*a),l*Math.sin(u+c*a)).add(o)),e}(t)]},i.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"triangles"]},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"triangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.genericBase("triangle",{width:this.defaultLength,height:this.defaultLength,top:"center",direction:1,rotation:0},ct.apply(void 0,[{}].concat(e)));return i.custom.getBorder=function(t){null==t.xAlign&&(null!=t.points?t.xAlign="points":t.xAlign="centroid"),null==t.yAlign&&(null!=t.points?t.yAlign="points":t.yAlign="centroid");var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x,S,T,A,k,O,_=(O=(e=t).direction,null!=e.points?b=ce(e.points):null!=e.ASA?(l=O,u=(f=Ws(s=e.ASA,3))[0],c=f[1],h=f[2],s=[new pe(0,0),new pe(c,0)],f=Math.PI-u-h,u=c/Math.sin(f)*Math.sin(u),s.push(new pe(c+u*Math.cos((Math.PI-h)*l),0+u*Math.sin((Math.PI-h)*l))),b=s):null!=e.SAS?(r=O,s=(o=Ws(l=e.SAS,3))[0],a=o[1],l=o[2],(o=[new pe(0,0),new pe(s,0)]).push(new pe(s+l*Math.cos((Math.PI-a)*r),0+l*Math.sin((Math.PI-a)*r))),b=o):null!=e.AAS?(n=O,r=(i=Ws(a=e.AAS,3))[0],o=i[1],a=i[2],i=Math.PI-r-o,r=a/Math.sin(r)*Math.sin(i),(i=[new pe(0,0),new pe(r,0)]).push(new pe(r+a*Math.cos((Math.PI-o)*n),0+a*Math.sin((Math.PI-o)*n))),b=i):null!=e.SSS?(p=O,n=(d=Ws(_=e.SSS,3))[0],i=d[1],_=d[2],d=Math.acos((n*n+i*i-_*_)/(2*n*i)),(_=[new pe(0,0),new pe(n,0)]).push(new pe(n+i*Math.cos((Math.PI-d)*p),0+i*Math.sin((Math.PI-d)*p))),b=_):(v=e.width,g=e.height,m=e.top,b=[new pe(0,0),new pe(v,0)],"left"===m?b.push(new pe(0,g*O)):"center"===m?b.push(new pe(v/2,g*O)):"right"===m&&b.push(new pe(v,g*O))),d=b,p=e.xAlign,_=e.yAlign,m=e.rotation,y="number"==typeof m?(new Ee).rotate(m).matrix():(x="s1",S=0,"string"==typeof m?x=m:(x=(w=ct({},{side:"s1",angle:0},m)).side,S=w.angle),T=0,"s1"===x?T=be(S,new Se(d[0],d[1]).angle()):"s2"===x?T=be(S,new Se(d[1],d[2]).angle()):"s3"===x&&(T=be(S,new Se(d[2],d[0]).angle())),(new Ee).rotate(T).matrix()),v=d.map((function(t){return t.transformBy(y)})),g=Math.min(v[0].x,v[1].x,v[2].x),O=Math.min(v[0].y,v[1].y,v[2].y),m=(b=Math.max(v[0].x,v[1].x,v[2].x))-g,w=(e=Math.max(v[0].y,v[1].y,v[2].y))-O,x=tn(v[0],v[1],v[2]),S=new Se(v[0],v[1]).midPoint(),T=new Se(v[1],v[2]).midPoint(),d=new Se(v[2],v[0]).midPoint(),k=A=0,"left"===p?A=-g:"center"===p?A=m/2-b:"right"===p?A=-b:"centroid"===p?A=-x.x:"a2"===p?A=-v[1].x:"a3"===p?A=-v[2].x:"s1"===p?A=-S.x:"s2"===p?A=-T.x:"s3"===p?A=-d.x:"number"==typeof p&&(A=-g-m*p),"bottom"===_?k=-O:"middle"===_?k=w/2-e:"top"===_?k=-e:"centroid"===_?k=-x.y:"a2"===_?k=-v[1].y:"a3"===_?k=-v[2].y:"s1"===_?k=-S.y:"s2"===_?k=-T.y:"s3"===_?k=-d.y:"number"==typeof _&&(k=-O-w*_),v.map((function(t){return new pe(t.x+A,t.y+k)})));return-1!==t.direction&&-1!=(We((v=Ws(v=_,3))[0],v[1],v[2])>Math.PI?1:-1)||_.reverse(),[t,_]},i.custom.getFill=function(t){return[t,"triangles"]},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"arrow",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.genericBase("arrow",{length:this.defaultLength/2,width:this.defaultLength/2,head:"triangle",sides:20,radius:this.defaultLength/4,rotation:0,angle:0,tail:!1,drawPosition:new pe(0,0)},ct.apply(void 0,[{}].concat(e)));return i.custom.getBorder=function(t){null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative");var e=Pn(t);return[e,(t=Ks(On(e),2))[0],t[1]]},i.custom.getFill=function(t,e){return[_n(t,e),"triangles"]},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"grid",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.generic.apply(this,[{transform:new Ee("grid").standard(),border:"draw",touchBorder:"border",holeBorder:[[]]}].concat(e));function r(t){return Nn(t,i.custom.options.line.width,!1,"mid","auto",.1,1,Math.PI/7,i.custom.options.line.dash,i.custom.options.line.linePrimitives,i.custom.options.line.lineNum,[[]],0)}return i.custom.options={bounds:new fe(this.limits.left+this.limits.width/4,this.limits.bottom+this.limits.height/4,this.limits.width/2,this.limits.height/2),line:{linePrimitives:!1,width:this.defaultLineWidth,lineNum:2,dash:[]}},i.custom.updatePoints=function(t){var e=ct({},i.custom.options,t),n=de((i.custom.options=e).bounds),o=e.xStep,a=e.xNum,s=e.yStep,l=e.yNum,u=e.line.width;e.line.linePrimitives&&1===e.line.lineNum&&(u=0);var c=n.width,h=n.height,f=(o=(a=null==(a=null!=o&&null==a?0===o?1:1+Math.floor((c+.1*o)/o):a)?2:a)<2?0:c/(a-1),s=(l=null==(l=null!=s&&null==l?0===s?1:1+Math.floor((h+.1*s)/s):l)?2:l)<2?0:h/(l-1),new pe(n.left,n.bottom)),d=f.add(-u/2,0),p=f.add(c+u/2,0),m=f.add(0,-u/2),y=f.add(0,h+u/2);t=[],n=[],0<a&&(n=ca(Ks(r([m,y]),1)[0],[{along:"x",num:a-1,step:o}])),0<l&&(t=ca(Ks(r([d,p]),1)[0],[{along:"y",num:l-1,step:s}])),c=[f.add(-u/2,-u/2),f.add(c+u/2,-u/2),f.add(c+u/2,h+u/2),f.add(-u/2,h+u/2)],f=null!=e.drawBorder?nn(e.drawBorder):[c],h=e.drawBorderBuffer,"number"==typeof e.drawBorderBuffer&&(h=f,0!==e.drawBorderBuffer&&(u=e.drawBorderBuffer,h=[[c[0].add(-u,-u),c[1].add(u,-u),c[2].add(u,u),c[3].add(-u,u)]])),i.custom.updateGeneric(ct({},e,{points:[].concat(Hs(t),Hs(n)),drawBorder:f,drawBorderBuffer:h,drawType:e.line.linePrimitives?"lines":"triangles"}))},i.custom.updatePoints(ct.apply(void 0,[{}].concat(e))),i}},{key:"line",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=this.polyline(ct.apply(void 0,[{},{transform:new Ee("line").standard()}].concat(e,[{points:[[0,0],[0,1]],dash:[],arrow:null}]))),r=ct.apply(void 0,[{}].concat(e));return i.custom.options=ct({},i.custom.options,{p1:[0,0],angle:0,length:this.defaultLength,width:this.defaultLineWidth}),i.custom.updatePolyline=i.custom.updatePoints,i.custom.updatePoints=function(t){var e=ct({},i.custom.options,t),n=(r=Ks(function(t){var n,i=e.p1,r=e.p2,o=e.length,a=e.width,s=e.angle,l=e.border,u=e.touchBorder;return t=e.widthIs,i=[ue(i)],null==r?i.push(new pe(i[0].x+o*Math.cos(s),i[0].y+o*Math.sin(s))):i.push(ue(r)),r="outline"===l?"line":l,"number"==typeof u&&(l=new Se(i[0],i[1]),l=new Se(l.pointAtLength(-u),l.pointAtLength(l.length()+u)),a="positive"===t?(n=l.offset("negative",u),l.offset("positive",a+u)):"negative"===t?(n=l.offset("negative",a+u),l.offset("positive",u)):(n=l.offset("negative",a/2+u),l.offset("positive",a/2+u)),u=[[n.p1,n.p2,a.p2,a.p1]]),[i,r,u]}(),3))[0],r=(t=r[1],r[2]);i.custom.updatePolyline(ct({},e,{points:n,border:t,touchBorder:r,holeBorder:e.holeBorder}))},i.custom.updatePoints(r),i}},{key:"textGL",value:function(t){return e=this.webgl[0],n=this.limits,null==(t=ct({},{position:new pe(0,0),color:[1,0,0,1]},t)).transform&&(t.transform=new Ee("Text").translate(0,0)),null!=t.position&&t.transform.updateTranslation(t.position),e=new Is(e,t),new is(e,t.transform,t.color,n);var e,n}},{key:"parseTextOptions",value:function(){for(var t={text:"",font:{family:this.defaultFont.family,style:this.defaultFont.style,size:this.defaultFont.size,weight:this.defaultFont.weight},xAlign:"left",yAlign:"baseline",border:"draw",touchBorder:"buffer",defaultTextTouchBorder:0},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return null==(t=ct.apply(void 0,[{},t].concat(n))).color&&null!=t.font.color&&(t.color=t.font.color),null==t.font.color&&null!=t.color&&(t.font.color=t.color),null==t.color&&(t.color=this.defaultFont.color),null==t.text||Array.isArray(t.text)||(t.text=[t.text]),null==t.line||Array.isArray(t.line)||(t.line=[t.line]),null==t.lines||Array.isArray(t.lines)||(t.lines=[t.lines]),null!=t.touchBorder&&Array.isArray(t.touchBorder)&&(t.touchBorder=nn(t.touchBorder)),null!=t.border&&Array.isArray(t.border)&&(t.border=nn(t.border)),t}},{key:"genericTextPrimitive",value:function(t,e){var n=e;null==n.transform?n.transform=new Ee("text").standard():n.transform=Be(n.transform),null!=n.position&&(e=ue(n.position),n.transform.updateTranslation(e));var i=new is(t,n.transform,n.color,this.limits);return i.timeKeeper=this.timeKeeper,i.recorder=this.recorder,Ys(i,n),null!=n.mods&&n.mods!=={}&&i.setProperties(n.mods),i.custom.updateBorders=function(t){i.drawBorder=i.drawingObject.textBorder,null!=t.drawBorder&&(i.drawBorder=t.drawBorder),i.drawBorderBuffer=i.drawingObject.textBorderBuffer,null!=t.drawBorderBuffer&&(i.drawBorderBuffer=t.drawBorderBuffer),null!=t.border&&(i.border=t.border),null!=t.touchBorder&&(i.touchBorder=t.touchBorder)},i.getBorderPointsSuper=i.getBorderPoints,i.getBorderPoints=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border";return"border"===t?i.getBorderPointsSuper(t):"touchBorder"===t?"draw"===i.touchBorder?i.drawBorder:"buffer"===i.touchBorder?i.drawBorderBuffer:"border"===i.touchBorder?i.getBorderPoints("border"):"rect"===i.touchBorder?[Le(i.drawBorderBuffer)]:De(i.touchBorder)?[Le(i.drawBorderBuffer,i.touchBorder)]:i.touchBorder:i.holeBorder},i.custom.setText=function(t){i.drawingObject.setText(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),i.custom.updateBorders({})},i}},{key:"textLine",value:function(){for(var t=this,e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=this.parseTextOptions.apply(this,[{border:"rect",touchBorder:"rect"}].concat(n)),o=new La(this.draw2D);o.loadText(r);var a=this.genericTextPrimitive(o,r);return a.custom.options=o,a.custom.updateText=function(e){a.drawingObject.clear(),e=t.parseTextOptions({border:"rect",touchBorder:"rect"},a.custom.options,e),a.drawingObject.loadText(e),a.custom.options=e,a.custom.updateBorders({})},a.custom.updateBorders(r),a}},{key:"textLines",value:function(){for(var t=this,e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},{color:this.defaultColor}].concat(n)),o=new Wa(this.draw2D),a=this.genericTextPrimitive(o,r);return a.custom.options=r,a.custom.updateText=function(e){a.drawingObject.clear();var i=e;1===e.length&&"string"==typeof e[0]&&(i=[{text:[n[0]]}]),null==(i=t.parseTextOptions({border:"rect",touchBorder:"rect"},a.custom.options,i)).justify&&(i.justify="left"),null==i.lineSpace&&(i.lineSpace=1.2*i.font.size),a.custom.options=i,a.drawingObject.loadText(i),a.custom.updateBorders(i)},a.custom.updateText(r),a}},{key:"text",value:function(){var t=this,e=this.parseTextOptions.apply(this,arguments),n=new Fa(this.draw2D);n.loadText(e);var i=this.genericTextPrimitive(n,e);return i.custom.options=e,i.custom.updateText=function(e){i.drawingObject.clear(),i.drawingObject.loadText(t.parseTextOptions(i.custom.options,e)),i.custom.updateBorders({}),i.animateNextFrame()},i.custom.updateBorders(e),i}},{key:"html",value:function(t){var e;(i=ct({},{classes:"",position:[0,0],xAlign:"center",yAlign:"middle",wrap:!0,id:"id__temp_".concat(Math.round(1e4*Math.random()))},t)).element=t.element,null==(n=i.wrap||Array.isArray(i.element)?((e=document.createElement("div")).setAttribute("id",i.id),Array.isArray(i.element)?i.element.forEach((function(t){return e.appendChild(t)})):e.appendChild(i.element),this.htmlCanvas.appendChild(e),this.htmlCanvas):(""===(n=(e=i.element).getAttribute("id"))?e.setAttribute("id",i.id):i.id=n,e.parentElement))&&(n=this.htmlCanvas);var n=new ta(n,i.id,new pe(0,0),i.yAlign,i.xAlign),i=ue(i.position);return(i=new is(n,(new Ee).scale(1,1).translate(i.x,i.y),[1,1,1,1],this.limits)).timeKeeper=this.timeKeeper,i.recorder=this.recorder,i}},{key:"htmlElement",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"id__temp_".concat(Math.round(1e4*Math.random())),n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new pe(0,0),r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"middle",o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"left",a=document.createElement("div");return n&&a&&n.split(" ").forEach((function(t){return a.classList.add(t.trim())})),Array.isArray(t)?t.forEach((function(t){return a.appendChild(t)})):a.appendChild(t),a.style.position="absolute",a.setAttribute("id",e),this.htmlCanvas.appendChild(a),o=new ta(this.htmlCanvas,e,new pe(0,0),r,o),(i=new is(o,(new Ee).scale(1,1).translate(i.x,i.y),[1,1,1,1],this.limits)).timeKeeper=this.timeKeeper,i.recorder=this.recorder,i}},{key:"htmlImage",value:function(){for(var t={id:dt("id__html_image_"),classes:"",position:new pe(0,0),yAlign:"middle",xAlign:"left",src:""},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},t].concat(n)),o=document.createElement("img");o.src=r.src;var a=r.id,s=r.classes,l=r.position,u=r.yAlign;return t=r.xAlign,t=this.htmlElement(o,a,s,ue(l),u,t),null!=r.color&&t.setColor(r.color),Ys(t,r),t}},{key:"htmlText",value:function(){for(var t={text:"",id:dt("id__html_text_"),classes:"",position:new pe(0,0),yAlign:"middle",xAlign:"left"},e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},t].concat(n)),o=document.createElement("div");Ps(o,r.text,r.modifiers);var a=r.id,s=r.classes,l=r.position,u=r.yAlign;return t=r.xAlign,t=this.htmlElement(o,a,s,ue(l),u,t),null!=r.color&&t.setColor(r.color),Ys(t,r),t}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}(),$s=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e=ct({width:0,height:0,ascent:0,descent:0,left:0,right:0,top:0,bottom:0},e),this.copyFrom(e)}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,[{key:"toRect",value:function(){return new fe(this.left,this.bottom,this.width,this.height)}},{key:"copyFrom",value:function(t){null!=t.width&&(this.width=t.width),null!=t.height&&(this.height=t.height),null!=t.ascent&&(this.ascent=t.ascent),null!=t.descent&&(this.descent=t.descent),null!=t.left&&(this.left=t.left),null!=t.right&&(this.right=t.right),null!=t.top&&(this.top=t.top),null!=t.bottom&&(this.bottom=t.bottom)}},{key:"leftOffset",value:function(t){this.left+=t,this.width=this.right-this.left}},{key:"rightOffset",value:function(t){this.right+=t,this.width=this.right-this.left}},{key:"topOffset",value:function(t){this.top+=t,this.ascent+=t,this.height=this.ascent+this.descent}},{key:"bottomOffset",value:function(t){this.bottom+=t,this.descent-=t,this.height=this.ascent+this.descent}},{key:"offset",value:function(t,e,n,i){this.left+=i,this.right+=e,this.top+=t,this.ascent+=t,this.descent-=n,this.bottom+=n,this.width=this.right-this.left,this.height=this.ascent+this.descent}},{key:"growWithSameBaseline",value:function(t){var e=this.bottom+this.descent;t.left<this.left&&(this.left=t.left),t.right>this.right&&(this.right=t.right),t.top>this.top&&(this.top=t.top),t.bottom<this.bottom&&(this.bottom=t.bottom),this.width=this.right-this.left,this.height=this.top-this.bottom,this.ascent=this.top-e,this.descent=e-this.bottom}}]),t}();function Qs(t){return function(t){if(Array.isArray(t))return Js(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Js(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Js(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Js(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Zs(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tl(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function el(t,e,n){return e&&tl(t.prototype,e),n&&tl(t,n),t}var nl=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.03,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;Zs(this,t),this.width=e,this.ascent=n,this.descent=i,this.height=this.ascent+this.descent}return el(t,[{key:"_dup",value:function(){return new t(this.width,this.ascent,this.descent)}}]),t}(),il=function(){function t(e){Zs(this,t),this.content=e,this.ascent=0,this.descent=0,this.width=0,this.location=new pe(0,0),this.scale=1,this.height=0,this.fullSize={leftOffset:0,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent},this.fnMap=new G,this.showContent=!0}return el(t,[{key:"calcSize",value:function(t,e){var n=this.content;n instanceof nl&&(this.width=n.width*e,this.height=n.height*e,this.ascent=n.ascent*e,this.descent=n.descent*e,this.location=t._dup(),this.scale=e),(n instanceof rs||n instanceof is)&&(null!=n.drawingObject&&null!=n.drawingObject.text&&(n.drawingObject.text[0].measureAndAlignText(),n.drawingObject.text[0].calcBorderAndBounds(),n.drawingObject.setBorder(),n.drawingObject.setTouchBorder(),n.custom.updateBorders({})),n.transform.updateTranslation(t.x,t.y),n.transform.updateScale(e,e),n.updateLastDrawTransform(),null!=n.internalSetTransformCallback&&this.fnMap.exec(n.internalSetTransformCallback,n.transform),n=n.getRelativeBoundingRect("draw"),this.location=t._dup(),this.scale=e,this.ascent=n.top*e,this.descent=-n.bottom*e,this.height=n.height*e,this.width=n.width*e),this.fullSize={leftOffset:0,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent}}},{key:"_dup",value:function(e){return(e=this.content instanceof nl?new t(this.content):new t(e?e[this.content.name]:this.content)).ascent=this.ascent,e.descent=this.descent,e.width=this.width,e.location=this.location._dup(),e.height=this.height,e.scale=this.scale,e}},{key:"getAllElements",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&!arguments[0]&&!this.showContent||this.content instanceof nl?[]:[this.content]}},{key:"setPositions",value:function(){var t=this.content;(t instanceof rs||t instanceof is)&&(t.transform.updateTranslation(this.location.x,this.location.y),t.transform.updateScale(this.scale,this.scale),t.updateLastDrawTransform())}},{key:"offsetLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0);this.location=this.location.add(t)}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new $s({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new $s({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}]),t}(),rl=function(){function t(e){Zs(this,t);var n=[];e.forEach((function(t){null!==t&&n.push(t)})),this.content=n,this.ascent=0,this.descent=0,this.width=0,this.location=new pe(0,0),this.height=0,this.fnMap=new G,this.showContent=!0}return el(t,[{key:"_dup",value:function(e){var n=[];this.content.forEach((function(t){return n.push(t._dup(e))}));var i=new t(n);return ht(this,i,["content"]),i}},{key:"calcSize",value:function(t,e){var n=0,i=0,r=t._dup(),o=null;this.content.forEach((function(t){t.calcSize(r,e),r.x+=t.width,t.descent>n&&(n=t.descent),t.ascent>i&&(i=t.ascent),t=t.getBounds(!0),null==o&&(o=new $s).copyFrom(t)})),null===o&&((o=new $s).left=t.x,o.top=t.y,o.bottom=t.y),this.width=r.x-t.x,this.ascent=i,this.descent=n,this.location=t._dup(),this.height=this.descent+this.ascent,this.fullSize={leftOffset:this.location.x-o.left,width:o.width,ascent:o.ascent,descent:o.descent,height:o.height}}},{key:"getAllElements",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=[];return t||this.showContent?(this.content.forEach((function(n){e=[].concat(Qs(e),Qs(n.getAllElements(t)))})),e):[]}},{key:"setPositions",value:function(){this.content.forEach((function(t){t.setPositions()}))}},{key:"offsetLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0);this.location=this.location.add(t),this.content.forEach((function(e){e.offsetLocation(t)}))}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new $s({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new $s({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}]),t}();function ol(t){return(ol="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function al(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return sl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sl(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ll(t,e){return(ll=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ul(t){return(ul=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var cl=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ll(t,e)}(r,is);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=ul(e);return function(t,e){if(e&&("object"===ol(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ul(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e,n,o,a){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),t=new ma(t),n=n instanceof Ee?n:new Ee("Symbol").scale(1,1).translate(0,0);var s=i.call(this,t,n,e,o);return null!=a.touchBorder&&(s.touchBorder=a.touchBorder),null!=a.border&&(s.border=a.border),null!=a.onClick&&(s.onClick=a.onClick),null!=a.isTouchable&&(s.isTouchable=a.isTouchable),s._custom.options=a,"dynamic"===s._custom.options.draw&&(s._custom.scale=new pe(1,1),s.internalSetTransformCallback=function(){var t,e,n,i,r=s.getScale();s._custom.scale.isNotEqualTo(r,8)&&(t=(i=al(s.getPoints(s._custom.options,r.x,r.y),4))[0],e=i[1],n=i[2],i=i[3],s.pointsDefinition={points:st(t),width:e,height:n,drawType:i},s.updateSymbol(t,e,n,i),s._custom.scale=r)}),s._custom.setSize=function(t,e,n){var i,r,o,l,u,c=s.transform._dup();"static"===s._custom.options.draw?(u=[],l=o=0,r="strip","first"===s._custom.options.staticHeight||"first"===s._custom.options.staticWidth?(u=(i=al(s.getPoints(a,e,n),4))[0],o=i[1],l=i[2],r=i[3]):null==s._custom.options.staticHeight&&null==s._custom.options.staticWidth||(u=(i=al(s.getPoints(a,s._custom.options.staticWidth,s._custom.options.staticHeight),4))[0],o=i[1],l=i[2],r=i[3]),s.pointsDefinition={points:st(u),width:o,height:l,drawType:r},s.updateSymbol(u,o,l,r),s._custom.options.staticHeight=l,s._custom.options.staticWidth=o,c.updateScale(o,l)):(r=(u=al(s.getPoints(s._custom.options,e,n),4))[0],o=u[1],l=u[2],u=u[3],s.pointsDefinition={points:st(r),width:o,height:l,drawType:u},s.updateSymbol(r,o,l,u),s._custom.scale=new pe(e,n),c.updateScale(e,n)),c.updateTranslation(t.x,t.y),s.setTransform(c)},s.setPointsFromDefinition=function(){var t,e,n,i;0!==Object.keys(s.pointsDefinition).length&&(t=(i=s.pointsDefinition).points,e=i.width,n=i.height,i=i.drawType,s.updateSymbol(t,e,n,i))},s}return t=[{key:"updateSymbol",value:function(t,e,n,i){this.drawingObject.change({points:t,drawType:i}),this.drawBorder=[[new pe(0,0),new pe(e,0),new pe(e,n),new pe(0,n)]],"number"==typeof this._custom.options.drawBorderBuffer||Array.isArray(this._custom.options.drawBorderBuffer)&&"number"==typeof this._custom.options.drawBorderBuffer[0]?this.drawBorderBuffer=[Le(this.drawBorder,this._custom.options.drawBorderBuffer)]:Array.isArray(this._custom.options.drawBorderBuffer)?this.drawBorderBuffer=nn(this._custom.options.drawBorderBuffer):this.drawBorderBuffer=this.drawBorder}},{key:"getTransform",value:function(){if("static"!==this._custom.options.draw)return(t=this.transform._dup()).updateScale(1,1),t;var t=this.transform._dup(),e=t.s();return null!=e&&t.updateScale(e.x/this._custom.options.staticWidth,e.y/this._custom.options.staticHeight),t}},{key:"getWidth",value:function(t,e){if("static"!==t.draw)return n=t.width,this.getDefaultValues(e,n,t).width;var n,i=t.staticHeight,r=t.staticWidth;return(n=null==(n=this.getDefaultValues(i="first"===i?e:i,r,t).width)?e:n)/i*e}},{key:"getHeight",value:function(t,e){if("static"!==t.draw)return n=t.height,this.getDefaultValues(n,e,t).height;var n,i=t.staticWidth,r=t.staticHeight;return(n=null==(n=this.getDefaultValues(r,i="first"===i?e:i,t).height)?e:n)/i*e}},{key:"getBounds",value:function(t,e,n,i,r,o){r=(a=this.getDefaultValues(r,i,t)).width,t=a.height;var a=new $s;return"left"===o?(a.left=e-r,a.bottom=n,a.top=a.bottom+t):"right"===o?(a.left=e,a.bottom=n,a.top=a.bottom+t):("top"===o?(a.bottom=n,a.top=n+t):(a.top=n,a.bottom=n-t),a.left=e+i/2-r/2),a.right=a.left+r,a.width=r,a.height=t,a.ascent=t,a.descent=0,a}},{key:"getPoints",value:function(t,e,n){return[[new pe(0,0),new pe(e,0),new pe(e,n),new pe(0,n)],e,n,"strip"]}},{key:"getDefaultValues",value:function(t,e,n){return{}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function hl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||dl(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fl(t){return function(t){if(Array.isArray(t))return pl(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||dl(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dl(t,e){if(t){if("string"==typeof t)return pl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pl(t,e):void 0}}function pl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function ml(t,e){var n=[];return t.forEach((function(t){var i;n.push((i=e,{xPosition:t.xPosition,yPosition:t.yPosition,xAlign:t.xAlign,yAlign:t.yAlign,offset:t.offset._dup(),scale:t.scale,content:t.content._dup(i),inSize:t.inSize,fullContentBounds:t.fullContentBounds}))})),n}function yl(t){var e=[];return t.forEach((function(t){e=[].concat(fl(e),fl(t.content.getAllElements()))})),e}function vl(t){t.forEach((function(t){t.content.setPositions()}))}function gl(t,e){t.forEach((function(t){t.content.offsetLocation(e)}))}var bl=function(){function t(e,n,i,r){var o=!(4<arguments.length&&void 0!==arguments[4])||arguments[4];!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.glyphs=i,this.content=e,this.annotations=n,this.options=r,this.fnMap=new G,this.showContent=o,this.scale=1}var e=[{key:"_dup",value:function(t){var e,n,i=this.content._dup(t),r=(e=this.glyphs,n={},Object.keys(e).forEach((function(t){var i,r;null!=e[t]&&(ht(i=e[t],r={},["glyph","annotations"]),r.glyph=i.glyph,r.annotations=ml(i.annotations,void 0),n[t]=r)})),n);return t=ml(this.annotations),ht(this,r=new this.constructor(i,t,r,this.options),["content","glyphs","annotations"]),r}},{key:"getAllElements",value:function(){var t,e,n=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];return n||this.showContent?[].concat(fl(this.content.getAllElements(n)),fl(yl(this.annotations)),fl((t=this.glyphs,e=[],Object.keys(t).forEach((function(n){null!=(n=t[n])&&(e=[].concat(fl(e),[n.glyph],fl(yl(n.annotations))))})),e))):[]}},{key:"setPositions",value:function(){var t;this.content.setPositions(),vl(this.annotations),t=this.glyphs,Object.keys(t).forEach((function(e){var n;null!=t[e]&&((e=(n=t[e]).glyph.transform._dup()).updateScale(null==n.width?1:n.width,null==n.height?1:n.height),e.updateTranslation(null==n.location?0:n.location.x,null==n.location?0:n.location.y),n.glyph.setTransform(e),vl(n.annotations))}))}},{key:"offsetLocation",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0);this.location=this.location.add(n),this.content.offsetLocation(n),gl(this.annotations,n),t=this.glyphs,e=n,Object.keys(t).forEach((function(n){null!=t[n]&&((n=t[n]).location=n.location.add(e),gl(n.annotations,e))}))}},{key:"calcSize",value:function(t,e){var n=this;this.location=t._dup();var i,r=t._dup(),o=this.content,a=this.annotations,s=(p=this.options).inSize,l=p.space,u=p.topSpace,c=p.bottomSpace,h=p.leftSpace,f=p.rightSpace,d=p.contentScale,p=(t=p.useFullBounds,p.fullContentBounds),m=new $s,y=new $s,v=new $s;o.calcSize(r._dup(),e*d),v.copyFrom(o.getBounds(p)),m.copyFrom(v),y.copyFrom(v),a.forEach((function(t,i){t.content.calcSize(r,e*t.scale),n.setAnnotationPosition(v,t,e);var o=t.content.getBounds();m.growWithSameBaseline(o),t=t.content.getBounds(!0),y.growWithSameBaseline(t),null!=n.glyphs.line&&n.glyphs.line.annotationIndex===i&&n.setLineGlyph(o,v)})),p=(d=hl(this.setEncompassGlyph(e,v),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=(p=hl(this.setVerticalGlyph(e,v,"left"),2))[0],p=p[1],m.growWithSameBaseline(d),y.growWithSameBaseline(p),p=(d=hl(this.setVerticalGlyph(e,v,"right"),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=(p=hl(this.setHorizontalGlyph(e,v,"top"),2))[0],p=p[1],m.growWithSameBaseline(d),y.growWithSameBaseline(p),p=(d=hl(this.setHorizontalGlyph(e,v,"bottom"),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=0,m.offset((null!=u?u:l||0)*e,(null!=f?f:l||0)*e,-(null!=c?c:l||0)*e,-(null!=h?h:l||0)*e),y.growWithSameBaseline(m),t&&m.copyFrom(y),s?(this.width=m.width,this.ascent=m.ascent,this.descent=m.descent,this.height=m.height,d=r.x-m.left):(this.width=v.width,this.ascent=v.ascent,this.descent=v.descent,this.height=v.height),this.fullSize={leftOffset:this.location.x-y.left,width:y.width,ascent:y.ascent,descent:y.descent,height:y.height},0!==d&&null!=o&&(i=new pe(d,0),o.offsetLocation(i),a.forEach((function(t){t.content.offsetLocation(i)})),Object.keys(this.glyphs).forEach((function(t){null!=(t=n.glyphs[t])&&(t.location=t.location.add(i),t.glyph._custom.setSize(t.location,t.width,t.height),t.annotations.forEach((function(t){t.content.offsetLocation(i)})))})))}},{key:"setEncompassGlyph",value:function(t,e){var n=this;if(null==this.glyphs.encompass)return(a=new $s).copyFrom(e),[e,a];var i=(s=this.glyphs.encompass).leftSpace,r=s.rightSpace,o=s.bottomSpace,a=s.topSpace,s=s.space,l=this.glyphs.encompass;s=null!=s?s:0,i=null!=i?i:s,r=null!=r?r:s,a=null!=a?a:s,o=null!=o?o:s,(s=new $s).copyFrom(e),s.offset(a*t,r*t,-o*t,-i*t);var u=l.glyph.getBounds(l.glyph._custom.options,s.left,s.bottom,s.width,s.height),c=new $s,h=new $s;return c.copyFrom(s),c.growWithSameBaseline(u),h.copyFrom(c),l.width=u.width,l.height=u.height,l.location=new pe(u.left,u.bottom),l.glyph._custom.setSize(l.location,l.width,l.height),l.annotations.forEach((function(e){e.content.calcSize(l.location,t*e.scale),n.setAnnotationPosition(u,e,t);var i=e.content.getBounds();c.growWithSameBaseline(i),e=e.content.getBounds(!0),h.growWithSameBaseline(e)})),[c,h]}},{key:"setLineGlyph",value:function(t,e){var n,i,r;null!=this.glyphs.line&&(n=(i=this.glyphs.line).content,r=i.annotation,i=this.glyphs.line,e=rn(e.toRect(),n.xAlign,n.yAlign),t=rn(t.toRect(),r.xAlign,r.yAlign),t=new Se(e,t),r=new Se(t.pointAtLength(n.space),t.pointAtLength(t.length()-r.space)),i.width=r.angle(),i.height=r.length(),i.location=r.p1._dup(),i.glyph._custom.setSize(i.location,i.width,i.height))}},{key:"setVerticalGlyph",value:function(t,e,n){var i=this;if(null==this.glyphs[n])return(b=new $s).copyFrom(e),[e,b];var r=(w=this.glyphs[n]).space,o=w.overhang,a=w.topSpace,s=w.bottomSpace,l=w.minContentHeight,u=w.minContentDescent,c=w.minContentAscent,h=w.descent,f=w.height,d=w.yOffset,p=w.annotationsOverContent,m=this.glyphs[n],y=e.height,v=e.left,g=e.bottom,b=e.descent,w=e.ascent;null!=u&&(b=Math.max(u,b),y=e.ascent+b),null!=c&&(y=(w=Math.max(c,w))+b),null!=l&&(w=-b+Math.max(l,y)),b+=t*(null!=s?s:o),y=(b=null!=h?h:b)+(w+=t*(null!=a?a:o)),null!=f&&(w=(y=f)-b),g=e.bottom-(b-e.descent),"left"===n?v-=r*t:v=e.left+e.width+r*t,null==h&&null==s&&null!=f&&(g=e.bottom+e.height/2-f/2);var x=m.glyph.getBounds(m.glyph._custom.options,v,g+d,null,y,n),S=new $s,T=new $s;S.copyFrom(e),S.growWithSameBaseline(x),T.copyFrom(S);var A,k=new $s;return k.copyFrom(x),m.width=x.width,m.height=x.height,m.location=new pe(x.left,x.bottom),m.glyph._custom.setSize(m.location,m.width,m.height),m.annotations.forEach((function(e){e.content.calcSize(m.location,t*e.scale),i.setAnnotationPosition(x,e,t);var n=e.content.getBounds();S.growWithSameBaseline(n),k.growWithSameBaseline(n),e=e.content.getBounds(!0),T.growWithSameBaseline(e)})),y=0,"left"===n&&k.right>v&&!1===p&&(y=v-k.right),0!==(y="right"===n&&k.left<v&&!1===p?v-k.left:y)&&(A=new pe(y,0),m.location=m.location.add(A),m.glyph._custom.setSize(m.location,m.width,m.height),m.annotations.forEach((function(t){t.content.offsetLocation(A)})),S.left+=y,S.right=Math.max(S.right+y,e.right),T.left+=y,T.right=Math.max(S.right+y,e.right)),[S,T]}},{key:"setHorizontalGlyph",value:function(t,e,n){var i=this;if(null==this.glyphs[n])return(g=new $s).copyFrom(e),[e,g];var r=this.glyphs[n],o=r.space,a=r.overhang,s=r.width,l=r.leftSpace,u=r.rightSpace,c=r.xOffset,h=r.annotationsOverContent,f=this.glyphs[n];(g=new $s).copyFrom(e),r=g.width,e=g.left,null!=a&&(r+=2*a*t,e=g.left-a*t),null!=s&&(r=s),null==l&&null==u||(r=(l||0)*t+g.width+(u||0)*t,null!=l&&(e=g.left-l*t)),null==l&&null==u&&null!=s?e=g.left+(g.width-s)/2:null==l&&null!=u&&null!=s&&(e=g.right+u*t-s),o="top"===n?g.top+o*t:g.bottom-o*t;var d=f.glyph.getBounds(f.glyph._custom.options,e+c,o,r,null,n),p=new $s,m=new $s;p.copyFrom(g),p.growWithSameBaseline(d),m.copyFrom(p);var y=new $s;y.copyFrom(d),f.width=d.width,f.height=d.height,f.location=new pe(d.left,d.bottom),f.glyph._custom.setSize(f.location,f.width,f.height),f.annotations.forEach((function(e){e.content.calcSize(f.location,t*e.scale),i.setAnnotationPosition(d,e,t);var n=e.content.getBounds();p.growWithSameBaseline(n),y.growWithSameBaseline(n),e=e.content.getBounds(!0),m.growWithSameBaseline(e)}));var v,g=0;return"top"===n&&y.bottom<o&&!1===h&&(g=o-y.bottom),0!==(g="bottom"===n&&y.top>o&&!1===h?o-y.top:g)&&(v=new pe(0,g),f.location=f.location.add(v),f.glyph._custom.setSize(f.location,f.width,f.height),f.annotations.forEach((function(t){t.content.offsetLocation(v)})),p.top+=g,p.bottom+=g,m.top+=g,m.bottom+=g),[p,m]}},{key:"setAnnotationPosition",value:function(t,e,n){var i,r=e.xPosition,o=e.yPosition,a=e.xAlign,s=e.yAlign,l=ue(l=e.offset),u=e.content,c=e.fullContentBounds,h=new pe(t.left,t.bottom+t.descent);null!=t.annotations&&null!=e.reference&&(null!=(e=t.annotations[e.reference]).xPosition&&(r=e.xPosition),null!=e.yPosition&&(o=e.yPosition),null!=e.xAlign&&(a=e.xAlign),null!=e.yAlign&&(s=e.yAlign),null!=e.offset&&(l=l.add(ue(e.offset)))),r=(r="right"===r?1:"center"===r?.5:"number"==typeof r?r:0)*t.width+h.x,i=(i="bottom"===o?0:"middle"===o?.5:"top"===o?1:"number"==typeof o?o:"string"==typeof o&&"a"===o.slice(-1)[0]?(i=parseFloat(o),t.ascent/t.height*i+t.descent/t.height):t.descent/t.height)*t.height+h.y-t.descent,c=u.getBounds(c),"center"===a?r-=.5*c.width:"right"===a?r-=c.width:"number"==typeof a&&(r-=c.width*a),"bottom"===s?i+=c.descent:"middle"===s?i=i+c.descent-c.height/2:"top"===s?i-=c.ascent:"string"==typeof s&&"a"===s.slice(-1)[0]?(a=parseFloat(s),i-=c.ascent*a):"number"==typeof s&&(i+=c.descent-c.height*s),r+=(l=ue(l)).x*n,i+=l.y*n,c=new pe(r,i).sub(c.left,c.bottom+c.descent),u.offsetLocation(c)}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new $s({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new $s({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function wl(t){return(wl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function xl(t,e,n){return(xl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Tl(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Sl(t,e){return(Sl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Tl(t){return(Tl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Al=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Sl(t,e)}(r,rl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Tl(e);return function(t,e){if(e&&("object"===wl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Tl(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){var n;return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),(n=i.call(this,[])).elements=t,n.collectionMethods=e,n.description=null,n.modifiers={},n.elementMods={},n.onShow=null,n.onTransition=null,n.fromForm={},n.positionsSet=!1,n.layout="always",n}return t=[{key:"getNamedElements",value:function(){var t={};return this.collectionMethods.getAllElements().forEach((function(e){t[e.name]=e})),t}},{key:"setPositions",value:function(){0<arguments.length&&void 0!==arguments[0]&&arguments[0]||"always"!==this.layout&&!1!==this.positionsSet||this.arrange(this.arranged.scale,this.arranged.xAlign,this.arranged.yAlign,this.arranged.fixTo),xl(Tl(r.prototype),"setPositions",this).call(this)}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.elements,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.collectionMethods,n=(t=new r(t,e),{});e.getAllElements().forEach((function(t){n[t.name]=t}));var i=[];return this.content.forEach((function(t){i.push(t._dup(n))})),t.content=i,ht(this,t,["content","collectionMethods","form","elements"]),t}},{key:"arrange",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"left",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"baseline",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new pe(0,0);this.arranged={scale:t,xAlign:e,yAlign:n,fixTo:i};var o=this.collectionMethods.getAllElements().filter((function(t){return t.isShown}));this.collectionMethods.hideAll(),this.collectionMethods.show(),this.positionsSet=!0,xl(Tl(r.prototype),"calcSize",this).call(this,new pe(0,0),t),this.setPositions(!0);var a=new pe(0,0);i instanceof is||i instanceof rs?null!=(s=i.transform.t())&&(a=s._dup()):a=new pe(-i.x,-i.y);var s,l=this.width,u=this.height,c=this.ascent,h=this.descent,f=this.location._dup();(i instanceof is||i instanceof rs)&&(t=i.transform.t(),s=i.transform.s(),null!=t&&null!=s&&(l=(i=i.getBoundingRect("draw")).width*s.x,u=i.height*s.y,c=i.top*s.y-t.y,h=t.y-i.bottom*s.y,f=t._dup())),"right"===e?a.x+=l:"center"===e?a.x+=l/2:"number"==typeof e?a.x+=e*l:null!=e&&"o"===e.slice(-1)[0]&&(e=parseFloat(e),a.x+=e),"top"===n?a.y+=f.y+c:"bottom"===n?a.y+=f.y-h:"middle"===n?a.y+=f.y-h+u/2:"number"==typeof n?a.y+=f.y-h+n*u:null!=n&&"o"===n.slice(-1)[0]&&(n=parseFloat(n),a.y+=f.y+n),0===(a=new pe(0,0).sub(a)).x&&0===a.y||(this.offsetLocation(a),this.setPositions(!0)),this.collectionMethods.showOnly(o)}},{key:"lazyArrange",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"left",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"baseline",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new pe(0,0);this.arranged={scale:t,xAlign:e,yAlign:n,fixTo:i},this.positionsSet=!1}},{key:"dissolveElements",value:function(t){var e,n,i,r=this,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"in",a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.01,s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,l=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;0===t.length&&l?this.fnMap.exec(l,!1):(e=t.length,n=0,i=function(t){(n+=1)===e&&l&&r.fnMap.exec(l,t)},t.forEach((function(t){t.animations.addTo("_EquationColor").opacity({dissolve:o,onFinish:i,duration:s,delay:a,completeOnCancel:!0}).start()})))}},{key:"getElementsToShowAndHide",value:function(){var t=this.collectionMethods.getAllElements().filter((function(t){return t.isShown})),e=this.getAllElements(!1),n=t.filter((function(t){return-1===e.indexOf(t)}));return{show:e.filter((function(e){return-1===t.indexOf(e)})),hide:n}}},{key:"render",value:function(){this.hideShow(),this.setPositions()}},{key:"showHide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;3<arguments.length&&void 0!==arguments[3]&&!arguments[3]||this.collectionMethods.stop(),this.collectionMethods.show();var i=(r=this.getElementsToShowAndHide()).show,r=r.hide;0===t?i.forEach((function(t){t.showAll()})):this.dissolveElements(i,"in",.01,t,null),0===e?r.forEach((function(t){return t.hide()})):this.dissolveElements(r,"out",t,e,n)}},{key:"hideShow",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;3<arguments.length&&void 0!==arguments[3]&&!arguments[3]||this.collectionMethods.stop(),this.collectionMethods.show();var i=(r=this.getElementsToShowAndHide()).show,r=r.hide;0===e?r.forEach((function(t){return t.hide()})):this.dissolveElements(r,"out",.01,e,null),0===t?(i.forEach((function(t){t.showAll()})),null!=n&&n()):this.dissolveElements(i,"in",e,t,n)}},{key:"allHideShow",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:.5,o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;this.collectionMethods.stop();var a,s,l,u,c=this.collectionMethods.getAllElements().filter((function(t){return t.isShown})),h=this.getAllElements(!1),f=h.filter((function(t){return!t.isShown})),d=h.filter((function(t){return t.isShown})),p=e;0!==h.length||0!==c.length||null==o?(a=function(){t.setPositions()},0===h.length&&(a=function(e){t.setPositions(),null!=o&&o(e)}),0<c.length?(this.dissolveElements(c,"out",e,n,a),p+=n):this.setPositions(),this.applyElementMods(),s=h.length,l=0,u=function(t){(l+=1)===s-1&&o&&o(t)},f.forEach((function(t){t.animations.addTo("_EquationColor").dissolveIn({duration:r,onFinish:u,delay:p+i}).start()})),d.forEach((function(t){t.animations.addTo("_EquationColor").dissolveIn({duration:r,onFinish:u,delay:i}).start()}))):o(!1)}},{key:"applyElementMods",value:function(){function t(t){Object.keys(t).forEach((function(e){e=(n=t[e]).element;var n=n.mods;null!=e&&null!=n&&(e.setProperties(n),null!=n.color&&e.setColor(n.color),null!=n.opacity&&e.setOpacity(n.opacity))}))}var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;t(this.elementMods),null!=e&&0<e.length&&null!=this.fromForm[e]&&null!=this.fromForm[e].elementMods&&t(this.fromForm[e].elementMods)}},{key:"animatePositionsTo",value:function(t,e,n,i){var r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null,a=6<arguments.length&&void 0!==arguments[6]&&arguments[6],s=this.collectionMethods.getAllElements();this.collectionMethods.stop();var l=this.getAllElements(!1);l.forEach((function(t){.001===t.opacity&&t.hide(),t.setOpacity(1)}));var u=s.filter((function(t){return t.isShown})),c=u.filter((function(t){return-1===l.indexOf(t)})),h=l.filter((function(t){return-1===u.indexOf(t)})),f=this.collectionMethods.getElementTransforms();this.setPositions();var d=this.collectionMethods.getElementTransforms(),p=[],m=[],y=[];Object.keys(d).forEach((function(t){var e=f[t],n=d[t];e.isEqualTo(n)||(p.push(t),m.push(e),y.push(n))}));var v,g={};h.forEach((function(t){g[t.name]=t.transform._dup()})),v=null===n?qe(m,y,0,new pe(.35,.35),2*Math.PI/6,new pe(.4,.4)):n,this.collectionMethods.setElementTransforms(f),this.collectionMethods.setElementTransforms(g);var b=t,w=null;s=null,n=null,a?0===p.length&&0===h.length?n=r:0===p.length?s=r:w=r:0===p.length&&0===h.length?n=r:0===h.length?w=r:s=r,0<c.length?(this.dissolveElements(c,"out",t,e,n),b+=e):null!=n&&this.fnMap.exec(n),this.applyElementMods(o);var x="string"==typeof o&&0!==o.length&&null!=this.fromForm&&null!=this.fromForm[o]&&void 0!==this.fromForm[o].translation?ct({},this.translation,this.fromForm[o].translation):ct({},this.translation);return Object.keys(x).forEach((function(t){var e=(i=x[t]).element,n=i.style,i=(t=i.direction,i.mag);e&&(null!=n&&(e.animations.options.translation.style=n),null!=t&&(e.animations.options.translation.direction=t),null!=i&&(e.animations.options.translation.magnitude=i))})),a&&0<h.length&&(this.dissolveElements(h,"in",b,i,s),b+=i+.001),0<(w=this.collectionMethods.animateToTransforms(d,v,b,0,w,"_Equation"))&&(b=w),a||0<h.length&&(this.dissolveElements(h,"in",b,i,s),b+=i+.001),b}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function kl(t){return(kl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ol(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return _l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_l(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Pl(t,e){return(Pl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function El(t){return(El=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ml=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Pl(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=El(e);return function(t,e){if(e&&("object"===kl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=El(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i,r,o,a=t.side,s="left"===a||"right"===a?(u=(i=Ol(this.getLeftPoints(t,e,n),4))[0],r=i[1],o=i[2],i[3]):(u=(s=Ol(this.getLeftPoints(t,n,e),4))[0],r=s[1],o=s[2],s[3]),l="right"===a?(new Ee).scale(-1,1).translate(o,0):"top"===a?(new Ee).translate(0,-s/2).rotate(-Math.PI/2).translate(s/2,o):"bottom"===a?(new Ee).translate(0,-s/2).rotate(Math.PI/2).translate(s/2,0):new Ee,u=u.map((function(t){return t.transformBy(l.m())})),c=r.map((function(t){return t.transformBy(l.m())})),h=[];return u.forEach((function(t,e){e=c[e],h.push(t),h.push(e)})),"top"===a||"bottom"===a?[h,s,o,"strip"]:[h,o,s,"strip"]}},{key:"getLeftPoints",value:function(t,e,n){for(var i=t.sides,r=(o=this.getVerticalDefaultValues(n,e,t)).lineWidth,o=(e=o.width,t=o.tipWidth,e-r),a=(Math.pow(o,2)+Math.pow(n/2,2))/(2*o),s=(t=e-t,(Math.pow(t,2)+Math.pow(n/2,2))/(2*t)),l=Math.asin(n/2/a),u=2*l/i,c=Math.asin(n/2/s),h=2*c/i,f=[],d=[],p=0;p<i+1;p+=1)f.push(Re(a,l-u*p+Math.PI).add(a+r,n/2)),d.push(Re(s,c-h*p+Math.PI).add(s,n/2));return[d,f,f[0].x,n]}},{key:"getDefaultValues",value:function(t,e,n){var i={};return"left"===n.side||"right"===n.side?(i=this.getVerticalDefaultValues(t,e,n)).height=t:(n=(i=this.getVerticalDefaultValues(e,t,n)).width,i.width=e,i.height=n),i}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==e&&null==n.width&&(i.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(i.width=e),null!=n.width&&(i.width=n.width),null==n.lineWidth?i.lineWidth=.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041)):i.lineWidth=n.lineWidth,null==n.tipWidth?i.tipWidth=i.lineWidth/3:i.tipWidth=n.tipWidth,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Bl(t){return(Bl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Cl(t,e){return(Cl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function jl(t){return(jl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Rl=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Cl(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=jl(e);return function(t,e){if(e&&("object"===Bl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=jl(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i=t.fill;return e=(n=this.getDefaultValues(n,e,t)).lineWidth,t=n.width,n=n.height,[e=i?[new pe(0,0),new pe(t,0),new pe(0,n),new pe(t,n)]:[new pe(0,0),new pe(e,e),new pe(0,n),new pe(e,n-e),new pe(t,n),new pe(t-e,n-e),new pe(t,0),new pe(t-e,e),new pe(0,0),new pe(e,e)],t,n,"strip"]}},{key:"getBounds",value:function(t,e,n,i,r){var o=this.getDefaultValues(r,i,t),a=o.lineWidth,s=o.width,l=o.height,u=new $s;return"static"===t.draw?(o=t.staticWidth,t=a/(null==(t="first"===(t=t.staticHeight)?l+2*a:t)?1:t),o=a/(null==(o="first"===o?s+2*a:o)?1:o),u.width=s/(1-2*o),u.height=l/(1-2*t),o=u.width*o,t=u.height*t,u.left=e-o,u.right=u.left+u.width,u.bottom=n-t,u.top=u.bottom+u.height,u.ascent=u.height,u.descent=0):(u.left=e+i/2-s/2-a,u.bottom=n+r/2-l/2-a,u.width=s+2*a,u.height=l+2*a,u.right=u.left+u.width,u.top=u.bottom+u.height,u.descent=0,u.ascent=u.height),u}},{key:"getDefaultValues",value:function(t,e,n){var i={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?i.lineWidth=n.lineWidth:i.lineWidth=.01,!0===n.fill&&(i.lineWidth=0),null!=n.height&&"number"==typeof n.height?i.height=n.height:i.height=null!=t?t:1,null!=n.width&&"number"==typeof n.width?i.width=n.width:i.width=null!=e?e:1,i}},{key:"surround",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"local",r=[t];0!==(r=null!=e&&0!==e.length?t.getElements(e):r).length&&(n=ue("number"==typeof n?[n,n]:n),(i=t instanceof rs?t.getBoundingRect(i,"border",e):t.getBoundingRect(i)).left-=n.x,i.bottom-=n.y,i.width+=2*n.x,i.height+=2*n.y,i.right=i.left+i.width,i.top=i.bottom+i.height,this._custom.setSize(new pe(i.left,i.bottom),i.width,i.height))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Fl(t){return(Fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Dl(t,e){return(Dl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Il(t){return(Il=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ll=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Dl(t,e)}(r,Ml);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Il(e);return function(t,e){if(e&&("object"===Fl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Il(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){for(var i=t.sides,r=(s=this.getVerticalDefaultValues(n,e,t)).lineWidth,o=s.width,a=o/2+r/2,s=(t=a-(e=s.tipWidth),a-r),l=(Math.pow(s,2)+Math.pow(t,2))/(2*s),u=[],c=[],h=Math.PI/2/i,f=Math.asin(t/l)/i,d=[],p=[],m=0;m<i+1;m+=1){var y=m*h,v=m*f;p.push(new pe(a*Math.cos(y),a*Math.sin(y))),d.push(new pe(l*Math.cos(v)-l+a-r,l*Math.sin(v)))}for(var g=(new Ee).scale(-1,1).translate(o,n-a).m(),b=0;b<i+1;b+=1)u.push(p[i-b].transformBy(g)),c.push(d[i-b].transformBy(g));g=(new Ee).scale(1,-1).translate(0,n/2-e/2+a).m();for(var w=0;w<i+1;w+=1)u.push(d[w].transformBy(g)),c.push(p[w].transformBy(g));g=(new Ee).translate(0,n/2+e/2-a).m();for(var x=0;x<i+1;x+=1)u.push(d[i-x].transformBy(g)),c.push(p[i-x].transformBy(g));g=(new Ee).scale(-1,-1).translate(o,a).m();for(var S=0;S<i+1;S+=1)u.push(p[S].transformBy(g)),c.push(d[S].transformBy(g));return[u,c,o,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==e&&null==n.width&&(i.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(i.width=e),null!=n.width&&(i.width=n.width),null==n.lineWidth?i.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):i.lineWidth=n.lineWidth,null==n.tipWidth?i.tipWidth=i.lineWidth/3:i.tipWidth=n.tipWidth,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Wl(t){return(Wl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function zl(t,e){return(zl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Nl(t){return(Nl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ql=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&zl(t,e)}(i,Ml);var t,e,n=(t=i,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,i=Nl(t);return function(t,e){if(e&&("object"===Wl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Nl(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,[{key:"getLeftPoints",value:function(t,e,n){var i=t.sides,r=t.radius,o=(e=(o=this.getVerticalDefaultValues(n,e,t)).lineWidth,t=o.width,o.tipWidth);if(0===r)return[[new pe(t,0),new pe(0,0),new pe(0,n),new pe(t,n)],[new pe(t,o),new pe(e,o),new pe(e,n-o),new pe(t,n-o)],t,n];for(var a=r=Math.min(r,t,n/2),s=r-e,l=[new pe(t,0)],u=[new pe(t,e)],c=new pe(a,a),h=new pe(a,n-a),f=0;f<=i;f+=1){var d=Math.PI/2/i*f;l.push(Re(a,Math.PI/2*3-d).add(c)),u.push(Re(s,Math.PI/2*3-d).add(c))}for(var p=0;p<=i;p+=1){var m=Math.PI/2/i*p;l.push(Re(a,Math.PI-m).add(h)),u.push(Re(s,Math.PI-m).add(h))}return l.push(new pe(t,n)),u.push(new pe(t,n-e)),[l,u,t,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==e&&null==n.width&&(i.width=.8*(97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909)))),null!=e&&(i.width=e),null!=n.width&&(i.width=n.width),null==n.lineWidth?i.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):i.lineWidth=n.lineWidth,null==n.tipWidth?i.tipWidth=.7*i.lineWidth:i.tipWidth=n.tipWidth,i}}]),i}();function Hl(t){return(Hl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Kl(t,e){return(Kl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ul(t){return(Ul=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Vl=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Kl(t,e)}(i,Ml);var t,e,n=(t=i,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,i=Ul(t);return function(t,e){if(e&&("object"===Hl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Ul(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,[{key:"getLeftPoints",value:function(t,e,n){e=(i=this.getVerticalDefaultValues(n,e,t)).lineWidth,t=i.width;var i=new Se(new pe(0,0),new pe(t,n/2));return e=Math.acos(e/i.distance),e=Math.PI/2-e,e=i.ang+e,e=t-n/2/Math.tan(e),[[new pe(t-e,0),new pe(0,n/2),new pe(t-e,n)],[new pe(t,0),new pe(e,n/2),new pe(t,n)],t,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==e&&null==n.width&&(i.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(i.width=e),null!=n.width&&(i.width=n.width),null==n.lineWidth?i.lineWidth=.7*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):i.lineWidth=n.lineWidth,i}}]),i}();function Gl(t){return(Gl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Yl(t,e){return(Yl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Xl(t){return(Xl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var $l=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Yl(t,e)}(r,Ml);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Xl(e);return function(t,e){if(e&&("object"===Gl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Xl(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){return t=(e=this.getVerticalDefaultValues(n,e,t)).lineWidth,e=e.width,[[new pe(0,0),new pe(0,n)],[new pe(t,0),new pe(t,n)],e,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==n.lineWidth?i.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):i.lineWidth=n.lineWidth,i.width=i.lineWidth,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ql(t){return(Ql="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Jl(t,e){return(Jl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Zl(t){return(Zl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var tu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Jl(t,e)}(i,cl);var t,e,n=(t=i,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,i=Zl(t);return function(t,e){if(e&&("object"===Ql(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Zl(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(i.prototype,[{key:"getPoints",value:function(t,e,n){var i=t.sides,r=(b=this.getDefaultValues(n,e,t)).lineWidth,o=b.width,a=Math.PI/2*.9,s=Math.PI/2*.95,l=.431*o,u=n/2-r,c=.176*n,h=.153*n,f=c/Math.tan(a),d=h/Math.tan(s),p=r,m=2*r,y=3*r,v=.6*r,g=new Se(new pe(0,0),new pe(l,u)),b=(e=p/Math.sin(g.ang),t=new Se(new pe(e,0),n,g.ang),new Se(new pe(0,n),new pe(l,u))),w=(r=-y/Math.sin(b.ang),e=new Se(new pe(r,n),n,b.ang),r=t.intersectsWith(e).intersect,t=new pe(o,c),e=new pe(o-v,c),new pe(o-f,0)),x=(f=new pe(e.x-(c-m)/Math.tan(a),m),a=new pe(0,0),g=new pe(p/Math.sin(g.ang)+m/Math.tan(g.ang),m),l=new pe(l,u),u=r,r=new pe(0,n),b=new pe(-y/Math.sin(b.ang)-p/Math.tan(b.ang),n-p),new pe(o-d,n)),S=(d=new pe(o,n-h),v=new pe(o-v,n-h),s=new pe(v.x-(h-p)/Math.tan(s),n-p),m=He(e,f,new pe(f.x-(c-m),m),i),[]);m.forEach((function(t){S.push(w),S.push(t)})),i=He(new pe(s.x-h+p,n-p),s,v,i);var T=[];return i.forEach((function(t){T.push(x),T.push(t)})),[[t,e].concat(S,[a,g,l,u,r,b],T,[d,v]),o,n,"strip"]}},{key:"getDefaultValues",value:function(t,e,n){return t={lineWidth:.88*t/(25*t+15),width:.88*t,height:t},null!=n.lineWidth&&(t.lineWidth=n.lineWidth),null!=n.width&&(t.width=n.width),t}}]),i}();function eu(t){return(eu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function nu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function iu(t,e){return(iu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ru(t){return(ru=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ou=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&iu(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=ru(e);return function(t,e){if(e&&("object"===eu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ru(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i=t.serif,r=t.sides,o=(b=this.getDefaultValues(n,e,t)).lineWidth,a=b.width,s=r;"false"===i&&(s=2);var l=1.2*o,u=3*o,c=o/2,h=.9*u,f=new pe(0,0),d=new pe(u+2*h,0),p=new pe(f.x,c),m=new pe(d.x,c),y=new pe(h,p.y),v=new pe(h+u,y.y),g=(e=new pe(y.x,n-c),new pe(v.x,n-c)),b=(t=new pe(p.x,n-c),new pe(p.x,n)),w=(r=new pe(m.x,n),i=p,o=y,c=new pe(y.x,y.y+h),p=m,m=v,y=new pe(v.x,y.y+h),c=He(i,o,c,s),He(p,m,y,s)),x=[];c.forEach((function(t,e){x.push(t),x.push(w[e])})),s=He(new pe(e.x,e.y-h),e,t,s);var S=[];s.forEach((function(t){S.push(t),S.push(new pe(g.x,t.y))}));for(var T,A=[f,d].concat(x,S,[b,r]),k=[],O=A.length-1;0<O;O-=2)k.push(new pe(a-A[O-1].x,A[O-1].y)),k.push(new pe(a-A[O].x,A[O].y));return l=[new pe(h+u,n),new pe(h+u,n-l),new pe(a-h-u,n),new pe(a-h-u,n-l)],[[].concat(function(t){if(Array.isArray(t))return nu(t)}(T=A)||function(){if("undefined"!=typeof Symbol&&null!=T[Symbol.iterator]||null!=T["@@iterator"])return Array.from(T)}()||function(t){if(t){if("string"==typeof t)return nu(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nu(t,void 0):void 0}}(T)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),l,k),a,n,"strip"]}},{key:"getDefaultValues",value:function(t,e,n){var i={lineWidth:n.lineWidth||1,width:e||1,height:t};return null==n.lineWidth&&null!=e?i.lineWidth=e/7/3:null==n.lineWidth&&null==e?(i.lineWidth=12902.65+-12902.648946996/(1+Math.pow(t/573148,.9938213)),i.width=1704804+-1704803.997815697/(1+Math.pow(t/2234236,.9967453))):null!=n.lineWidth&&null==e&&(i.width=7*n.lineWidth*3),i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function au(t){return(au="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function su(t){return function(t){if(Array.isArray(t))return lu(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return lu(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?lu(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function uu(t,e){return(uu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function cu(t){return(cu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var hu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&uu(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=cu(e);return function(t,e){if(e&&("object"===au(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=cu(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i,r,o=t.sides,a=t.serif,s=t.num,l=t.type,u=t.serifSides,c=t.lineIntegralSides,h=(e=this.getDefaultValues(n,e,t)).lineWidth,f=(t=e.width,e.tipWidth),d=t-(s-1)*h*3,p=n,m=.7*h,y=(e=d,o=A(-(e=a?d-2*m:e)/2,e/2,e/o),-Math.log(n/(.99999999999*n)-1)/d/2),v=0,g=[];o.forEach((function(t,e){var o=1/(1+Math.exp(-y*t)),a=Math.atan(p*y*o*(1-o)),s=o*p,l=(u=(h/2-f/2)*Math.pow(Math.cos((s-n/2)/n*Math.PI),2)+f/2)*Math.cos(a+Math.PI/2),u=(o=u*Math.sin(a+Math.PI/2),new pe(t+l+d/2,s+o));o=new pe(t-l+d/2,s-o),0<e&&(g.push(i._dup()),g.push(r._dup()),g.push(o._dup()),g.push(i._dup()),g.push(o._dup()),g.push(u._dup())),i=u,r=o,0===e&&(v=a)}));var b=[];if(!1===a)b=g;else{for(var w=u,x=new pe(g[1].x+m*Math.cos(v+Math.PI/2),g[1].y+m*Math.sin(v+Math.PI/2)),S=new pe(g[g.length-1].x+m*Math.cos(v-Math.PI/2),g[g.length-1].y+m*Math.sin(v-Math.PI/2)),T=[],k=[],O=2*Math.PI/Math.max(w,3),_=new pe(0,0),P=new pe(0,0),E=0;E<w+1;E+=1){var M=new pe(x.x+m*Math.cos(O*E),x.y+m*Math.sin(O*E)),B=new pe(S.x+m*Math.cos(O*E),S.y+m*Math.sin(O*E));0<E&&(T.push(g[1]._dup()),T.push(_._dup()),T.push(M._dup()),k.push(g[g.length-2]._dup()),k.push(P._dup()),k.push(B._dup())),_=M,P=B}b=[].concat(T,g,k)}for(var C=b.length,j=1;j<s;j+=1)for(var R=0;R<C;R+=1)b.push(b[R].add(3*h*j,0));return"line"===l&&(c=this.getLineIntegralPoints(h,s,t,n,c),b=[].concat(su(b),su(c))),[b,t,n,"triangles"]}},{key:"getLineIntegralPoints",value:function(t,e,n,i,r){for(var o=6*t,a=Math.max(o,2*(3*t+(e-1)*t*3/2)),s=new pe(n/2,i/2),l=2*Math.PI/r,u=new pe(0,0),c=new pe(0,0),h=t/2,f=[],d=0;d<r+1;d+=1){var p=d*l,m=new pe((a/2-h/2)*Math.cos(p),(o/2-h/2)*Math.sin(p)).add(s);p=new pe((a/2+h/2)*Math.cos(p),(o/2+h/2)*Math.sin(p)).add(s),0<d&&(f.push(u._dup()),f.push(c._dup()),f.push(m._dup()),f.push(u._dup()),f.push(m._dup()),f.push(p._dup())),u=p,c=m}return f}},{key:"getDefaultValues",value:function(t,e,n){var i=607.73+-607.7295779198/(1+Math.pow(t/5368595,.6370402));return t={lineWidth:i,width:12277.16+-12277.156262281/(1+Math.pow(t/36507180,.6193363))+(n.num-1)*i*3,tipWidth:.01033455+-.010329798066/(1+Math.pow(t/.2588074,2.024942)),height:t},null!=e&&(t.width=e),null!=n.lineWidth&&(t.lineWidth=n.lineWidth),null!=n.tipWidth?t.tipWidth=n.tipWidth:t.tipWidth=t.lineWidth/3,t}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function fu(t){return(fu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function du(t,e){return(du=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function pu(t){return(pu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var mu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&du(t,e)}(r,Ml);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=pu(e);return function(t,e){if(e&&("object"===fu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=pu(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){var i=t.direction,r=n;null==r&&(r=t.length);var o,a=(c=this.getVerticalDefaultValues(r,e,t)).lineWidth,s=c.arrowWidth,l=c.arrowLength,u=new pe(s/2+a/2,0),c=(n=new pe(s/2-a/2,0),e=new pe(u.x,r-l),t=new pe(n.x,e.y),new pe(s,e.y));return a=new pe(0,e.y),l=new pe(s/2,r),a=[n._dup(),t._dup(),a._dup(),l._dup()],l=[u._dup(),e._dup(),c._dup(),l._dup()],"down"!==i&&"left"!==i||(o=(new Ee).scale(1,-1).translate(0,r).m(),a=a.map((function(t){return t.transformBy(o)})),l=l.map((function(t){return t.transformBy(o)}))),[a,l,s,r]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var i={};return null==n.lineWidth?i.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):i.lineWidth=n.lineWidth,null==n.arrowWidth?i.arrowWidth=3*i.lineWidth:i.arrowWidth=n.arrowWidth,null==n.arrowLength?i.arrowLength=3*i.lineWidth:i.arrowLength=n.arrowLength,i.width=i.arrowWidth,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function yu(t){return(yu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function vu(t,e){return(vu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function gu(t){return(gu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var bu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&vu(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=gu(e);return function(t,e){if(e&&("object"===yu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=gu(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){return e=(n=this.getDefaultValues(n,e,t)).lineWidth,t=n.width,n=n.height,[[new pe(0,0),new pe(0,e),new pe(t,0),new pe(t,e)],t,n,"strip"]}},{key:"getDefaultValues",value:function(t,e,n){var i={};return null!=n.lineWidth?i.lineWidth=n.lineWidth:i.lineWidth=.01,i.height=i.lineWidth,i.width=null!=e?e:1,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function wu(t){return(wu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function xu(t,e){return(xu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Su(t){return(Su=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Tu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&xu(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Su(e);return function(t,e){if(e&&("object"===wu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Su(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i=t.style,r=(p=this.getDefaultValues(n,e,t)).lineWidth,o=p.width,a=p.height,s=Math.atan2(a,o),l=Math.PI/2-s,u=r*Math.cos(l),c=r*Math.sin(l),h=new pe(0,c),f=new pe(u,0),d=new pe(0,a-c),p=(n=new pe(u,a),e=new pe(o-u,a),t=new pe(o,a-c),new pe(o-u,0));return s=new pe(o,c),l=new pe(0,a/2-r/2),u=new pe(0,a/2+r/2),c=new pe(o,a/2-r/2),r=new pe(o,a/2+r/2),[u="forward"===i?[h,f,t,h,t,e]:"back"===i?[d,n,s,d,s,p]:"cross"===i?[h,f,t,h,t,e,d,n,s,d,s,p]:[l,c,r,l,r,u],o,a,"triangles"]}},{key:"getBounds",value:function(t,e,n,i,r){return i=(r=this.getDefaultValues(r,i,t)).width,t=r.height,(r=new $s).left=e,r.bottom=n,r.width=i,r.height=t,r.right=r.left+r.width,r.top=r.bottom+r.height,r.descent=0,r.ascent=r.height,r}},{key:"getDefaultValues",value:function(t,e,n){var i={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?i.lineWidth=n.lineWidth:i.lineWidth=.015,null!=n.height&&"number"==typeof n.height?i.height=n.height:i.height=null!=t?t:1,null!=n.width&&"number"==typeof n.width?i.width=n.width:i.width=null!=e?e:1,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Au(t){return(Au="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ku(t,e){return(ku=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ou(t){return(Ou=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var _u=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ku(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Ou(e);return function(t,e){if(e&&("object"===Au(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ou(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i=(f=this.getDefaultValues(n,e,t)).lineWidth,r=f.startWidth,o=f.tickWidth,a=f.tickHeight,s=f.downWidth,l=f.startHeight,u=f.lineWidth2,c=f.height,h=f.width,f=(t=new pe(0,l-a),new pe(o,l));return a=new pe(s+o,0),l=new pe(r,c-i),s=new pe(h,c-i),o=new Se(t,f),r=new Se(f,a),h=new Se(a,l),c=new Se(l,s),o=o.offset("top",i),r=r.offset("top",u),u=h.offset("top",i),h=c.offset("top",i),c=o.p1._dup(),o=o.intersectsWith(r).intersect,r=r.intersectsWith(u).intersect,h=u.intersectsWith(h).intersect,i=s.add(0,i),[[t,c,f,o,a,r,l,h,s,i],e,n,"strip"]}},{key:"getBounds",value:function(t,e,n,i,r){var o=this.getHeightFromContentHeight(r,t),a=this.getDefaultValues(o,i,t),s=a.width,l=a.startWidth,u=a.lineWidth,c=a.startHeight,h=a.downWidth,f=a.tickWidth,d=a.lineWidth2;return r=new $s,"static"===t.draw?(a=t.staticWidth,u/=t=null==(t="first"===(t=t.staticHeight)?o+u:t)?1:t,a=l/(null==(a="first"===a?s+l:a)?1:a),t=c/t,r.width=s/(1-a),r.height=o/(1-u),a=r.width*a,t=r.height*t,u=r.height*u,r.left=e-a,r.right=r.left+r.width,r.bottom=n,r.top=r.bottom+r.height,r.ascent=r.height,r.descent=0,r.annotations={root:{xPosition:"left",yPosition:"bottom",xAlign:"right",yAlign:"bottom",offset:new pe(.5*a,t+2*u)}}):(r.left=e+i/2-s/2-l,r.bottom=n,r.width=s+l,r.height=o,r.right=r.left+r.width,r.top=r.bottom+r.height,r.descent=0,r.ascent=r.height,r.annotations={root:{xPosition:"left",yPosition:"bottom",xAlign:"right",yAlign:"bottom",offset:new pe(h+f,c+d)}}),r}},{key:"getHeightFromContentHeight",value:function(t,e){return(t=null!=t?t:1)+(null!=e.lineWidth&&"number"==typeof e.lineWidth?e.lineWidth:.01)}},{key:"getDefaultValues",value:function(t,e,n){var i={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?i.lineWidth=n.lineWidth:i.lineWidth=.01,null!=n.lineWidth2&&"number"==typeof n.lineWidth2?i.lineWidth2=n.lineWidth2:i.lineWidth2=2*i.lineWidth,null!=n.height&&"number"==typeof n.height?i.height=n.height:i.height=null!=t?t:1,null!=n.startHeight&&"number"==typeof n.startHeight?(i.startHeight=n.startHeight,n.proportionalToHeight&&(i.startHeight=n.startHeight*i.height)):i.startHeight=i.height/3,null!=n.maxStartHeight&&n.maxStartHeight<i.startHeight&&(i.startHeight=n.maxStartHeight),null!=n.tickHeight&&"number"==typeof n.tickHeight?(i.tickHeight=n.tickHeight,n.proportionalToHeight&&(i.tickHeight=n.tickHeight*i.startHeight)):i.tickHeight=.1*i.startHeight,null!=n.startWidth&&"number"==typeof n.startWidth?(i.startWidth=n.startWidth,n.proportionalToHeight&&(i.startWidth=n.startWidth*i.height)):i.startWidth=i.startHeight/2,null!=n.maxStartWidth&&n.maxStartWidth<i.startWidth&&(i.startWidth=n.maxStartWidth),null!=n.tickWidth&&"number"==typeof n.tickWidth?(i.tickWidth=n.tickWidth,n.proportionalToHeight&&(i.tickWidth=n.tickWidth*i.startWidth)):i.tickWidth=i.startWidth/5,null!=n.downWidth&&"number"==typeof n.downWidth?(i.downWidth=n.downWidth,n.proportionalToHeight&&(i.downWidth=n.downWidth*i.startWidth)):i.downWidth=i.startWidth/5*2,null!=n.width&&"number"==typeof n.width?i.width=n.width:i.width=null!=e?e:1,i}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Pu(t){return(Pu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Eu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Mu(t,e){return(Mu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Bu(t){return(Bu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Cu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Mu(t,e)}(r,cl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Bu(e);return function(t,e){if(e&&("object"===Pu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Bu(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var i=new Se([0,0],n,e);return[(i=Nn([new pe(0,0),i.p2],t.width,!1,"mid","none",.1,1,0,t.dash,!1,2,[[]],0,[[]],t.arrow),t=1,(function(t){if(Array.isArray(t))return t}(i)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(i,t)||function(t,e){if(t){if("string"==typeof t)return Eu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Eu(t,e):void 0}}(i,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),e,n,"triangles"]}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}(),ju=function(){function t(e,n){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.shapes=e,this.defaultColor=n}var e=[{key:"get",value:function(t,e){return"vinculum"===t?this.vinculum(e):"strike"===t?this.strike(e):"bracket"===t?this.bracket(e):"squareBracket"===t?this.squareBracket(e):"brace"===t?this.brace(e):"bar"===t?this.bar(e):"tBox"===t?this.touchBox(e):"box"===t?this.box(e):"angleBracket"===t?this.angleBracket(e):"radical"===t?this.radical(e):"sum"===t?this.sum(e):"prod"===t?this.product(e):"int"===t?this.integral(e):"arrow"===t?this.arrow(e):"line"===t?this.line(e):null}},{key:"vinculum",value:function(t){return t=ct({color:this.defaultColor,lineWidth:null,staticHeight:null,draw:"dynamic",staticWidth:"first",drawBorderBuffer:0,touchBorder:0},t),new bu(this.shapes.webgl[0],t.color,new Ee("VinculumSymbol").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"box",value:function(t){return t=ct({color:this.defaultColor,fill:!1,width:null,height:null,lineWidth:.01,draw:"dynamic",staticHeight:"first",staticWidth:"first"},t),new Rl(this.shapes.webgl[0],t.color,new Ee("Box").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"line",value:function(t){return t=ct({color:this.defaultColor,width:.01,dash:[],arrow:null,draw:"dynamic",staticHeight:"first",staticWidth:"first"},t),new Cu(this.shapes.webgl[0],t.color,new Ee("Line").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"touchBox",value:function(t){return t=ct({color:[0,0,0,1e-4],fill:!1,width:null,height:null,lineWidth:.01,draw:"static",staticHeight:"first",staticWidth:"first",isTouchable:!0},t),new Rl(this.shapes.webgl[0],t.color,new Ee("TouchBox").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"arrow",value:function(t){return"left"===(t=ct({color:this.defaultColor,direction:"right",lineWidth:.01,arrowWidth:.03,arrowLength:.04,length:.1,staticHeight:"first",draw:"dynamic",staticWidth:null},t)).direction||"right"===t.direction?t.side="top":t.side="left",new mu(this.shapes.webgl[0],t.color,new Ee("ArrowSymbol").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"sum",value:function(t){return t=ct({color:this.defaultColor,lineWidth:null,sides:5,staticHeight:"first",draw:"static",staticWidth:null,drawBorderBuffer:0,touchBorder:0},t),new tu(this.shapes.webgl[0],t.color,new Ee("sum").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"product",value:function(t){return t=ct({color:this.defaultColor,lineWidth:null,sides:5,staticHeight:"first",draw:"static",staticWidth:null},t),new ou(this.shapes.webgl[0],t.color,new Ee("Sum").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"integral",value:function(t){return t=ct({color:this.defaultColor,lineWidth:null,width:null,tipWidth:null,sides:30,serif:!0,staticHeight:"first",draw:"static",staticWidth:null,num:1,type:"generic",serifSides:10,lineIntegralSides:20},t),new hu(this.shapes.webgl[0],t.color,new Ee("Integral").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"radical",value:function(t){var e={color:this.defaultColor,lineWidth:.01,staticSize:null,startHeight:.5,startWidth:.5,maxStartWidth:.15,maxStartHeight:.15,proportionalToHeight:!0,draw:"dynamic",staticHeight:"first",staticWidth:"first"};return null!=t.proportionalToHeight&&!1===t.proportionalToHeight&&(e.startHeight=.15,e.startWidth=.15),t=ct(e,t),new _u(this.shapes.webgl[0],t.color,new Ee("bracket").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"strike",value:function(t){return t=ct({style:"cross",color:this.defaultColor,lineWidth:null,draw:"dynamic",staticHeight:"first",width:null,height:null,staticWidth:"first"},t),new Tu(this.shapes.webgl[0],t.color,new Ee("bracket").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"bracket",value:function(t){return t=ct({side:"left",color:this.defaultColor,lineWidth:null,sides:10,draw:"dynamic",staticHeight:"first",width:null,tipWidth:null,staticWidth:null},t),new Ml(this.shapes.webgl[0],t.color,new Ee("bracket").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"angleBracket",value:function(t){return t=ct({side:"left",lineWidth:null,width:null,color:this.defaultColor,draw:"dynamic",staticHeight:"first"},t),new Vl(this.shapes.webgl[0],t.color,new Ee("bar").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"brace",value:function(t){return t=ct({side:"left",color:this.defaultColor,lineWidth:null,sides:10,draw:"dynamic",staticHeight:"first",width:null,tipWidth:null,staticWidth:null},t),new Ll(this.shapes.webgl[0],t.color,new Ee("brace").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"bar",value:function(t){return t=ct({side:"left",lineWidth:.01,color:this.defaultColor,draw:"dynamic",staticHeight:"first"},t),new $l(this.shapes.webgl[0],t.color,new Ee("bar").scale(1,1).translate(0,0),this.shapes.limits,t)}},{key:"squareBracket",value:function(t){return t=ct({side:"left",lineWidth:null,color:this.defaultColor,width:null,draw:"dynamic",staticHeight:"first",radius:0,sides:5,tipWidth:null},t),new ql(this.shapes.webgl[0],t.color,new Ee("bar").scale(1,1).translate(0,0),this.shapes.limits,t)}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function Ru(t){return(Ru="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fu(t){return function(t){if(Array.isArray(t))return Du(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Du(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Du(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Du(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Iu(t,e){return(Iu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Lu(t){return(Lu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Wu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Iu(t,e)}(r,rl);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Lu(e);return function(t,e){if(e&&("object"===Ru(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Lu(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e,n){var o=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var a=[];Array.isArray(e)?e.forEach((function(t){a.push(null!=t?new il(t):null)})):a.push(null!=e?new il(e):null);var s=[];return Array.isArray(e)?s=e:s.push(e),e=[],Array.isArray(t)?e=t:e.push(t),(t=i.call(this,[].concat(a,Fu(e)))).glyphs=s,t.contents=e,t.glyphLocations=a.map((function(){return new pe(0,0)})),t.glyphWidths=a.map((function(){return 1})),t.glyphHeights=a.map((function(){return 1})),t.options=n,t.showContent=o,t}return t=[{key:"_dup",value:function(t){var e,n=this.contents.map((function(e){return null==e?null:e._dup(t)})),i=this.glyphs;return t&&(e=[],this.glyphs.forEach((function(n){null!=n?e.push(t[n.name]):e.push(n)})),i=e),ht(this,i=new this.constructor(n,i,this.options),["content","contents","glyphs"]),i}},{key:"getAllElements",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!t&&!this.showContent)return[];var e=[];return this.contents.forEach((function(n){null!=n&&(e=[].concat(Fu(e),Fu(n.getAllElements(t))))})),this.glyphs.forEach((function(t){null!=t&&(e=[].concat(Fu(e),[t]))})),e}},{key:"setPositions",value:function(){var t=this;this.glyphs.forEach((function(e,n){var i;null!=e&&((i=e.getTransform()._dup()).updateTranslation(t.glyphLocations[n].x,t.glyphLocations[n].y),i.updateScale(t.glyphWidths[n],t.glyphHeights[n]),e.setTransform(i))})),this.contents.forEach((function(t){null!=t&&t.setPositions()}))}},{key:"offsetLocation",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new pe(0,0);this.location=this.location.add(e),this.glyphLocations.forEach((function(n,i){null!=t.glyphs[i]&&(t.glyphLocations[i]=n.add(e))})),this.contents.forEach((function(t){null!=t&&t.offsetLocation(e)}))}},{key:"calcSize",value:function(t,e){}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function zu(t){return(zu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Nu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return qu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Hu(t,e){return(Hu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ku(t){return(Ku=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Uu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Hu(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Ku(e);return function(t,e){if(e&&("object"===zu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ku(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),i=Nu(this.glyphs,1)[0],r=(m=Nu(this.contents,2))[0],o=m[1],a=(y=this.options).scaleModifier,s=y.numeratorSpace,l=y.denominatorSpace,u=y.overhang,c=y.offsetY,h=y.fullContentBounds,f=y.baseline,d=e*a,p=new $s,m=new $s,y=new $s;e=new $s,null!=r&&(r.calcSize(n._dup(),d),m.copyFrom(r.getBounds(h))),null!=o&&(o.calcSize(n._dup(),d),y.copyFrom(o.getBounds(h))),this.location=t._dup(),p.width=Math.max(m.width,y.width)+2*u*d,null!=i&&(p.height=i.getHeight(i._custom.options,p.width)),s=new pe(n.x+(p.width-m.width)/2,n.y+(a=d*c/a)+p.height+s*d+m.descent),l=new pe(n.x+(p.width-y.width)/2,n.y+a-l*d-y.ascent),d=0,"numerator"===f&&null!=r?d=n.y-s.y:"denominator"===f&&null!=o&&(d=n.y-l.y),null!=r&&r.offsetLocation(s.sub(r.location.x,r.location.y-d)),null!=o&&o.offsetLocation(l.sub(o.location.x,o.location.y-d)),this.width=p.width,this.descent=n.y-(l.y-y.descent),this.descent<0&&(this.descent=0),this.ascent=s.y+m.ascent-n.y,this.height=this.descent+this.ascent,this.glyphLocations[0]=new pe(this.location.x,this.location.y+a+d),this.glyphWidths[0]=p.width,this.glyphHeights[0]=p.height,e.copyFrom(p),e.left=this.glyphLocations[0].x,e.bottom=this.glyphLocations[0].y,null!=r&&e.growWithSameBaseline(r.getBounds(!0)),null!=o&&e.growWithSameBaseline(o.getBounds(!0)),i&&i._custom.setSize(this.glyphLocations[0],p.width,p.height),this.fullSize={leftOffset:this.location.x-e.left,width:e.width,ascent:e.ascent,descent:e.descent,height:e.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Vu(t){return(Vu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Gu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Yu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Xu(t,e){return(Xu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function $u(t){return($u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Qu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xu(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=$u(e);return function(t,e){if(e&&("object"===Vu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=$u(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();for(var n=t._dup(),i=.07*e,r=this.options,o=r.order,a=(t=r.fit,r.space),s=r.contentScale,l=r.yAlign,u=r.fullContentBounds,c=(o=Gu(o,2))[0],h=o[1],f=[],d=[],p=0,m=[],y=0;y<c;y+=1){m.push([]),f.push([]),d.push([]);for(var v=0;v<h;v+=1){var g=new $s,b=this.contents[p];null!=b&&(b.calcSize(n._dup(),e*s),g.copyFrom(b.getBounds(u))),m[y].push(b),f[y].push(g),d[y].push(new pe(0,0)),p+=1}}var w,x=function(t,e,n){for(var i=[],r=[],o=[],a=0,s=0,l=0,u=0;u<t;u+=1){for(var c=0,h=0,f=0;f<e;f+=1){var d=n[u][f];(d.ascent>c||0===f)&&(c=d.ascent),(d.descent>h||0===f)&&(h=d.descent)}(a<c||0===u)&&(a=c),(s<h||0===u)&&(s=h);var p=h+c;(l<p||0===u)&&(l=p),o.push(p),i.push(c),r.push(h)}return{ascents:i,descents:r,heights:o,maxAscent:a,maxDescent:s,maxHeight:l}}(c,h,f),S=(o=Gu(function(t,e,n){for(var i=[],r=0,o=0;o<e;o+=1){for(var a=0,s=0;s<t;s+=1){var l=n[s][o].width;a<l&&(a=l),r<l&&(r=l)}i.push(a)}return[i,r]}(c,h,f),2))[0];if(o=o[1],o=Math.max(o,x.maxHeight),"min"!==t){"max"===t?w=new pe(o,o):null==(w=le(t))&&(w=new pe(0,0));for(var T=0;T<c;T+=1)x.heights[T]=w.y;for(var A=0;A<h;A+=1)S[A]=w.x}for(var k=0,O=0,_=c-1;0<=_;--_){O=0;for(var P=0;P<h;P+=1){var E=f[_][P],M=O+S[P]/2-E.width/2;E=k+x.heights[_]/2-(E.ascent-E.descent)/2,"baseline"===l&&(E=k+x.descents[_]),O+=S[P]+a.x*e,d[_][P]=new pe(M,E)}k+="baseline"===l?x.descents[_]+x.ascents[_]+a.y*e:x.heights[_]+a.y*e}for(var B=k-a.y*e,C=(t=O-a.x*e,new $s),j=0;j<c;j+=1)for(var R=0;R<h;R+=1){d[j][R].x+=n.x,d[j][R].y=n.y-B/2+d[j][R].y+i;var F=m[j][R];null!=F&&(F.offsetLocation(d[j][R].sub(F.location)),0===C.width&&C.copyFrom(F.getBounds(!0)),C.growWithSameBaseline(F.getBounds(!0)))}this.width=t,this.height=B,this.descent=B/2-i,this.ascent=B/2+i,this.fullSize={leftOffset:this.location.x-C.left,width:C.width,ascent:C.ascent,descent:C.descent,height:C.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ju(t){return(Ju="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Zu(t,e){return(Zu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function tc(t){return(tc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ec=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Zu(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=tc(e);return function(t,e){if(e&&("object"===Ju(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=tc(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();for(var n=t._dup(),i=this.options,r=i.lineOptions,o=(t=i.yAlign,i.fullContentBounds),a=i.justify,s=r.length,l=[],u=[],c=0,h=0;h<s;h+=1){var f=new $s,d=this.contents[h];null!=d&&(d.calcSize(n._dup(),e),f.copyFrom(d.getBounds(o))),l.push(f),u.push(new pe(0,0)),f.width>c&&(c=f.width)}for(var p=u[0].y+l[0].ascent,m=u[0].y-l[0].descent,y=1;y<s;y+=1){var v=u[y-1].y,g=r[y],b=g.space;null!=(g=g.baselineSpace)?u[y].y=v-g:(w=l[y-1].descent,g=l[y].ascent,u[y].y=v-g-w-b);var w=u[y].y+l[y].ascent;p<w&&(p=w),(b=u[y].y-l[y].descent)<m&&(m=b)}var x=0;"top"===t?x=-p:"middle"===t?x=(p-m)/2-p:"bottom"===t?x-=m:"number"==typeof t&&t<s&&(x-=u[t].y);for(var S=0,T=0;T<s;T+=1)"right"===a?u[T].x=-l[T].width:"center"===a?u[T].x=-l[T].width/2:"element"===a&&null!=r[T].justify&&(u[T].x=-r[T].justify.transform.t().x),u[T].x+=r[T].offset,u[T].x<S&&(S=u[T].x);for(var A=0;A<s;A+=1)u[A].x-=S;for(var k=new $s,O=new $s,_=0;_<s;_+=1){var P=this.content[_];null!=P&&(P.offsetLocation(u[_].add(0,x)),0===k.width&&k.copyFrom(P.getBounds(!0)),k.growWithSameBaseline(P.getBounds(!0)),0===O.width&&O.copyFrom(P.getBounds(!1)),O.growWithSameBaseline(P.getBounds(!1)))}this.width=O.width,this.height=O.height,this.descent=O.descent,this.ascent=O.ascent,this.fullSize={leftOffset:this.location.x-k.left,width:k.width,ascent:k.ascent,descent:k.descent,height:k.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function nc(t){return(nc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ic(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function rc(t,e){return(rc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function oc(t){return(oc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ac=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rc(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=oc(e);return function(t,e){if(e&&("object"===nc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=oc(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n,i=t._dup(),r=(s=this.options).scaleModifier,o=s.fullContentBounds,a=(a=1,(function(t){if(Array.isArray(t))return t}(n=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(n,a)||function(t,e){if(t){if("string"==typeof t)return ic(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ic(t,e):void 0}}(n,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),s=(t=new $s,new $s);null!=a&&(a.calcSize(i._dup(),e*r),t.copyFrom(a.getBounds(o)),s.copyFrom(a.getBounds(!0))),this.width=t.width,this.height=t.height,this.descent=t.descent,this.ascent=t.ascent,this.fullSize={leftOffset:this.location.x-s.left,width:s.width,ascent:s.ascent,descent:s.descent,height:s.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function sc(t){return(sc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function lc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function uc(t,e){return(uc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function cc(t){return(cc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var hc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&uc(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=cc(e);return function(t,e){if(e&&("object"===sc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=cc(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),i=(p=this.options).width,r=p.descent,o=p.ascent,a=p.xAlign,s=p.yAlign,l=p.fit,u=p.scaleModifier,c=p.inSize,h=p.fullContentBounds,f=(d=1,(function(t){if(Array.isArray(t))return t}(f=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(f,d)||function(t,e){if(t){if("string"==typeof t)return lc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?lc(t,e):void 0}}(f,d)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),d=new $s,p=(t=new $s,new $s);null!=f&&(f.calcSize(n._dup(),e*u),d.copyFrom(f.getBounds(h)),t.copyFrom(d)),null!=i&&(t.width=i,t.right=t.left+i),null!=r&&(t.descent=r),null!=o&&(t.ascent=o),t.height=t.descent+t.ascent,null!=f&&("width"===l?f.calcSize(n._dup(),t.width/d.width):"height"===l?f.calcSize(n._dup(),t.height/d.height):"contain"===l&&(m=Math.min(t.width/d.width,t.height/d.height),f.calcSize(n._dup(),m)),d.copyFrom(f));var m=n._dup();"center"===a?m.x=n.x+t.width/2-d.width/2:"right"===a?m.x=n.x+t.width-d.width:"number"==typeof a&&(m.x=n.x+t.width*a),"bottom"===s?m.y=n.y-t.descent+d.descent:"middle"===s?m.y=n.y-t.descent+t.height/2-d.height/2+d.descent:"top"===s?m.y=n.y+t.ascent-d.height+d.descent:"number"==typeof s&&(m.y=n.y-t.descent+t.height*s+d.descent),null!=f&&f.offsetLocation(m.sub(f.location)),null!=f?(p.copyFrom(f.getBounds(!0)),p.growWithSameBaseline(t)):p.copyFrom(t),c?(this.width=t.width,this.height=t.height,this.descent=t.descent,this.ascent=t.ascent):(this.width=0,this.height=0,this.descent=0,this.ascent=0),this.fullSize={leftOffset:this.location.x-p.left,width:p.width,ascent:p.ascent,descent:p.descent,height:p.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function fc(t){return(fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function dc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function pc(t,e){return(pc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function mc(t){return(mc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var yc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&pc(t,e)}(r,Wu);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=mc(e);return function(t,e){if(e&&("object"===fc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=mc(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),i.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),i=(s=this.options).offset,r=s.fullContentBounds,o=(a=1,(function(t){if(Array.isArray(t))return t}(o=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(o,a)||function(t,e){if(t){if("string"==typeof t)return dc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dc(t,e):void 0}}(o,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),a=new $s,s=new $s;null!=o&&(o.calcSize(n._dup(),e),a.copyFrom(o.getBounds(r))),null!=o&&(o.offsetLocation(i),s.copyFrom(o.getBounds(!0))),this.width=0,this.height=0,this.descent=0,this.ascent=0,this.fullSize={leftOffset:t.x-s.left,width:s.width,ascent:s.ascent,descent:s.descent,height:s.height}}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function vc(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||bc(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gc(t){return function(t){if(Array.isArray(t))return wc(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||bc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bc(t,e){if(t){if("string"==typeof t)return wc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wc(t,e):void 0}}function wc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function xc(t,e){return"string"!=typeof e?e:t instanceof rs?t&&"_".concat(e)in t?t["_".concat(e)]:null:t&&e in t?t[e]:null}var Sc=function(){function t(e,n,i){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.elements=e,this.phrases={},this.fullLineHeight=null,this.addElementFromKey=n,this.getExistingOrAddSymbol=i,this.phraseElements={}}var e=[{key:"stringToElement",value:function(t){if(0===t.length)return null;if(t.startsWith("space")){var e=parseFloat(t.replace(/space[_]*/,""))||.03;return new il(new nl(e))}if(t.startsWith(" ")){var n=.03*t.length;return new il(new nl(n))}return(n=xc(this.elements,t))?new il(n):t in this.phrases?this.parseContent(this.phrases[t]):null!=(t=this.addElementFromKey(t,{}))?new il(t):null}},{key:"parseContent",value:function(t){var e,n=this;if(null==t)return null;if("number"==typeof t)return null;if(t instanceof rl)return t;if(t instanceof bl)return t;if("string"==typeof t)return null==(o=this.stringToElement(t))||null!=this.phraseElements[t]||(null!=o.getAllElements?this.phraseElements[t]=o.getAllElements():(e=[],o.forEach((function(t){null!=t.getAllElements?e.push.apply(e,gc(t.getAllElements())):e.push(t)})),this.phraseElements[t]=e)),o;if(Array.isArray(t)){var i=[];return t.forEach((function(t){t=n.parseContent(t),Array.isArray(t)?i=[].concat(gc(i),gc(t)):i.push(t)})),i}var r=vc(Object.entries(t)[0],2),o=r[0];return t=r[1],null!=(r=this.eqnMethod(o,t))?r:(t=this.addElementFromKey(o,t),new il(t))}},{key:"contentToElement",value:function(t){return t instanceof rl?t._dup():t instanceof rs||t instanceof is?new rl([new il(t)]):(t=this.parseContent(t),Array.isArray(t)||(t=[t]),new rl(t))}},{key:"eqnMethod",value:function(t,e){return"frac"===t?this.frac(e):"strike"===t?this.strike(e):"box"===t?this.box(e):"tBox"===t?this.touchBox(e):"root"===t?this.root(e):"brac"===t?this.brac(e):"sub"===t?this.sub(e):"sup"===t?this.sup(e):"supSub"===t?this.supSub(e):"topBar"===t?this.topBar(e):"bottomBar"===t?this.bottomBar(e):"annotate"===t?this.annotate(e):"bottomComment"===t?this.bottomComment(e):"topComment"===t?this.topComment(e):"bar"===t?this.bar(e):"topStrike"===t?this.topStrike(e):"bottomStrike"===t?this.bottomStrike(e):"pad"===t?this.pad(e):"int"===t?this.int(e):"sumOf"===t||"prodOf"===t?this.sumProd(e):"matrix"===t?this.matrix(e):"lines"===t?this.lines(e):"scale"===t?this.scale(e):"container"===t?this.container(e):"offset"===t?this.offset(e):null}},{key:"container",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h,f=Array.isArray(t)?(n=(e=vc(t,11))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],e[10]):(n=t.content,i=t.width,r=t.inSize,o=t.descent,a=t.ascent,s=t.xAlign,l=t.yAlign,u=t.fit,c=t.scale,h=t.fullContentBounds,t.showContent),d=ct({scaleModifier:1,fit:null,width:null,ascent:null,descent:null,xAlign:"center",yAlign:"baseline",inSize:!0,fullContentBounds:!1,showContent:!0},{scaleModifier:c,fit:u,width:i,ascent:a,descent:o,xAlign:s,yAlign:l,inSize:r,fullContentBounds:h});return new hc([this.contentToElement(n)],[],d,null==f||f)}catch(t){throw new Error("FigureOne Equation Container Error: ".concat(t.message))}}},{key:"offset",value:function(t){try{var e,n,i,r=Array.isArray(t)?(i=(n=vc(t,3))[0],e=n[1],n[2]):(i=t.content,e=t.offset,t.fullContentBounds),o=ct({offset:[0,0],fullContentBounds:!1},{offset:ue(e||[0,0]),fullContentBounds:r});return new yc([this.contentToElement(i)],[],o)}catch(t){throw new Error("FigureOne Equation Offset Error: ".concat(t.message))}}},{key:"brac",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m=Array.isArray(t)?(n=(e=vc(t,14))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],f=e[10],d=e[11],p=e[12],e[13]):(n=t.left,i=t.content,r=t.right,o=t.inSize,a=t.insideSpace,s=t.outsideSpace,l=t.topSpace,u=t.bottomSpace,c=t.minContentHeight,h=t.minContentDescent,f=t.height,d=t.descent,p=t.fullContentBounds,t.useFullBounds),y=ct({},{insideSpace:.03,outsideSpace:.03,topSpace:.05,bottomSpace:.05,minContentHeight:null,minContentDescent:null,descent:null,height:null,inSize:!0,useFullBounds:!1,fullContentBounds:!1},{insideSpace:a,outsideSpace:s,topSpace:l,bottomSpace:u,minContentHeight:c,minContentDescent:h,descent:d,height:f,inSize:o,useFullBounds:m,fullContentBounds:p}),v={};return n&&(v.left={symbol:n,space:y.insideSpace,topSpace:y.topSpace,bottomSpace:y.bottomSpace,minContentHeight:y.minContentHeight,minContentDescent:y.minContentDescent,descent:y.descent,height:y.height}),r&&(v.right={symbol:r,space:y.insideSpace,topSpace:y.topSpace,bottomSpace:y.bottomSpace,minContentHeight:y.minContentHeight,minContentDescent:y.minContentDescent,descent:y.descent,height:y.height}),this.annotate({content:i,glyphs:v,inSize:y.inSize,leftSpace:y.outsideSpace,rightSpace:y.outsideSpace,useFullBounds:y.useFullBounds,fullContentBounds:y.fullContentBounds})}catch(t){throw new Error("FigureOne Equation Brackert Error: ".concat(t.message))}}},{key:"bar",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};try{var n,i,r,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b=Array.isArray(t)?(i=(n=vc(t,17))[0],r=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],f=n[9],d=n[10],p=n[11],m=n[12],y=n[13],v=n[14],g=n[15],n[16]):(i=t.content,r=t.symbol,o=t.inSize,a=t.space,s=t.overhang,l=t.length,u=t.left,c=t.right,h=t.top,f=t.bottom,d=t.side,p=t.minContentHeight,m=t.minContentDescent,y=t.minContentAscent,v=t.descent,g=t.fullContentBounds,t.useFullBounds),w=ct({},{inSize:!0,space:.03,overhang:0,length:null,left:null,right:null,top:null,bottom:null,side:"top",minContentHeight:null,minContentDescent:null,minContentAscent:null,descent:null,fullContentBounds:!1,useFullBounds:!1},{side:d,space:a,overhang:s,length:l,left:u,right:c,top:h,bottom:f,inSize:o,minContentHeight:p,minContentDescent:m,minContentAscent:y,descent:v,fullContentBounds:g,useFullBounds:b},e),x={};return"top"===w.side&&(x.top={symbol:r,space:w.space,overhang:w.overhang,leftSpace:w.left,rightSpace:w.right,width:w.length}),"bottom"===w.side&&(x.bottom={symbol:r,space:w.space,overhang:w.overhang,leftSpace:w.left,rightSpace:w.right,width:w.length}),"left"===w.side&&(x.left={symbol:r,space:w.space,overhang:w.overhang,topSpace:w.top,bottomSpace:w.bottom,height:w.length,minContentHeight:w.minContentHeight,minContentDescent:w.minContentDescent,minContentAscent:w.minContentAscent,descent:w.descent}),"right"===w.side&&(x.right={symbol:r,space:w.space,overhang:w.overhang,topSpace:w.top,bottomSpace:w.bottom,height:w.length,minContentHeight:w.minContentHeight,minContentDescent:w.minContentDescent,minContentAscent:w.minContentAscent,descent:w.descent}),this.annotate({content:i,glyphs:x,inSize:w.inSize,fullContentBounds:w.fullContentBounds,useFullBounds:w.useFullBounds})}catch(t){throw new Error("FigureOne Equation Bar Error: ".concat(t.message))}}},{key:"annotate",value:function(t){var e=this,n={inSize:!0,useFullBounds:!1,fullContentBounds:!1,space:0,contentScale:1,encompass:{space:0},left:{space:0,overhang:0,yOffset:0,annotationsOverContent:!1},right:{space:0,overhang:0,yOffset:0,annotationsOverContent:!1},top:{space:0,overhang:0,xOffset:0,annotationsOverContent:!1},bottom:{space:0,overhang:0,xOffset:0,annotationsOverContent:!1},line:{content:{xAlign:"left",yAlign:"bottom",space:0},annotation:{xAlign:"left",yAlign:"bottom",space:0},annotationIndex:0}},i=t.content,r=t.annotation,o=t.annotations,a=t.glyphs,s={xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:new pe(0,0),scale:1,inSize:!0,fullContentBounds:!1},l=[];null!=r?l.push(r):null!=o&&(l=o);var u=function(t){if(null==t||!Array.isArray(t))return[];var n=[];return t.forEach((function(t){n.push(function(t){var n=ct({},s,t);return n.offset=ue(n.offset),n.content=e.contentToElement(t.content),n}(t))})),n},c=(o=u(l),{});return(l=function(t){if(null!=a){var i=a[t];if(null!=i){c[t]={};var r=i.annotations;if(null!=i.annotation&&(r=[i.annotation]),r=u(r),c[t]=ct({},n[t],i),c[t].annotations=r,c[t].glyph=e.getExistingOrAddSymbol(i.symbol||""),null==c[t].glyph)throw new Error("Equation glyph identifier '".concat(JSON.stringify(i.symbol||""),"' is not a glyph, or does not exist"))}}})("encompass"),l("left"),l("right"),l("top"),l("bottom"),l("line"),t=ct(n,t),new bl(this.contentToElement(i),o,c,t)}},{key:"scale",value:function(t){try{var e,n,i,r=Array.isArray(t)?(i=(n=vc(t,3))[0],e=n[1],n[2]):(i=t.content,e=t.scale,t.fullContentBounds),o=ct({scaleModifier:1,fullContentBounds:!1},{scaleModifier:e,fullContentBounds:r});return new ac([this.contentToElement(i)],[],o)}catch(t){throw new Error("FigureOne Equation Scale Error: ".concat(t.message))}}},{key:"frac",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h=Array.isArray(t)?(n=(e=vc(t,10))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.numerator,i=t.symbol,r=t.denominator,o=t.scale,a=t.numeratorSpace,s=t.denominatorSpace,l=t.overhang,u=t.offsetY,c=t.baseline,t.fullContentBounds),f=ct({scaleModifier:1,numeratorSpace:.05,denominatorSpace:.05,offsetY:.07,overhang:.05,fullContentBounds:!1,baseline:"vinculum"},{scaleModifier:o,overhang:l,numeratorSpace:a,denominatorSpace:s,offsetY:u,fullContentBounds:h,baseline:c});return new Uu([this.contentToElement(n),this.contentToElement(r)],this.getExistingOrAddSymbol(i),f)}catch(t){throw new Error("FigureOne Equation Fraction Error: ".concat(t.message))}}},{key:"root",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h,f,d=!0,p=Array.isArray(t)?(a=(o=vc(t,13))[0],s=o[1],d=o[2],l=o[3],u=o[4],c=o[5],h=o[6],f=o[7],e=o[8],i=o[9],n=o[10],r=o[11],o[12]):(a=t.symbol,s=t.content,d=t.inSize,l=t.space,u=t.topSpace,c=t.rightSpace,h=t.bottomSpace,f=t.leftSpace,e=t.root,i=t.rootOffset,n=t.rootScale,r=t.fullContentBounds,t.useFullBounds),m=ct({space:.02,rootScale:.6,rootOffset:[0,.06],inSize:!0,fullContentBounds:!1,useFullBounds:!1},{leftSpace:f,topSpace:u,bottomSpace:h,rightSpace:c,space:l,rootScale:n,rootOffset:i,inSize:d,fullContentBounds:r,useFullBounds:p});m.rootOffset=ue(m.rootOffset);var y=[];return null!=e&&y.push({content:e,offset:m.rootOffset,scale:m.rootScale,reference:"root"}),this.annotate({content:s,inSize:m.inSize,useFullBounds:m.useFullBounds,fullContentBounds:m.fullContentBounds,glyphs:{encompass:{symbol:a,annotations:y,space:m.space,leftSpace:m.leftSpace,rightSpace:m.rightSpace,topSpace:m.topSpace,bottomSpace:m.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation Root Error: ".concat(t.message))}}},{key:"supSub",value:function(t){var e,n,i=null,r=null,o=null,a=null,s=null;return t=Array.isArray(t)?(n=(e=vc(t,7))[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],e[6]):(n=t.content,i=t.superscript,r=t.subscript,o=t.scale,s=t.superscriptOffset,a=t.subscriptOffset,t.inSize),s=ct({scale:.5,subscriptOffset:[0,0],superscriptOffset:[0,0],inSize:!0},{superscript:i,subscript:r,scale:o,subscriptOffset:a,superscriptOffset:s,inSize:t}),t=[],null!=i&&t.push({content:s.superscript,xPosition:"right",yPosition:"0.7a",xAlign:"left",yAlign:"baseline",offset:ue(s.superscriptOffset).add(new pe(.04*s.scale,0)),scale:s.scale}),null!=r&&t.push({content:s.subscript,xPosition:"right",yPosition:"baseline",xAlign:"left",yAlign:"0.7a",offset:s.subscriptOffset,scale:s.scale}),this.annotate({content:n,annotations:t,inSize:s.inSize})}},{key:"sup",value:function(t){try{var e,n,i,r,o,a=Array.isArray(t)?(n=(e=vc(t,5))[0],i=e[1],r=e[2],o=e[3],e[4]):(n=t.content,i=t.superscript,r=t.scale,o=t.offset,t.inSize);return this.supSub({content:n,superscript:i,superscriptOffset:o,inSize:a,scale:r})}catch(t){throw new Error("FigureOne Equation Superscript Error: ".concat(t.message))}}},{key:"sub",value:function(t){try{var e,n,i,r,o,a=Array.isArray(t)?(n=(e=vc(t,5))[0],i=e[1],r=e[2],o=e[3],e[4]):(n=t.content,i=t.subscript,r=t.scale,o=t.offset,t.inSize);return this.supSub({content:n,subscript:i,subscriptOffset:o,inSize:a,scale:r})}catch(t){throw new Error("FigureOne Equation Subscript Error: ".concat(t.message))}}},{key:"touchBox",value:function(t){try{var e,n,i,r,o,a,s,l=Array.isArray(t)?(n=(e=vc(t,7))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],e[6]):(n=t.content,i=t.symbol,r=t.space,o=t.topSpace,a=t.rightSpace,s=t.bottomSpace,t.leftSpace),u=ct({inSize:!1,space:0,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null},{content:n,symbol:i,space:r,topSpace:o,rightSpace:a,bottomSpace:s,leftSpace:l});return this.annotate({content:n,inSize:!1,fullContentBounds:!1,useFullBounds:!1,glyphs:{encompass:{symbol:i,space:u.space,leftSpace:u.leftSpace,rightSpace:u.rightSpace,topSpace:u.topSpace,bottomSpace:u.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation TouchBox Error: ".concat(t.message))}}},{key:"box",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h=Array.isArray(t)?(n=(e=vc(t,10))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.content,i=t.symbol,r=t.inSize,o=t.space,a=t.topSpace,s=t.rightSpace,l=t.bottomSpace,u=t.leftSpace,c=t.fullContentBounds,t.useFullBounds),f=ct({inSize:!1,space:0,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null,fullContentBounds:!1,useFullBounds:!1},{content:n,symbol:i,inSize:r,space:o,topSpace:a,rightSpace:s,bottomSpace:l,leftSpace:u,fullContentBounds:c,useFullBounds:h});return this.annotate({content:n,inSize:f.inSize,fullContentBounds:f.fullContentBounds,useFullBounds:f.useFullBounds,glyphs:{encompass:{symbol:i,space:f.space,leftSpace:f.leftSpace,rightSpace:f.rightSpace,topSpace:f.topSpace,bottomSpace:f.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation Box Error: ".concat(t.message))}}},{key:"pad",value:function(t){try{var e,n,i,r,o,a=Array.isArray(t)?(n=(e=vc(t,5))[0],i=e[1],r=e[2],o=e[3],e[4]):(n=t.content,i=t.top,r=t.right,o=t.bottom,t.left),s=ct({top:0,left:0,right:0,bottom:0},{top:i,right:r,bottom:o,left:a});return this.annotate({content:n,topSpace:s.top,bottomSpace:s.bottom,rightSpace:s.right,leftSpace:s.left})}catch(t){throw new Error("FigureOne Equation Pad Error: ".concat(t.message))}}},{key:"topBar",value:function(t){try{return this.bar(t,{side:"top"})}catch(t){throw new Error("FigureOne Equation TopBar Error: ".concat(t.message))}}},{key:"bottomBar",value:function(t){try{return this.bar(t,{side:"bottom"})}catch(t){throw new Error("FigureOne Equation BottomBar Error: ".concat(t.message))}}},{key:"matrix",value:function(t){var e=this;try{var n,i,r,o,a,s,l,u,c,h,f=Array.isArray(t)?(i=(n=vc(t,10))[0],r=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],n[9]):(i=t.order,r=t.left,o=t.content,a=t.right,s=t.scale,l=t.fit,u=t.space,c=t.yAlign,h=t.brac,t.fullContentBounds),d=ct({},{contentScale:.7,fit:"min",space:[.05,.05],yAlign:"baseline",brac:{},fullContentBounds:!1},{space:u,fit:l,order:i,contentScale:s,brac:h,yAlign:c,fullContentBounds:f}),p=[];null!=o&&(p=o.map((function(t){return e.contentToElement(t)}))),null!=d.order&&d.order[0]*d.order[1]===p.length||(d.order=[1,p.length]),null!=d.space&&(d.space=ue(d.space));var m=new Qu(p,[],d);return null!=r&&null!=a?this.brac(ct({},d.brac,{content:m,left:r,right:a})):m}catch(t){throw new Error("FigureOne Equation Bar Error: ".concat(t.message))}}},{key:"lines",value:function(t){var e=this;try{var n,i,r,o,a,s,l=Array.isArray(t)?(i=(n=vc(t,6))[0],r=n[1],o=n[2],a=n[3],s=n[4],n[5]):(i=t.content,r=t.justify,o=t.baselineSpace,a=t.space,s=t.yAlign,t.fullContentBounds),u=ct({},{justify:"center",yAlign:0,baselineSpace:null,space:0,fullContentBounds:!1},{justify:r,baselineSpace:o,space:a,yAlign:s,fullContentBounds:l}),c=[],h=[];return null!=i&&(i.forEach((function(t){var n=u.baselineSpace,i=u.space,r=null;Array.isArray(t)||null==t.content?c.push(e.contentToElement(t)):(c.push(e.contentToElement(t.content)),null!=t.baselineSpace&&(n=t.baselineSpace),null!=t.space&&(i=t.space),null!=t.justify&&(r=e.elements[t.justify])),h.push({baselineSpace:n,space:i,justify:r,offset:t.offset||0})})),u.lineOptions=h),new ec(c,[],u)}catch(t){throw new Error("FigureOne Equation Lines Error: ".concat(t.message))}}},{key:"int",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x,S,T,A,k,O,_,P={inSize:!0,space:.01,topSpace:.1,bottomSpace:.1,height:null,yOffset:0,contentScale:1,fromScale:.5,toScale:.5,fromOffset:[0,0],toOffset:[.04,0],limitsPosition:"side",limitsAroundContent:!0,fromXPosition:.5,fromYPosition:"bottom",fromXAlign:"left",fromYAlign:"middle",toXPosition:"right",toYPosition:"top",toXAlign:"left",toYAlign:"middle",fullBoundsContent:!1,useFullBounds:!1},E=Array.isArray(t)?(n=(e=vc(t,27))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],y=e[14],v=e[15],g=e[16],b=e[17],w=e[18],x=e[19],S=e[20],T=e[21],A=e[22],k=e[23],O=e[24],_=e[25],e[26]):(i=t.content,n=t.symbol,r=t.from,o=t.to,a=t.inSize,s=t.space,l=t.topSpace,u=t.bottomSpace,c=t.height,h=t.yOffset,f=t.scale,d=t.fromScale,p=t.toScale,m=t.fromOffset,y=t.toOffset,v=t.limitsPosition,g=t.limitsAroundContent,b=t.fromXPosition,w=t.fromYPosition,x=t.fromXAlign,S=t.fromYAlign,T=t.toXPosition,A=t.toYPosition,k=t.toXAlign,O=t.toYAlign,_=t.fullBoundsContent,t.useFullBounds);"topBottom"===v&&(P.fromXPosition=.1,P.fromYPosition="bottom",P.fromXAlign="center",P.fromYAlign="top",P.toXPosition=.9,P.toYPosition="top",P.toXAlign="center",P.toYAlign="bottom",P.fromOffset=[0,-.04],P.toOffset=[0,.04]),"topBottomCenter"===v&&(P.fromXPosition="center",P.fromYPosition="bottom",P.fromXAlign="center",P.fromYAlign="top",P.toXPosition="center",P.toYPosition="top",P.toXAlign="center",P.toYAlign="bottom",P.fromOffset=[0,-.04],P.toOffset=[0,.04]);var M=ct({},P,{space:s,topSpace:l,bottomSpace:u,height:c,yOffset:h,inSize:a,contentScale:f,fromScale:d,toScale:p,fromOffset:m,toOffset:y,limitsPosition:v,limitsAroundContent:g,fromXPosition:b,fromYPosition:w,fromXAlign:x,fromYAlign:S,toXPosition:T,toYPosition:A,toXAlign:k,toYAlign:O,fullBoundsContent:_,useFullBounds:E});M.fromOffset=ue(M.fromOffset),M.toOffset=ue(M.toOffset);var B=[{content:o,xPosition:M.toXPosition,yPosition:M.toYPosition,xAlign:M.toXAlign,yAlign:M.toYAlign,offset:M.toOffset,scale:M.toScale},{content:r,xPosition:M.fromXPosition,yPosition:M.fromYPosition,xAlign:M.fromXAlign,yAlign:M.fromYAlign,offset:M.fromOffset,scale:M.fromScale}];return this.annotate({content:i,inSize:M.inSize,contentScale:M.contentScale,fullBoundsContent:M.fullBoundsContent,useFullBounds:M.useFullBounds,glyphs:{left:{symbol:n,space:M.space,topSpace:M.topSpace,bottomSpace:M.bottomSpace,height:M.height,yOffset:M.yOffset,annotationsOverContent:M.limitsAroundContent,annotations:B}}})}catch(t){throw new Error("FigureOne Equation Integral Error: ".concat(t.message))}}},{key:"sumOf",value:function(t){try{return this.sumProd(t)}catch(t){throw new Error("FigureOne Equation SumOf Error: ".concat(t.message))}}},{key:"prodOf",value:function(t){try{return this.sumProd(t)}catch(t){throw new Error("FigureOne Equation ProductOf Error: ".concat(t.message))}}},{key:"sumProd",value:function(t){var e,n,i,r,o,a,s,l,u,c,h,f,d,p,m,y,v,g;t=Array.isArray(t)?(n=(e=vc(t,19))[0],i=e[1],b=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],f=e[11],d=e[12],p=e[13],m=e[14],y=e[15],v=e[16],g=e[17],e[18]):(n=t.symbol,i=t.content,b=t.from,r=t.to,o=t.inSize,a=t.space,s=t.topSpace,l=t.bottomSpace,u=t.height,c=t.yOffset,h=t.scale,f=t.fromScale,d=t.toScale,p=t.fromSpace,m=t.toSpace,y=t.fromOffset,v=t.toOffset,g=t.fullBoundsContent,t.useFullBounds);var b=[{content:r,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:ue((t=ct({},{inSize:!0,space:.1,topSpace:.07,bottomSpace:.07,height:null,yOffset:0,contentScale:1,fromScale:.5,toScale:.5,fromSpace:.04,toSpace:.04,fromOffset:[0,0],toOffset:[0,0],fullBoundsContent:!1,useFullBounds:!1},{space:a,topSpace:s,bottomSpace:l,height:u,yOffset:c,inSize:o,contentScale:h,fromScale:f,toScale:d,fromSpace:p,toSpace:m,fromOffset:y,toOffset:v,fullBoundsContent:g,useFullBounds:t})).toOffset).add(0,t.toSpace),scale:t.toScale},{content:b,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",offset:ue(t.fromOffset).add(0,-t.fromSpace),scale:t.fromScale}];return this.annotate({content:i,contentScale:t.contentScale,fullBoundsContent:t.fullBoundsContent,useFullBounds:t.useFullBounds,glyphs:{left:{symbol:n,annotations:b,space:t.space,topSpace:t.topSpace,bottomSpace:t.bottomSpace,yOffset:t.yOffset,height:t.height}},inSize:t.inSize})}},{key:"processComment",value:function(t){var e,n,i,r,o,a,s,l,u,c;t=Array.isArray(t)?(n=(e=vc(t,11))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],h=e[8],c=e[9],e[10]):(n=t.content,i=t.comment,r=t.symbol,o=t.contentSpace,a=t.commentSpace,s=t.scale,l=t.inSize,u=t.contentLineSpace,h=t.commentLineSpace,c=t.fullContentBounds,t.useFullBounds);var h=ct({contentSpace:.03,commentSpace:.03,scale:.6,inSize:!0,fullContentBounds:!1,useFullBounds:!1,contentLineSpace:.03,commentLineSpace:.03},{contentSpace:o,commentSpace:a,scale:s,inSize:l,useFullBounds:t,fullContentBounds:c,contentLineSpace:u,commentLineSpace:h});return[n,i,r,h.contentSpace,h.commentSpace,h.scale,h.inSize,h.contentLineSpace,h.commentLineSpace,h.fullContentBounds,h.useFullBounds]}},{key:"topComment",value:function(){try{var t=vc(this.processComment.apply(this,arguments),11),e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],f=[{content:n,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",scale:a,offset:[0,o]}];return""===i||null==i?this.annotate({content:e,annotations:f,inSize:s}):this.getExistingOrAddSymbol(i)instanceof Cu?(f[0].offset=[0,o+r],this.annotate({content:e,fullContentBounds:c,useFullBounds:h,annotations:f,glyphs:{line:{symbol:i,content:{xAlign:"center",yAlign:"top",space:l},annotation:{xAlign:"center",yAlign:"bottom",space:u},annotationIndex:0}},inSize:s})):this.annotate({content:e,fullContentBounds:c,useFullBounds:h,glyphs:{top:{symbol:i,annotations:f,space:r}},inSize:s})}catch(t){throw new Error("FigureOne Equation TopComment Error: ".concat(t.message))}}},{key:"bottomComment",value:function(){try{var t=vc(this.processComment.apply(this,arguments),11),e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],f=[{content:n,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",scale:a,offset:[0,-o]}];return""===i||null==i?this.annotate({content:e,annotations:f,inSize:s}):this.getExistingOrAddSymbol(i)instanceof Cu?(f[0].offset=[0,-o-r],this.annotate({content:e,fullContentBounds:c,useFullBounds:h,annotations:f,glyphs:{line:{symbol:i,content:{xAlign:"center",yAlign:"bottom",space:l},annotation:{xAlign:"center",yAlign:"top",space:u},annotationIndex:0}},inSize:s})):this.annotate({content:e,fullContentBounds:c,useFullBounds:h,glyphs:{bottom:{symbol:i,annotations:f,space:r}},inSize:s})}catch(t){throw new Error("FigureOne Equation BottomComment Error: ".concat(t.message))}}},{key:"strike",value:function(t){try{var e,n,i,r,o,a,s,l,u,c,h={inSize:!1,space:.02,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null,fullContentBounds:!1,useFullBounds:!1},f=Array.isArray(t)?(n=(e=vc(t,10))[0],i=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.content,i=t.symbol,r=t.inSize,o=t.space,a=t.topSpace,s=t.rightSpace,l=t.bottomSpace,u=t.leftSpace,c=t.fullContentBounds,t.useFullBounds),d=this.getExistingOrAddSymbol(i);null!=d&&"horizontal"===d._custom.options.style&&(h.space=0,h.leftSpace=.02,h.rightSpace=.02);var p=ct(h,{content:n,symbol:i,inSize:r,space:o,topSpace:a,rightSpace:s,bottomSpace:l,leftSpace:u,fullContentBounds:c,useFullBounds:f});return this.annotate({content:n,inSize:p.inSize,fullContentBounds:p.fullContentBounds,useFullBounds:p.useFullBounds,glyphs:{encompass:{symbol:i,topSpace:p.topSpace,bottomSpace:p.bottomSpace,leftSpace:p.leftSpace,rightSpace:p.rightSpace,space:p.space}}})}catch(t){throw new Error("FigureOne Equation Strike Error: ".concat(t.message))}}},{key:"processStrike",value:function(t){var e,n,i,r,o,a;t=Array.isArray(t)?(n=(e=vc(t,7))[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],e[6]):(n=t.content,r=t.comment,i=t.symbol,o=t.inSize,s=t.space,a=t.scale,t.commentSpace);var s=ct({space:0,scale:.5,commentSpace:.1,inSize:!0},{inSize:o,commentSpace:t,scale:a,space:s});return[n,i,r,s.inSize,s.commentSpace,s.scale,s.space]}},{key:"topStrike",value:function(){try{var t=vc(this.processStrike.apply(this,arguments),7),e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],l=[{content:i,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:[0,o],scale:a}];return this.annotate({content:e,inSize:r,glyphs:{encompass:{symbol:n,space:s,annotations:l}}})}catch(t){throw new Error("FigureOne Equation TopStrike Error: ".concat(t.message))}}},{key:"bottomStrike",value:function(){try{var t=vc(this.processStrike.apply(this,arguments),7),e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],l=[{content:i,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",offset:[0,-o],scale:a}];return this.annotate({content:e,inSize:r,glyphs:{encompass:{symbol:n,space:s,annotations:l}}})}catch(t){throw new Error("FigureOne Equation BottomStrike Error: ".concat(t.message))}}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function Tc(t){return(Tc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ac(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Oc(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function kc(t){return function(t){if(Array.isArray(t))return _c(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Oc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oc(t,e){if(t){if("string"==typeof t)return _c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_c(t,e):void 0}}function _c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Pc(t,e,n){return(Pc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Bc(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ec(t,e){return(Ec=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Mc(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Bc(t){return(Bc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Cc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ec(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Bc(e);return function(t,e){if(e&&("object"===Tc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Mc(t)}(this,n?(t=Bc(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var o={family:"Times New Roman",style:"normal",size:.2,weight:"200",color:a=null==(a=n.color)?t.defaultColor:a},a=ut({except:["font"]},{},{color:a,dimColor:a=null==(a=n.dimColor)?t.defaultDimColor.slice():a,position:new pe(0,0),scale:.7,formDefaults:{alignment:{fixTo:new pe(0,0),xAlign:"left",yAlign:"baseline"},elementMods:{},layout:"always"},elements:{},forms:{},formRestart:null,limits:t.limits,touchBorder:"rect",transform:new Ee("Equation").scale(1,1).rotate(0).translate(0,0),timeKeeper:t.timeKeeper},n);return n.font instanceof Ea?a.font=n.font:null!=n.font?a.font=new Ea(ct({},o,n.font)):a.font=new Ea(o),n.textFont instanceof Ea?a.textFont=n.textFont:null!=n.textFont?a.textFont=new Ea(ct({},o,{style:"italic"},n.textFont)):a.textFont=new Ea(ct({},o,{style:"italic"})),null!=a.transform&&(a.transform=Be(a.transform)),a.formDefaults.alignment.fixTo=le(a.formDefaults.alignment.fixTo,a.formDefaults.alignment.fixTo),null!=a.formRestart&&null!=a.formRestart.pulse&&(a.formRestart.pulse=ct({},{scale:1.1,duration:1},a.formRestart.pulse)),(e=i.call(this,a)).shapes=t,e.setColor(a.color),e.dimColor=a.dimColor,e.eqn={forms:{},currentForm:"",formSeries:{base:[]},currentFormSeries:[],currentFormSeriesName:"",scale:a.scale,formDefaults:{alignment:a.formDefaults.alignment,elementMods:a.formDefaults.elementMods,duration:a.formDefaults.duration,translation:a.formDefaults.translation,layout:a.formDefaults.layout},functions:new Sc(e.elements,e.addElementFromKey.bind(Mc(e)),e.getExistingOrAddSymbol.bind(Mc(e))),symbols:new ju(e.shapes,e.color),font:a.font,textFont:a.textFont,isAnimating:!1,descriptionElement:null,descriptionPosition:new pe(0,0),formRestart:a.formRestart},null!=a.elements&&e.addElements(a.elements),null!=a.phrases&&e.addPhrases(a.phrases),null!=a.forms&&e.addForms(a.forms),null!=a.initialForm&&(e.initialForm=a.initialForm),null!=a.formSeries?Array.isArray(a.formSeries)?(e.eqn.formSeries={base:a.formSeries},e.eqn.currentFormSeries=e.eqn.formSeries.base,e.eqn.currentFormSeriesName="base"):(e.eqn.formSeries=a.formSeries,null!=a.defaultFormSeries?e.setFormSeries(a.defaultFormSeries):e.setFormSeries(Object.keys(e.eqn.formSeries)[0])):(e.eqn.formSeries={base:Object.keys(e.eqn.forms).slice()},e.eqn.currentFormSeries=e.eqn.formSeries.base,e.eqn.currentFormSeriesName="base"),e.fnMap.add("_goToForm",(function(t,n){var i=e.getCurrentForm();return null!=i&&null==n.target&&(n.target=i.name),null!=n.start&&e.showForm(n.start),e.goToForm(ct({ifAnimating:{cancelGoTo:!1}},n,{form:n.target,callback:null})),e.getRemainingAnimationTime(["_Equation","_EquationColor"])})),e.fnMap.add("_showForm",(function(t,n){e.showForm(n.target)})),e.animations.goToForm=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},{element:Mc(e),duration:1}].concat(n));return null!=r.callback&&(r.done=r.callback),r.customProperties={target:r.target,index:r.index,animate:r.animate,delay:r.delay,dissolveOutTime:r.dissolveOutTime,duration:r.duration,blankTime:r.blankTime,dissolveInTime:r.dissolveInTime,prioritizeFormDuration:r.prioritizeFormDuration,fromWhere:r.fromWhere,ifAnimating:r.ifAnimating,callback:r.callback},null!=r.totalDuration&&(r.duration=r.totalDuration),r.callback="_goToForm",r.delay=0,r.setToEnd="_showForm",r.timeKeeper=e.timeKeeper,new lo(r)},e.animations.customSteps.push({step:e.animations.goToForm.bind(Mc(e)),name:"goToForm"}),e.fnMap.add("_nextForm",(function(t,n){return e.nextForm(ct({ifAnimating:{cancelGoTo:!1}},n,{callback:null})),e.getRemainingAnimationTime(["_Equation","_EquationColor"])})),e.animations.nextForm=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var r=ct.apply(void 0,[{},{element:Mc(e),duration:1}].concat(n));return null!=r.callback&&(r.done=r.callback),r.customProperties={animate:r.animate,delay:r.delay,dissolveOutTime:r.dissolveOutTime,duration:r.duration,blankTime:r.blankTime,dissolveInTime:r.dissolveInTime,prioritizeFormDuration:r.prioritizeFormDuration,fromWhere:r.fromWhere,ifAnimating:r.ifAnimating,callback:r.callback},null!=r.totalDuration&&(r.duration=r.totalDuration),r.callback="_nextForm",r.delay=0,r.setToEnd="_showForm",r.timeKeeper=e.timeKeeper,new lo(r)},e.animations.customSteps.push({step:e.animations.nextForm.bind(Mc(e)),name:"nextForm"}),e}return t=[{key:"stateSet",value:function(){var t=this;Pc(Bc(r.prototype),"stateSet",this).call(this),Object.keys(this.eqn.forms).forEach((function(e){"init"!==t.eqn.forms[e].layout&&(t.eqn.forms[e].positionsSet=!1)}))}},{key:"setFigure",value:function(t){Pc(Bc(r.prototype),"setFigure",this).call(this,t),null!=this.initialForm&&this.showForm(this.initialForm)}},{key:"_getStateProperties",value:function(t){return[].concat(kc(Pc(Bc(r.prototype),"_getStateProperties",this).call(this,t)),["eqn.currentForm","eqn.isAnimating","eqn.currentFormSeries","eqn.currentFormSeriesName"])}},{key:"_getStatePropertiesMin",value:function(){return[].concat(kc(Pc(Bc(r.prototype),"_getStatePropertiesMin",this).call(this)),["eqn.currentForm"])}},{key:"setFormSeries",value:function(t){null!=this.eqn.formSeries[t]&&(this.eqn.currentFormSeries=this.eqn.formSeries[t],this.eqn.currentFormSeriesName=t)}},{key:"getFormSeries",value:function(){return this.eqn.currentFormSeriesName}},{key:"layoutForms",value:function(t){var e,n=this;"none"!==t&&(e=function(t){var e=n.eqn.forms[t],i=(o=e.arranged).scale,r=o.xAlign,o=(t=o.yAlign,o.fixTo);e.arrange(i,r,t,o)},"current"!==t?(Object.keys(this.eqn.forms).forEach((function(t){e(t)})),this.showForm(this.eqn.currentForm)):e(this.eqn.currentForm))}},{key:"updateElementText",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"none";Object.keys(t).forEach((function(n){var i,r=e.getElement(n);null!=r&&(i=r.color.slice(),r.custom.updateText({text:t[n]}),r.setColor(i,!1))})),this.layoutForms(n)}},{key:"makeTextElem",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";null!=t.text&&(e=t.text);var n=this.eqn.textFont.definition(),i=n;return i=null!=t.font&&t.font instanceof Ea?t.font.definition():ct({},n,{style:t.style,weight:t.weight,family:t.family,size:t.size,color:t.color,width:t.width},t.font),null==t.style&&(null!=t.font&&null==t.font.style||null==t.font)&&(e.match(/[A-Z,a-z,\u0370-\u03ff]/)?i.style=this.eqn.textFont.style:i.style="normal"),null==i.color&&(i.color=this.color),i=this.shapes.text({text:{text:e,touchBorder:0},position:new pe(0,0),font:i,xAlign:"left",yAlign:"baseline",touchBorder:"buffer",mods:{dimColor:this.dimColor.slice()}}),null!=t.touchBorder&&(i.touchBorder=t.touchBorder),null!=t.isTouchable&&(i.isTouchable=t.isTouchable),null!=t.onClick&&(i.onClick=t.onClick),null!=t.mods&&i.setProperties(t.mods),i}},{key:"getTextFromKey",value:function(t){return t.replace(/^_*/,"").replace(/_.*/,"")}},{key:"getExistingOrAddSymbol",value:function(t){if("string"==typeof t)return this.getExistingOrAddSymbolFromKey(t,{});t=(e=Ac(Object.entries(t)[0],2))[0];var e=e[1];return this.getExistingOrAddSymbolFromKey(t,e)}},{key:"getExistingOrAddSymbolFromKey",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=this.getElement(t);if(null!=n)return n;if(null!=e.symbol&&"string"==typeof e.symbol){var i=this.makeSymbolElem(e);if(null!=i)return this.add(t,i),i}return n=t.replace(/^_*/,""),null!=(i=this.eqn.symbols.get(n,e))?(.01<i.color[3]&&null==e.color&&i.setColor(this.color),null!=e.mods&&i.setProperties(e.mods),this.add(t,i),i):null!=(n=n.match(/_[^_]*$/))&&null!=(i=this.eqn.symbols.get(n[0].replace(/_/,""),e))?(.01<i.color[3]&&null==e.color&&i.setColor(this.color),null!=e.mods&&i.setProperties(e.mods),this.add(t.replace(/_[^_]*$/,""),i),i):null}},{key:"addElementFromKey",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(null!=(i=this.getExistingOrAddSymbolFromKey(t,e)))return i;var n=t.replace(/^_*/,"").replace(/_.*/,""),i=this.makeTextElem(ct({text:n},e));return this.add(t,i),i}},{key:"makeSymbolElem",value:function(t){var e=this.eqn.symbols.get(t.symbol,t);return null==e&&(e=this.makeTextElem({text:"Symbol ".concat(t.symbol," not valid")})),null==t.color&&.01<e.color[3]&&e.setColor(this.color),e.dimColor=this.dimColor.slice(),null!=t.mods&&e.setProperties(t.mods),e}},{key:"addElements",value:function(t){var e=this;Object.keys(t).forEach((function(n){var i,r=t[n];"string"==typeof r?n.startsWith("space")&&n.startsWith(" ")&&0<n.length||e.add(n,e.makeTextElem({text:r})):r instanceof is||r instanceof rs?e.add(n,r):null!=(i=null!=r.symbol&&"string"==typeof r.symbol?e.makeSymbolElem(r):e.makeTextElem(r,e.getTextFromKey(n)))&&(null!=r.mods&&i.setProperties(r.mods),e.add(n,i))}));var n=this.makeTextElem({text:"gh"}),i=this.createForm({elem:n});i.content=[this.eqn.functions.contentToElement(n)],i.arrange(this.eqn.scale,"left","baseline",new pe(0,0)),this.eqn.functions.fullLineHeight=i,this.setFirstTransform(this.transform)}},{key:"addDescriptionElement",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new pe(0,0);this.eqn.descriptionElement=t,this.eqn.descriptionPosition=e,this.eqn.descriptionElement&&this.eqn.descriptionElement.setPosition(this.getPosition("figure").add(e))}},{key:"setPosition",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;Pc(Bc(r.prototype),"setPosition",this).call(this,t,e),e=this.getPosition("figure"),null!=this.eqn.descriptionElement&&this.eqn.descriptionElement.setPosition(e.add(this.eqn.descriptionPosition))}},{key:"addPhrases",value:function(t){var e=this;Object.keys(t).forEach((function(n){var i=t[n];e.eqn.functions.phrases[n]=i}))}},{key:"addForms",value:function(t){function e(t){return"string"==typeof t}function n(t){return Array.isArray(t)}var i=this;Object.keys(t).forEach((function(r){var o,a=t[r];(e(a)||n(a)||!e(o=a)&&!n(o)&&null!=o&&"object"===Tc(o)&&1===(o=Object.keys(o)).length&&o[0]in i.eqn.functions||a instanceof rl||a instanceof bl?function(t,e){var n;try{n=[i.eqn.functions.contentToElement(e)]}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(i.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}try{i.addForm(t,n)}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(i.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}}:function(t,e){var n;try{n=[i.eqn.functions.contentToElement(e.content)]}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(i.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}var r=e.elementMods,o=e.duration,a=e.alignment,s=e.scale,l=e.description,u=e.modifiers,c=e.translation;c={elementMods:r,alignment:a,scale:s,description:l,modifiers:u,fromForm:e.fromForm,duration:o,translation:c,onShow:e.onShow,onTransition:e.onTransition};try{i.addForm(t,n,c)}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(i.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}})(r,a)})),null==this.initialForm&&0<Object.keys(this.eqn.forms).length&&(this.initialForm=Object.keys(this.eqn.forms)[0])}},{key:"checkFixTo",value:function(t){return"string"!=typeof t?t instanceof is||t instanceof rs||t instanceof pe?t:new pe(0,0):null!=(t=xc(this,t))?t:new pe(0,0)}},{key:"createForm",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.elements;return new Al(t,{getAllElements:this.getChildren.bind(this),hideAll:this.hideAll.bind(this),show:this.show.bind(this),showOnly:this.showOnly.bind(this),stop:this.stopEquationAnimating.bind(this),getElementTransforms:this.getElementTransforms.bind(this),setElementTransforms:this.setElementTransforms.bind(this),animateToTransforms:this.animateToTransforms.bind(this)})}},{key:"getFormElements",value:function(t){return null==this.eqn.forms[t]?[]:this.eqn.forms[t].content[0].getAllElements(1<arguments.length&&void 0!==arguments[1]&&arguments[1])}},{key:"getPhraseElements",value:function(t){var e=this;if("string"==typeof t)return null==this.eqn.functions.phraseElements[t]?[]:this.eqn.functions.phraseElements[t];var n={},i=[];return t.forEach((function(t){null!=e.eqn.functions.phraseElements[t]&&e.eqn.functions.phraseElements[t].forEach((function(t){null==n[t.name]&&(n[t.name]=!0,i.push(t))}))})),i}},{key:"getUnusedElements",value:function(){for(var t=this.getChildren().map((function(t){return t.name})),e=Object.keys(this.eqn.forms),n=0;n<e.length;n+=1)for(var i=e[n],r=this.getFormElements(i).map((function(t){return t.name})),o=0;o<r.length;o+=1){var a=r[o];if(-1<(a=t.indexOf(a))&&t.splice(a,1),0===t.length)return[]}return t}},{key:"stopEquationAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel";this.stopAnimating(t,"_Equation",!0),this.stopAnimating(t,"_EquationColor",!0),this.stopPulsing(t)}},{key:"addForm",value:function(t,e){var n=this,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=u=ct({},{elementMods:{},description:"",modifiers:{},scale:this.eqn.scale,duration:void 0,onStart:null,fromForm:{},onShow:null,onTransition:null,layout:this.eqn.formDefaults.layout},this.eqn.formDefaults),o=(c=r=i?ct({},u,i):r).description,a=c.modifiers,s=c.fromForm,l=c.onShow,u=c.onTransition,c=(i=c.duration,c.translation),h=this.createForm();function f(t){var e={};return Object.keys(t).forEach((function(i){var r=t[i],o=xc(n,i);null!=o&&(e[i]={element:o,mods:r})})),e}function d(t){var e={};return Object.keys(t).forEach((function(i){var r,o,a,s=xc(n,i),l=t[i];l=Array.isArray(l)?(o=(r=Ac(l,3))[0],a=r[1],r[2]):(o=l.style,a=l.direction,l.mag),null!=s&&(e[i]={element:s,style:o,direction:a,mag:l})})),e}(this.eqn.forms[t]=h).description=o,h.modifiers=a,h.name=t,h.duration=i,h.translation=c,h.fromForm=s,h.onShow=l,h.onTransition=u,h.elementMods={},h.elementMods=f(r.elementMods),null!=h.translation&&(h.translation=d(h.translation)),null!=h.fromForm&&Object.keys(h.fromForm).forEach((function(t){null!=(t=h.fromForm[t]).elementMods&&(t.elementMods=f(t.elementMods)),null!=t.translation&&(t.translation=d(t.translation))})),r.alignment.fixTo=this.checkFixTo(r.alignment.fixTo),h.content=e,h.layout=r.layout,"init"!==r.layout?h.lazyArrange(r.scale,r.alignment.xAlign,r.alignment.yAlign,r.alignment.fixTo):h.arrange(r.scale,r.alignment.xAlign,r.alignment.yAlign,r.alignment.fixTo),""===this.eqn.currentForm&&(this.eqn.currentForm=t)}},{key:"getCurrentForm",value:function(){return null==this.eqn.forms[this.eqn.currentForm]?null:this.eqn.forms[this.eqn.currentForm]}},{key:"render",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=this.getCurrentForm();null!=e&&(e.setPositions(),e.showHide(0,0,null,t),this.show(),e.applyElementMods())}},{key:"setCurrentForm",value:function(t){"string"==typeof t?(this.eqn.currentForm="",t in this.eqn.forms&&(this.eqn.currentForm=t)):this.eqn.currentForm=t.name}},{key:"showForm",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.eqn.currentForm,e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];Pc(Bc(r.prototype),"show",this).call(this);var n=t;(n="string"==typeof t?this.getForm(t):n)&&(this.setCurrentForm(n),this.render(e),this.fnMap.exec(n.onTransition),this.fnMap.exec(n.onShow))}},{key:"showAll",value:function(){this.showForm()}},{key:"getForm",value:function(t){return t instanceof Al?t:t in this.eqn.forms?this.eqn.forms[t]:null}},{key:"goToForm",value:function(){var t,e,n,i,o,a,s,l=this,u=ct({duration:null,prioritizeFormDuration:!0,delay:0,fromWhere:"_current",animate:"dissolve",callback:null,ifAnimating:{skipToTarget:!0,cancelGoTo:!0}},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{});this.eqn.isAnimating&&(u.ifAnimating.skipToTarget?(this.stopEquationAnimating("complete"),null!=(e=this.getCurrentForm())&&this.showForm(e)):this.stopEquationAnimating("cancel"),this.eqn.isAnimating=!1,u.ifAnimating.cancelGoTo)||(null!=u.form?t=this.eqn.forms[u.form]:null!=u.index?t=this.eqn.forms[this.eqn.currentFormSeries[u.index]]:0<this.eqn.currentFormSeries.length&&(i=0,(o=(i=null!=(a=this.getCurrentForm())&&(i=this.eqn.currentFormSeries.indexOf(a.name))<0?0:i)+1)===this.eqn.currentFormSeries.length&&(o=0),t=this.eqn.forms[this.eqn.currentFormSeries[o]]),null!=t&&("_current"===u.fromWhere&&(u.fromWhere=this.eqn.currentForm),e=u.duration,u.prioritizeFormDuration&&(void 0!==t.duration&&(e=t.duration),null!=u.fromWhere&&null!=t.fromForm[u.fromWhere]&&void 0!==t.fromForm[u.fromWhere].duration&&(e=t.fromForm[u.fromWhere].duration)),a=t.onTransition,null!=t.fromForm&&null!=t.fromForm[u.fromWhere]&&void 0!==t.fromForm[u.fromWhere].onTransition&&(a=t.fromForm[u.fromWhere].onTransition),null!=e&&0<e&&"dissolve"===u.animate?(null==u.dissolveOutTime&&(u.dissolveOutTime=.4*e),null==u.dissolveInTime&&(u.dissolveInTime=.4*e),null==u.blankTime&&(u.blankTime=.2*e)):(null==u.dissolveOutTime&&(u.dissolveOutTime=.4),null==u.dissolveInTime&&(u.dissolveInTime=.4),null==u.blankTime&&(u.blankTime=.2)),0===e?(this.showForm(t),this.fnMap.exec(u.callback)):(this.eqn.isAnimating=!0,this.fnMap.exec(a),n=function(){l.fnMap.exec(t.onShow),l.eqn.isAnimating=!1,l.fnMap.exec(u.callback)},"move"===u.animate?t.animatePositionsTo(u.delay,u.dissolveOutTime,e,u.dissolveInTime,n,u.fromWhere,!1):"dissolveInThenMove"===u.animate?t.animatePositionsTo(u.delay,u.dissolveOutTime,e,u.dissolveInTime,n,u.fromWhere,!0):"moveFrom"===u.animate&&null!=this.eqn.formRestart&&null!=this.eqn.formRestart.moveFrom?(i=this.eqn.formRestart.moveFrom,o=this.getPosition(),a=this.getPosition(),i instanceof r&&i.showForm(t.name),a=i instanceof rs?i.getPosition():ue(this.eqn.formRestart.moveFrom),this.fnMap.add("_equationShowFormCallback",(function(){l.showForm(t.name,!1)})),this.animations.new("_Equation").dissolveOut({duration:u.dissolveOutTime}).position({target:a,duration:0}).trigger({callback:"showFormCallback",duration:.01}).position({target:o,duration:e}).whenFinished(n).start()):"pulse"===u.animate&&null!=this.eqn.formRestart&&null!=this.eqn.formRestart.pulse?(s=this.eqn.formRestart.pulse,t.allHideShow(u.delay,u.dissolveOutTime,u.blankTime,u.dissolveInTime,(function(){l.pulse({duration:s.duration,scale:s.scale,frequency:0,done:n}),null!=s.element&&s.element instanceof r&&s.element.getCurrentForm().name===t.name&&s.element.pulse({duration:s.duration,scale:s.scale})}))):t.allHideShow(u.delay,u.dissolveOutTime,u.blankTime,u.dissolveInTime,n),this.setCurrentForm(t))))}},{key:"getFormIndex",value:function(){if(null==(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null))return-1;var t,e=this.getForm(t);return null!=e?this.eqn.currentFormSeries.indexOf(e.name):-1}},{key:"prevForm",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=this.getCurrentForm();null==i||-1<(t=this.getFormIndex(i))&&(--t<0&&(t=this.eqn.currentFormSeries.length-1),"number"==typeof e||null==e?this.goToForm({index:t,duration:e,delay:n,fromWhere:i.name}):this.goToForm(ct({index:t,fromWhere:i.name},e)))}},{key:"nextForm",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r="move",o=this.getCurrentForm();null==o||-1<(t=this.getFormIndex(o))&&((t+=1)>this.eqn.currentFormSeries.length-1&&(t=0,r=null!=(e=this.eqn.formRestart)&&null!=e.moveFrom?"moveFrom":null!=e&&null!=e.pulse?"pulse":"dissolve"),"number"==typeof n||null==n?this.goToForm({index:t,duration:n,delay:i,fromWhere:o.name,animate:r}):this.goToForm(ct({index:t,animate:r,fromWhere:o.name},n)))}},{key:"replayCurrentForm",value:function(t){var e;this.eqn.isAnimating?(this.stopEquationAnimating("complete"),this.eqn.isAnimating=!1,null!=(e=this.getCurrentForm())&&this.showForm(e)):(this.stopEquationAnimating(),this.eqn.isAnimating=!1,this.prevForm(0),this.nextForm(t,.5))}},{key:"animateToForm",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;this.stopEquationAnimating();var r=this.getForm(t);null!=r&&r.animatePositionsTo(n,.4,e,.4,i),this.setCurrentForm(t)}},{key:"changeDescription",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};null!=(t=this.getForm(t))&&(t.description="".concat(e),t.modifiers=n)}},{key:"getDescription",value:function(t){return null!=(t=this.getForm(t))&&null!=t.description?Os(t.description,t.modifiers):""}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}(),jc=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);var i,r,o,a,s=(h=ct({},{label:"",color:[this.lastOffsetMag=0,0,1,1],scale:.7,position:new pe(0,0),xAlign:"center",yAlign:"middle"},n)).label,l=h.color,u=h.scale,c=h.position,h=(n=h.yAlign,h.xAlign);"string"==typeof s?(a=e.equation({elements:{base:s},color:l,formDefaults:{alignment:{fixTo:new pe(0,0),xAlign:h,yAlign:n}},scale:u,forms:{base:["base"]},position:c})).showForm("base"):s instanceof Cc?(a=s).showForm(Object.keys(a.eqn.forms)[0]):Array.isArray(s)?(i={},r={},o=[],s.forEach((function(t,e){i["_".concat(e)]=t,r[e]=[t],o.push("".concat(e))})),(a=e.equation({elements:i,forms:r,color:l,position:c,formDefaults:{alignment:{fixTo:new pe(0,0),xAlign:h,yAlign:n}},scale:u,formSeries:o})).showForm("0")):(u={color:l,formDefaults:{alignment:{fixTo:new pe(0,0),xAlign:h,yAlign:n}},scale:u},(a=e.equation(ct(u,s))).showForm(Object.keys(a.eqn.forms)[0])),this.eqn=a,this.width=0,this.height=0,this.aOffset=0}var e=[{key:"showForm",value:function(t){this.eqn.showForm(t)}},{key:"setText",value:function(t){var e,n,i=this.eqn.getCurrentForm();null!=i&&(e=Object.keys(i.elements)[0],null!=(n=i.elements[e].drawingObject)&&(n.setText(t),i.elements[e].drawBorder=i.elements[e].drawingObject.textBorder,i.elements[e].drawBorderBuffer=i.elements[e].drawingObject.textBorderBuffer),i.arrange(this.eqn.eqn.scale,this.eqn.eqn.formDefaults.alignment.xAlign,this.eqn.eqn.formDefaults.alignment.yAlign,this.eqn.eqn.formDefaults.alignment.fixTo))}},{key:"getText",value:function(){var t,e="",n=this.eqn.getCurrentForm();return null!=n&&(t=Object.keys(n.elements)[0],null!=(t=n.elements[t].drawingObject)&&(e=t.text[0].text)),e}},{key:"updateRotation",value:function(t,e,n,i,r,o){var a,s,l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:"oval",c=!(8<arguments.length&&void 0!==arguments[8])||arguments[8],h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:2*Math.PI,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:Math.PI,p=Math.PI/2,m=0;"start"===i?p=-Math.PI:"end"===i?p=0:(s=-(a=Math.cos(e+l)<0?-Math.PI/2:Math.PI/2),y=-(v=0<Math.sin(e+l)?Math.PI/2:-Math.PI/2),"top"===i&&(p=a),"bottom"===i&&(p=s),"right"===i&&(p=y),"left"===i&&(p=v),"positive"===i&&(p=Math.PI/2),"negative"===i&&(p=-Math.PI/2),0!==d(Math.sin(e+l),4)||"left"!==i&&"right"!==i||("top"===r&&(p=a),"bottom"===r&&(p=s)),0!==d(Math.cos(e+l),4)||"top"!==i&&"bottom"!==i||("right"===r&&(p=y),"left"===r&&(p=v)),"inside"===i&&(p=-Math.PI/2),"outside"===i&&(p=Math.PI/2));var y=l;"horizontal"===o&&(m=-e),"baseToLine"===o&&p<(m=y=0)&&(m=Math.PI),"baseAway"===o&&(y=0,m=Math.PI,p<0&&(m=0)),"upright"===o&&(y=0,Math.cos(e+l)<0&&(m=Math.PI)),r=0;var v=0;l=!1,null!=(o=this.eqn.getCurrentForm())&&(this.height!==o.height&&(this.height=o.height,l=!0),this.width!==o.width&&(this.width=o.width,l=!0),r=o.height/2,v=o.width/2),n!==this.lastOffsetMag&&(this.lastOffsetMag=n,l=!0),o=new pe(0,0),"oval"===u&&(o=this.getOvalOffset(m-y,r,v,n,p,l,i,h,f)),h=t.add(o),f=m-y,!1===c&&(h=t.add(o).rotate(e,t),f=m-y+e),this.eqn.setPosition(h),this.eqn.transform.updateRotation(f)}},{key:"getOvalOffset",value:function(t,e,n,i,r,o,a){function s(t,e,n){return t*e/Math.sqrt(Math.pow(e*Math.cos(n),2)+Math.pow(t*Math.sin(n),2))}var l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:2*Math.PI,u=8<arguments.length&&void 0!==arguments[8]?arguments[8]:Math.PI;if(o){for(var c=Math.atan(e/n),h=e/Math.sin(c)+i,f=h-s(n+i,e+i,c),d=2,p=-1,m=0;d<33&&p<h;)p=s(n+(m=f*d*.1+i),e+m,c),d+=1;this.aOffset=m}var y,v,g=this.aOffset+n,b=this.aOffset+e,w=ae(t,"0to360");return o=0,t=0,"start"===a?(o=-(y=s(g,b,v=l-w))*Math.cos(l),t=-y*Math.sin(l)):"end"===a?(o=-(y=s(g,b,v=u-w))*Math.cos(u),t=-y*Math.sin(u)):(y=s(g,b,v=ae(2*Math.PI-Math.atan(-Math.pow(b,2)/(Math.pow(g,2)*Math.tan(w))),"0to360")),(v=ae(w+v-Math.PI,"-180to180"))<0&&(v+=Math.PI),o=y*Math.cos(v),t=y*Math.sin(v),r<0&&(t=-t,o=-o)),0===i?new pe(0,0):new pe(o,t)}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function Rc(t){return(Rc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Dc(t,e,n){return(Dc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=qc(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ic(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Lc(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Wc(t,e)}function Wc(t,e){return(Wc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function zc(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=qc(t);return function(t,e){if(e&&("object"===Rc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Nc(t)}(this,e?(n=qc(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function Nc(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qc(t){return(qc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Hc=function(){Lc(e,jc);var t=zc(e);function e(n,i,r,o){var a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"top",s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"left",l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:"horizontal",u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:.5,c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:.7,h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:1;return Ic(this,e),(c=t.call(this,n,{label:i,color:r,scale:c})).offset=o,c.location=a,c.subLocation=s,c.orientation=l,c.linePosition=u,c.precision=h,c}return e}(),Kc=function(){Lc(n,rs);var t,e=zc(n);function n(t,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};Ic(this,n);var o,a,s,l=ct({},{width:.01,align:"start",color:t.primitives.defaultColor,dash:[],mods:{},pulseWidth:{line:6,label:2,arrow:3,duration:1,frequency:0},transform:new Ee("Line").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},r);(s=e.call(this,l)).setColor(l.color),s.collections=t,s.isTouchDevice=i,s.dash=l.dash,s.width=l.width,s.line=(a=l,a=null!=(o=ct({},{p1:new pe(0,0),length:1,angle:0,align:"start",offset:0},a)).p1&&null!=o.p2?new Se(o.p1,o.p2):new Se(o.p1,o.length,o.angle),a=0!==o.offset?a.offset("positive",o.offset):a),s.alignDraw=l.align,s.localXPosition=0,s.autoUpdateSubscriptionId=-1,s.lastParentRotationOffset=0,s.pulseWidthOptions={oldCallback:null,oldTransformMethod:null},s.multiMove={midLength:0,includeLabelInTouchBoundary:!1},s.scaleTransformMethodName="_transformMethod",s._line=null,0<s.width&&(r=s.collections.primitives,t=s.line.length(),i=s.width,o=l.color,a=s.dash,(a=r.line({p1:[0,0],length:a.length<2?1:t,angle:0,width:i,color:o,dash:a,transform:(new Ee).scale(1,1).translate(0,0)})).fnMap.add(s.scaleTransformMethodName,(function(t){return(new Ee).scale(1,t)})),s.add("line",a)),s._arrow1=null,s._arrow2=null,s.label=null,s._label=null,s.showRealLength=!1,null!=l.arrow&&(c=En(l.arrow,s.width||.01),s.arrow=c,s.addArrow("start"),s.addArrow("end")),s.setupLine();var u,c={text:null,offset:1e-5,location:"positive",subLocation:"left",orientation:"horizontal",linePosition:.5,scale:.7,color:l.color,precision:1,update:!1};return void 0!==l.label&&(null===(u="string"==typeof l.label||null===l.label?ct({},c,{text:l.label}):ct({},c,l.label)).text&&(u.text="",s.showRealLength=!0),s.addLabel(u.text,u.offset,u.location,u.subLocation,u.orientation,u.linePosition,u.scale,u.color,u.precision,u.update,u)),l.move&&(u=ct({},{type:"rotation",middleLength:.22,includeLabelInTouchBoundary:!1},l.move),s.setMovable({movable:!0,type:u.type,middleLength:u.middleLength})),s.pulseWidthDefaults={line:l.pulseWidth.line||1,label:l.pulseWidth.label||1,arrow:l.pulseWidth.arrow||1,duration:l.pulseWidth.duration||1,frequency:l.pulseWidth.frequency||0},null!=l.mods&&l.mods!=={}&&s.setProperties(l.mods),s.fnMap.add("_lengthCallback",(function(t,e){var n=e.start;e=e.target,s.setLength((e-n)*t+n)})),s.animations.length=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{element:Nc(s)}].concat(e));return i.customProperties={start:null==i.start?s.line.length():i.start,target:null==i.target?s.line.length():i.target},i.callback="_lengthCallback",i.timeKeeper=s.timeKeeper,new go(i)},s.fnMap.add("_pulseWidth",(function(t,e){var n=e.line,i=e.label,r=e.arrow,o=e.duration;e=e.frequency,s.pulseWidth({line:n,label:i,arrow:r,duration:o,frequency:e})})),s.animations.pulseWidth=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{element:Nc(s),duration:1}].concat(e));return i.callback="_pulseWidth",i.customProperties={line:i.line,label:i.label,arrow:i.arrow,duration:i.duration,frequency:i.frequency},i.timeKeeper=s.timeKeeper,new lo(i)},s.animations.customSteps.push({step:s.animations.length.bind(Nc(s)),name:"length"}),s.animations.customSteps.push({step:s.animations.pulseWidth.bind(Nc(s)),name:"pulseWidth"}),s.fnMap.add("transformToLine",s.transformToLine.bind(Nc(s))),s.notifications.add("setTransform","transformToLine"),s}return t=[{key:"transformToLine",value:function(){var t=this.transform.r()||0,e=this.transform.t()||new pe(0,0),n=this.line.length(),i=new Se(e,n,t),r=[0,0];"start"===this.alignDraw?r=e._dup():"end"===this.alignDraw?r=i.pointAtPercent(-1):"center"===this.alignDraw?r=i.pointAtPercent(-.5):"number"==typeof this.alignDraw&&(r=i.pointAtPercent(-this.alignDraw)),this.line=new Se(r,n,t)}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return Fc(t)}(e=Dc(qc(n.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return Fc(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Fc(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["line","alignDraw","width","dash","animateLengthToOptions","pulseWidthOptions"]);var e}},{key:"_fromState",value:function(t){return ct(this,t),this.setupLine(),this}},{key:"stateSet",value:function(){Dc(qc(n.prototype),"stateSet",this).call(this),this.setupLine()}},{key:"pulseWidthDone",value:function(){var t=this._line;null!=t&&(this.pulseWidthOptions.oldTransformMethod&&(t.pulseSettings.transformMethod=this.pulseWidthOptions.oldTransformMethod),t.pulseSettings.callback=this.pulseWidthOptions.oldCallback)}},{key:"pulseWidth",value:function(){var t=ct({line:this.pulseWidthDefaults.line,label:this.pulseWidthDefaults.label,arrow:this.pulseWidthDefaults.arrow,done:null,duration:this.pulseWidthDefaults.duration,frequency:this.pulseWidthDefaults.frequency,when:"nextFrame"},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),e=t.done;null!=(i=this._line)&&(i.stopPulsing(),this.pulseWidthOptions={oldTransformMethod:i.pulseSettings.transformMethod,oldCallback:i.pulseSettings.callback},i.pulseSettings.callback=this.pulseWidthDoneCallbackName,i.pulseSettings.transformMethod=this.scaleTransformMethodName,i.pulse({duration:t.duration,scale:t.line,frequency:t.frequency,callback:e,when:t.when}),e=null);var n=this._arrow1,i=this._arrow2;null!=n&&(n.pulse({duration:t.duration,scale:t.arrow,frequency:t.frequency,callback:e,when:t.when,centerOn:n.getPosition("figure")}),e=null),null!=i&&(i.pulse({duration:t.duration,scale:t.arrow,frequency:t.frequency,callback:e,when:t.when,centerOn:i.getPosition("figure")}),e=null),null!=(i=this._label)&&(t="number"==typeof t.label?ct({},t,{scale:t.label,callback:e}):ct({},t,t.label,{callback:e}),i.pulse(t),e=null),null!=e&&e(),this.animateNextFrame()}},{key:"addArrow",value:function(t){var e,n,i;null!=this.arrow&&null!=this.arrow[t]&&(i=this.arrow[t],e=0,n=1,"start"===t&&(e=Math.PI,n=0),n=this.collections.primitives.arrow(ct({},i,{angle:e,color:this.color,transform:(new Ee).translate(n)})),i=kn(i)[1],this["arrow".concat(t="end"===t?2:1)]={height:i},this.add("arrow".concat(t),n))}},{key:"setMovable",value:function(t){var e={movable:!0,type:this.move.type,middleLength:.333,includeLabelInTouchBoundary:!1},i=!1===t?ct({},e,{movable:!1}):!0===t?e:ct({},e,t);i.movable?(t=(e=i).includeLabelInTouchBoundary,i=e.type,e=e.middleLength,this.multiMove.includeLabelInTouchBoundary=t,"translation"===i||"rotation"===i||"scale"===i?(this.move.type=i,Dc(qc(n.prototype),"setMovable",this).call(this,!0),this.hasTouchableElements=!0,null!=this._line&&(this._line.isTouchable=!0,this._line.isMovable=!1),this._movePad&&(this._movePad.isMovable=!1)):"centerTranslateEndRotation"===i&&(this.setMultiMovable(e),this.updateMovePads())):(this.isMovable=!1,this.isTouchable=!1,null!=this._line&&(this._line.isTouchable=!1,this._line.isMovable=!1))}},{key:"setMultiMovable",value:function(t){var e;this.multiMove.midLength=t,null==this._rotPad&&(e=this.collections.primitives.rectangle({position:new pe(0,0),xAlign:"left",yAlign:"bottom",width:1,height:1,color:[0,0,1,5e-4]}),this.add("rotPad",e),e.setMovable(),e.move.type="rotation",e.move.element=this,e.drawingObject.border=[[]]),null==this._movePad&&(e=this.collections.primitives.rectangle({position:new pe(0,0),xAlign:"left",yAlign:"bottom",width:1,height:1,color:[0,1,0,5e-4]}),this.add("movePad",e),e.setMovable(),e.move.type="translation",e.move.element=this,e.drawingObject.border=[[]]),this.hasTouchableElements=!0,this.isTouchable=!1,this.isMovable=!1,this.setLength(this.line.length())}},{key:"updateMoveTransform",value:function(){var t=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.transform._dup()).r();null!=t&&(t>2*Math.PI&&this.transform.updateRotation(t-2*Math.PI),t<0&&this.transform.updateRotation(t+2*Math.PI))}},{key:"addLabel",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"top",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"left",r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"horizontal",o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:.5,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:.7,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:this.color,l=8<arguments.length&&void 0!==arguments[8]?arguments[8]:1,u=9<arguments.length&&void 0!==arguments[9]&&arguments[9],c=10<arguments.length&&void 0!==arguments[10]?arguments[10]:{};this.label=new Hc(this.collections,t,s,e,n,i,r,o,a,l),(this.label.eqn.initialForm=null)!=c.isTouchable&&(this.label.eqn.isTouchable=c.isTouchable),null!=c.touchBorder&&(this.label.eqn.touchBorder=c.touchBorder),null!=c.onClick&&(this.label.eqn.onClick=c.onClick),null!=this.label&&this.add("label",this.label.eqn),this.setAutoUpdate(u),this.updateLabel(),this.updateMovePads()}},{key:"setAutoUpdate",value:function(){var t=this;0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.notifications.remove("setTransform",this.autoUpdateSubscriptionId),this.autoUpdateSubscriptionId=-1):this.autoUpdateSubscriptionId=this.notifications.add("setTransform",(function(){t.updateLabel(),t.updateMovePads()}))}},{key:"getLength",value:function(){return this.line.length()}},{key:"getAngle",value:function(){return"deg"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"rad")?180*this.line.angle()/Math.PI:this.line.angle()}},{key:"setLabel",value:function(t){this.showRealLength=!1,null!=this.label&&this.label.setText(t),this.updateLabel(),this.updateMovePads()}},{key:"getLabel",value:function(){return null!=this.label?this.label.getText():""}},{key:"setLabelToRealLength",value:function(){this.showRealLength=!0,this.updateLabel(),this.updateMovePads()}},{key:"updateLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t&&(this.lastParentRotationOffset=t);var e,n=this.label;null!=n&&(t=we(this.transform.r()||0),this.showRealLength&&this._label&&(e=f(this.line.length(),2).toFixed(n.precision),n.getText()!==e&&n.setText(f(this.line.length(),2).toFixed(n.precision))),e=new pe(this.localXPosition+n.linePosition*this.line.length(),0),"start"===n.location&&(e.x=this.localXPosition),"end"===n.location&&(e.x=this.localXPosition+this.line.length()),n.updateRotation(e,t,n.offset,n.location,n.subLocation,n.orientation,this.lastParentRotationOffset,"oval",!0,2*Math.PI,Math.PI))}},{key:"setLength",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.alignDraw;t=0===t?1e-7:t,"start"===e?this.line=new Se(this.line.p1,t,this.line.angle()):"end"===e?this.line=new Se(this.line.pointAtLength(this.line.length()-t),t,this.line.angle()):"center"===e?this.line=new Se(this.line.pointAtLength((this.line.length()-t)/2),t,this.line.angle()):"number"==typeof e&&(this.line=new Se(this.line.pointAtLength((this.line.length()-t)*e),t,this.line.angle())),this.alignDraw=e,this.setupLine()}},{key:"setupLine",value:function(){var t=this,e=!this.isShown,n=!1;null!=this._label&&!1===this._label.isShown&&(n=!0);var i=function(e,n){null!=t["_".concat(e)]&&t["_".concat(e)].transform.updateTranslation(n)},r=0,o=this.line.p1._dup();"number"==typeof(s=this.alignDraw)?(r=-this.line.length()*s,o=this.line.pointAtPercent(s)):"end"===s?(r=-this.line.length(),o=this.line.p2._dup()):"center"===s&&(r=-this.line.length()/2,o=this.line.pointAtPercent(.5)),i("arrow1",this.localXPosition=r),i("arrow2",r+this.line.length());var a=this.line.length(),s=0;this.arrow1&&this._arrow1&&(a-=this.arrow1.height,s=this.arrow1.height),this.arrow2&&this._arrow2&&(a-=this.arrow2.height),a=Math.max(a,0),(i=this._line)&&(i.transform.updateTranslation(r+s),i.custom.updatePoints({p1:[0,0],p2:[a,0],dash:this.dash})),this.transform.updateRotation(this.line.angle()),this.transform.updateTranslation(o),this.updateLabel(),this.updateMovePads(),e&&this.hide(),n&&null!=this._label&&this._label.hide()}},{key:"updateMovePads",value:function(){var t,e,n,i,r;null!=this._movePad&&null!=this._rotPad&&(n=["line","arrow1","arrow2"],this.multiMove.includeLabelInTouchBoundary&&n.push("label"),t=(r=Le(this.getBorder("draw","touchBorder",n)))[0].distance(r[1]),e=r[0].distance(r[3]),(n=this._movePad)&&(i=this.multiMove.midLength*this.line.length(),n.transform.updateScale(i,e),n.setPosition(this.localXPosition+this.line.length()/2-i/2,r[0].y)),(i=this._rotPad)&&(i.transform.updateScale(t,e),i.setPosition(r[0].x,r[0].y)),(r=this._startPad)&&r.transform.updateTranslation(this.localXPosition,0))}},{key:"setEndPoints",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.line=new Se(t,e).offset("positive",n),this.setupLine()}},{key:"pointFromTo",value:function(t,e){var n,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=this.spaceTransformMatrix("figure","local"),o=t.element.getBoundingRect("figure"),a=e.element.getBoundingRect("figure"),s={from:{xAlign:"center",yAlign:"middle",space:0},to:{xAlign:"center",yAlign:"middle",space:0}};i&&(n=o.intersectsWith(a.center()),i=a.intersectsWith(o.center()),null!=n&&(s.from.xAlign=(n.x-o.left)/o.width,s.from.yAlign=(n.y-o.bottom)/o.height),null!=i&&(s.to.xAlign=(i.x-a.left)/a.width,s.to.yAlign=(i.y-a.bottom)/a.height)),o=rn(o,(e=ct({},s,{from:t,to:e})).from.xAlign,e.from.yAlign).transformBy(r),r=rn(a,e.to.xAlign,e.to.yAlign).transformBy(r),r=new Se(o,r),this.setEndPoints(r.pointAtLength(e.from.space),r.pointAtLength(r.length()-e.to.space))}},{key:"grow",value:function(t){t=ct({},{start:0},t),this.animations.new().then(this.animations.length(t)).start()}},{key:"showLineOnly",value:function(){this.show(),this._line&&this._line.show(),this._arrow1&&this._arrow1.show(),this._arrow2&&this._arrow2.show(),this._label&&this._label.hideAll()}},{key:"getLine",value:function(){return new Se(this.getP1(),this.getP2())}},{key:"getP1",value:function(){return this.line.p1._dup()}},{key:"getP2",value:function(){return this.line.p2._dup()}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,t),n}();function Uc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Vc(t){return(Vc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Gc(t,e,n){return(Gc="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=th(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Yc(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Xc(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$c(t,e)}function $c(t,e){return($c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Qc(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=th(t);return Jc(this,e?(n=th(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function Jc(t,e){if(e&&("object"===Vc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Zc(t)}function Zc(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function th(t){return(th=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var eh=function(){Xc(e,jc);var t=Qc(e);function e(n,i,r,o){var a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:.5,s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,l=6<arguments.length&&void 0!==arguments[6]&&arguments[6],u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:"degrees",c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:0,h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:null,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:null,d=11<arguments.length&&void 0!==arguments[11]?arguments[11]:"horizontal",p=12<arguments.length?arguments[12]:void 0,m=13<arguments.length?arguments[13]:void 0,y=14<arguments.length&&void 0!==arguments[14]?arguments[14]:.7;return Yc(this,e),(y=t.call(this,n,{label:i,color:r,scale:y})).radius=o,y.curvePosition=a,y.offset=s,y.showRealAngle=l,y.units=u,y.orientation=d,y.precision=c,y.autoHide=h,y.autoHideMax=f,y.location=p,y.subLocation=m,y}return e}();const nh=function(){Xc(n,rs);var t,e=Qc(n);function n(t,i,r){var o,a,s,l=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(Yc(this,n),l=ct({},{position:new pe(0,0),color:t.primitives.defaultColor,direction:1,curve:null,corner:null,sides:null,sideStart:null,sideStop:null,pulseAngle:{curve:1.5,label:1.5,arrow:1.5,side:1.5,corner:1.5,thick:1},mods:{},transform:new Ee("Angle").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},l),(o=e.call(this,l)).setColor(l.color),o.collections=t,o.largerTouchBorder=l.largerTouchBorder,o.isTouchDevice=i,o.autoUpdateSubscriptionId=0,o.lastLabelRotationOffset=0,"positive"===l.direction?o.direction=1:"negative"===l.direction?o.direction=-1:o.direction=l.direction,o.calculateAngleRotationPosition(l),o.setNextPositionAndRotation(),o.side1=null,o.side2=null,o.curve=null,o.label=null,o._curve=null,l.curve&&o.addCurve(l.curve),o._arrow1=null,(o._arrow2=null)!=l.arrow){t=.01,o.curve&&(t=o.curve.width);var u=!0;"string"!=typeof l.arrow&&null!=l.arrow.autoHide&&(u=l.arrow.autoHide),i=.1,o.curve&&(i=o.curve.radius),"string"!=typeof l.arrow&&null!=l.arrow.radius&&(i=l.arrow.radius);var c=.3;if("string"!=typeof l.arrow&&null!=l.arrow.curveOverlap&&(c=l.arrow.curveOverlap),t=En(l.arrow,t),o.arrow=t,null==o.arrow)return Jc(o);u={radius:i,autoHide:u,curveOverlap:c},null!=o.arrow.start&&(o.arrow.start=ct({},u,o.arrow.start)),null!=o.arrow.end&&(o.arrow.end=ct({},u,o.arrow.end)),o.addArrow("start"),o.addArrow("end")}return!l.label&&null!==l.label||(null===l.label&&(l.label={text:null}),"string"==typeof l.label&&(l.label={text:l.label}),o.addLabel(l.label)),c=.5,u=.01,u={length:c=o.curve?2*o.curve.radius:c,width:u=o.curve?o.curve.width:u,color:o.color},l.side1&&(a=ct({},u,l.side1),o.addSide(1,a.length,a.width,a.color)),l.side2&&(a=ct({},u,l.side2),o.addSide(2,a.length,a.width,a.color)),null!=l.corner&&(s=ct({},u,{style:"fill"},l.corner),o.addCorner(s)),l.sides&&(s={},s=ct({},u,s="object"===Vc(l.sides)?l.sides:s),o.addSide(1,s.length,s.width,s.color),o.addSide(2,s.length,s.width,s.color)),o.pulseAngleDefaults={curve:l.pulseAngle.curve||1.5,corner:l.pulseAngle.corner||1.5,label:l.pulseAngle.label||1.5,arrow:l.pulseAngle.arrow||1.5,duration:l.pulseAngle.duration||1.5,frequency:l.pulseAngle.frequency||0,thick:l.pulseAngle.thick||1},o.animations.angle=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i,r,a=ct.apply(void 0,[{},{element:Zc(o)}].concat(e)),s=!0;return a.callback=function(t){s&&(r=null==a.start?o.angle:a.start,i=null==a.target?o.angle:a.target,s=!1),t=(i-r)*t+r,o.setAngle({angle:t})},a.timeKeeper=o.timeKeeper,new go(a)},o.animations.customSteps.push({step:o.animations.angle.bind(Zc(o)),name:"angle"}),o.animations.pulseAngle=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{element:Zc(o),duration:1}].concat(e));return i.callback=function(){o.pulseAngle({curve:i.curve,label:i.label,arrow:i.arrow,corner:i.corner,duration:i.duration,frequency:i.frequency,thick:i.thick})},i.timeKeeper=o.timeKeeper,new lo(i)},o.animations.customSteps.push({step:o.animations.pulseAngle.bind(Zc(o)),name:"pulseAngle"}),o.update(),null!=l.mods&&l.mods!=={}&&o.setProperties(l.mods),o}return t=[{key:"calculateAngleRotationPosition",value:function(t){var e,n=ct({},{angle:1,startAngle:this.startAngle},t),i=n.angle,r=n.startAngle,o=n.position;null!=o&&(o=ue(o)),null!=n.p1&&null!=n.p2&&null!=n.p3&&(e=ue(n.p1),t=ue(n.p2),n=ue(n.p3),o=t._dup(),r=new Se(t,e).angle(),i=We(e,t,n)),this.nextStartAngle=r,null!=o&&(this.nextPosition=o),this.angle=i}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return Uc(t)}(e=Gc(th(n.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return Uc(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Uc(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["angle","lastLabelRotationOffset"]);var e}},{key:"_fromState",value:function(t){return ct(this,t),this.setAngle({angle:this.angle,rotationOffset:this.lastLabelRotationOffset}),this}},{key:"setAutoUpdate",value:function(){var t=this;0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.notifications.remove("setTransform",this.autoUpdateSubscriptionId),this.autoUpdateSubscriptionId=-1):this.autoUpdateSubscriptionId=this.notifications.add("setTransform",(function(){t.updateLabel(t.getRotation())}))}},{key:"setNextPositionAndRotation",value:function(){null!=this.nextPosition&&this.transform.updateTranslation(this.nextPosition),null!=this.nextStartAngle&&(this.transform.updateRotation(this.nextStartAngle),this.startAngle=this.nextStartAngle||0),this.nextPosition=null,this.nextStartAngle=null}},{key:"setAngle",value:function(){var t=!this.isShown,e=!1;null!=this._label&&!1===this._label.isShown&&(e=!0),this.calculateAngleRotationPosition(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{});var n=this.corner,i=this._corner;null!=n&&null!=i&&(n=this.getCornerPoints(n.length),i.custom.updatePoints({points:n})),this.update(),t&&this.hide(),e&&null!=this._label&&this._label.hide()}},{key:"getCornerPoints",value:function(t){return[new pe(t,0),new pe(0,0),new pe(t*Math.cos(this.angle),t*Math.sin(this.angle))]}},{key:"addCorner",value:function(t){var e=t.width,n=t.color,i=t.length,r=t.style;t=this.collections.primitives.polyline({width:e,color:n,points:this.getCornerPoints(i),cornerStyle:r}),this.corner={length:i,width:e,color:n,style:r},this.add("corner",t)}},{key:"addSide",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:this.color;i=this.collections.primitives.line({length:1,width:n,angle:0,color:i,transform:(new Ee).scale(1,1).rotate(0)}),this["side".concat(t)]={length:e,width:n},this.add("side".concat(t),i)}},{key:"addLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e={text:null,radius:.4,curvePosition:.5,offset:1e-4,showRealAngle:!1,units:"degrees",precision:0,orientation:"horizontal",autoHide:null,autoHideMax:null,scale:.7,color:this.color,location:"outside",update:!1};this.curve&&(e.radius=Math.max(this.curve.radius,this.curve.radius+(this.curve.num-1)*this.curve.step)),null===(t=ct({},e,t)).text&&(t.text="",t.showRealAngle=!0),this.label=new eh(this.collections,t.text,t.color,t.radius,t.curvePosition,t.offset,t.showRealAngle,t.units,t.precision,t.autoHide,t.autoHideMax,t.orientation,t.location,t.subLocation,t.scale),(this.label.eqn.initialForm=null)!=t.isTouchable&&(this.label.eqn.isTouchable=t.isTouchable),null!=t.touchBorder&&(this.label.eqn.touchBorder=t.touchBorder),null!=t.onClick&&(this.label.eqn.onClick=t.onClick),null!=this.label&&this.add("label",this.label.eqn),this.setAutoUpdate(t.update),this.updateLabel()}},{key:"addCurve",value:function(){var t=ct({},{width:.01,sides:100,radius:.5,num:1,fill:!1,step:0,autoHide:null,autoHideMax:null,autoRightAngle:!1,rightAngleRange:1/180*Math.PI},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),e=this.direction;this.angle<0&&-1===this.direction?e=1:this.angle<0&&1===this.direction&&(e=-1);for(var n,i,r=0;r<t.num;r+=1){var o={sides:t.sides,radius:t.radius+r*t.step,color:this.color,direction:e,transform:new Ee("AngleCurve").rotate(0)};!1===t.fill&&(o.line={width:t.width});var a=this.collections.primitives.polygon(o);this.curve=t,o="curve",0<r&&(o="".concat(o).concat(r)),this.add(o,a)}null!=this.curve&&this.curve.autoRightAngle&&(n=this.collections.collection(),i=.707*t.radius,n.add("line1",this.collections.primitives.line({p1:[i,0],length:i+t.width/2,width:t.width,angle:Math.PI/2*e,color:this.color})),n.add("line2",this.collections.primitives.line({p1:[0,i*e],length:i+t.width/2,width:t.width,angle:0,color:this.color})),this.add("curveRight",n))}},{key:"change",value:function(t){null!=this._curve&&null!=t.radius&&this._curve.custom.update({radius:t.radius}),null!=this.label&&(null!=t.curveRadius&&(this.label.radius=t.curveRadius),null!=t.curvePosition&&(this.label.curvePosition=t.curvePosition),null!=t.offset&&(this.label.offset=t.offset))}},{key:"addArrow",value:function(t){var e,n,i,r;null!=this.arrow[t]&&(e=this.arrow[t],n=this.collections.primitives.arrow(ct({},e,{color:this.color,transform:(new Ee).rotate(0).translate(0,0)})),i=kn(e)[1],r="end"===t?2:1,this.arrow[t]={height:i,radius:e.radius||0,autoHide:e.autoHide,curveOverlap:e.curveOverlap},this.add("arrow".concat(r),n),this.update())}},{key:"updateCurve",value:function(t,e,n,i){var r=this.curve;if(r){var o=this.direction;this.angle<0&&-1===this.direction?o=1:this.angle<0&&1===this.direction&&(o=-1);var a=n;-1===this.direction&&(a*=-1),this.angle<0&&(a*=-1);for(var s=0;s<r.num;s+=1){var l,u="_curve",c=this[u=0<s?"_curve".concat(s):u];c&&(i?(c.show(),0===s?(l=0,this.curve&&(u=2*Math.PI/this.curve.sides,l=t-Math.floor(f(t/u))*u),c.angleToDraw=ae(t,"0to360"),c.transform.updateRotation(a+o*l/2)):(l=0,this.curve&&(l=e%(2*Math.PI/this.curve.sides)),c.angleToDraw=ae(e,"0to360"),c.transform.updateRotation(o*l/2))):c.hide())}}}},{key:"update",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=this._arrow1,n=this._arrow2,i=!1,r=!1,o=0,a=ae(this.angle,"-360to360");0<=a&&-1===this.direction?a=2*Math.PI-a:a<0&&1===this.direction?a=Math.abs(a):a<0&&-1===this.direction&&(a=2*Math.PI-Math.abs(a));var s,l,u,c,h=a,f=a,d=0,p=0;null!=this.arrow&&null!=this.arrow.start&&(l=(s=this.arrow.start).radius||0,h-=d=s.height/l*(1-s.curveOverlap),f-=s.height/l),null!=this.arrow&&null!=this.arrow.end&&(l=(s=this.arrow.end).radius||0,h-=p=s.height/l*(1-s.curveOverlap),f-=s.height/l),null!=this.arrow&&f<0&&(null!=this.arrow.start&&this.arrow.start.autoHide&&(u=this.arrow.start.radius||0,i=!0,f+=this.arrow.start.height/u,h+=d),null!=this.arrow.end&&this.arrow.end.autoHide&&(u=this.arrow.end.radius||0,r=!0,f+=this.arrow.end.height/u,h+=p)),e&&null!=this.arrow&&null!=this.arrow.start&&(i?e.hide():(e.show(),e.transform.updateTranslation(this.arrow.start.radius,0),p=this.arrow.start.height/this.arrow.start.radius,c=this.arrow.start.radius||0,c=(0<this.angle&&1===this.direction||this.angle<0&&-1===this.direction?new Se(Re(c,p),[c,0]):new Se(Re(c,-p),[c,0])).angle(),e.transform.updateRotation(c),o=d)),n&&null!=this.arrow&&null!=this.arrow.end&&(r?n.hide():(n.show(),n.transform.updateTranslation(Re(this.arrow.end.radius,this.angle)),c=this.arrow.end.height/this.arrow.end.radius,m=this.arrow.start.radius||0,m=(0<this.angle&&1===this.direction||0<this.angle&&-1===this.direction?new Se(Re(m,this.angle-this.direction*c),Re(m,this.angle)):new Se(Re(m,this.angle+this.direction*c),Re(m,this.angle))).angle(),n.transform.updateRotation(m),o=d)),null!=t&&(this.lastLabelRotationOffset=t),this.setNextPositionAndRotation();var m=this._curve;d=this.curve,t=this._curveRight,null!=m&&null!=d&&(null!=d.autoHide&&a<d.autoHide||null!=d.autoHideMax&&a>d.autoHideMax?(null!=t&&t.hide(),m.hide(),null!=e&&e.hide(),null!=n&&n.hide()):null!=d&&d.autoRightAngle&&a>=Math.PI/2-d.rightAngleRange/2&&a<=Math.PI/2+d.rightAngleRange/2?(null!=t&&t.showAll(),m.hide(),null!=e&&e.hide(),null!=n&&n.hide()):(null!=t&&t.hide(),null!=e&&!1===i&&e.show(),null!=n&&!1===r&&n.show(),h=Math.max(h,0),this.updateCurve(h,a,o,!0))),this.updateLabel(),a=this._side1,o=this.side1,a&&o&&a.transform.updateScale(o.length,1),a=this._side2,o=this.side2,a&&o&&(a.transform.updateRotation(this.angle),a.transform.updateScale(o.length,1)),this.updateMovePads()}},{key:"checkLabelForRightAngle",value:function(){var t,e,n,i;null!=this.curve&&!1===this.curve.autoRightAngle||(i=!1)!==(i=null!=(n=this.label)&&90===parseFloat(n.getText())||i)&&(t=this._curveRight,e=this._curve,n=this._arrow1,i=this._arrow2,null!=t&&t.showAll(),null!=e&&e.hide(),null!=n&&n.hide(),null!=i&&i.hide())}},{key:"getAngle",value:function(){return"deg"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"rad")?180*this.angle/Math.PI:this.angle}},{key:"setLabel",value:function(t){var e=this.label;null!=e&&(e.setText(t),e.showRealAngle=!1),this.updateLabel()}},{key:"getLabel",value:function(){return null!=this.label?this.label.getText():""}},{key:"setLabelToRealAngle",value:function(){var t=this.label;null!=t&&(t.showRealAngle=!0),this.updateLabel()}},{key:"updateLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getRotation();null!=t&&(this.lastLabelRotationOffset=t);var e,n,i,r=this._label,o=this.label;r&&o&&(null!=o.autoHide&&o.autoHide>Math.abs(this.angle)||null!=o.autoHideMax&&Math.abs(this.angle)>o.autoHideMax?r.hide():(r.show(),o.showRealAngle&&(0<=(e=this.angle)&&-1===this.direction?e=-(2*Math.PI-Math.abs(e)):e<0&&-1===this.direction&&(e=2*Math.PI-Math.abs(e)),e=Math.abs(e),i=f(e,o.precision).toFixed(o.precision),"degrees"===o.units&&(i=(n=360===(n=f(180*e/Math.PI,o.precision))?0:n).toFixed(o.precision),i="".concat(i,"°")),o.setText(i)),t=ae(this.angle,"-360to360"),r=Math.PI/2,t<0&&(r=-Math.PI/2),0<=t&&-1===this.direction?t=-(2*Math.PI-t):t<0&&-1===this.direction&&(t=2*Math.PI-Math.abs(t)),e=Re(o.radius,t*o.curvePosition),"tangent"===(n=o.orientation)&&(n="baseToLine"),"outside"===(i=o.location)&&(i="negative",-1===this.direction&&(i="positive")),"inside"===i&&(i="positive",-1===this.direction&&(i="negative")),r=ae(ae(t,"0to360")*o.curvePosition+r,"0to360"),"start"===i&&(e=new pe(o.radius,0),r=0),"end"===i&&(e=Re(o.radius,t),r=ae(t,"0to360")),o.updateRotation(e,r,o.offset,i,o.subLocation,n,null==this.lastLabelRotationOffset?0:this.lastLabelRotationOffset,"oval",!1,Math.PI/2,-Math.PI/2)))}},{key:"pulseAngle",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n={curve:this.pulseAngleDefaults.curve,label:this.pulseAngleDefaults.label,arrow:this.pulseAngleDefaults.arrow,corner:this.pulseAngleDefaults.corner,done:null,duration:this.pulseAngleDefaults.duration,frequency:this.pulseAngleDefaults.frequency,when:"nextFrame",thick:this.pulseAngleDefaults.thick},i=this.getPosition("figure"),r=ct(n,e),o=r.done;e=function(e,n,i,a){var s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;null!=(e=t.elements[e])&&e.isShown&&(i=ct({num:r.thick},1<r.thick?a:i),1<(n="number"==typeof r[n]?ct({},i,r,{scale:r[n],callback:o}):ct({},i,r,r[n],{callback:o})).num&&null==n.min&&(n.min=1/n.scale),null!=s&&(n.centerOn=s),e.pulse(n),o=null)},null!=this._curve&&e("curve","curve",{},{}),null!=this._curveRight&&e("curveRight","curve",{},{},this.getPosition("figure")),null!=this.corner&&null!=this._corner&&e("corner","corner",{centerOn:i},{centerOn:i,num:1}),e("label","label",{centerOn:i},{num:1}),null!=this.arrow&&(null!=this._arrow1&&e("arrow1","arrow",{centerOn:i},{centerOn:this._arrow1.getPosition("figure"),num:1}),null!=this._arrow2&&e("arrow2","arrow",{centerOn:i},{centerOn:this._arrow2.getPosition("figure"),num:1})),this.animateNextFrame()}},{key:"showAll",value:function(){Gc(th(n.prototype),"showAll",this).call(this),this.update()}},{key:"setMovable",value:function(t){var e={movable:!0,type:this.move.type,width:.5,movePadRadius:0,startArm:null,endArm:null},n=(r=!1===t?ct({},e,{movable:!1}):!0===t?e:ct({},e,t)).movable,i=(e=r.startArm,t=r.endArm,r.movePadRadius),r=r.width;n?(null!=e&&null!=t?("rotation"===e&&this.addRotPad(1-i,r,"rotation"),"rotation"===t&&this.addAnglePad(1-i,r,"rotation"),"angle"===e&&this.addRotPad(1-i,r,"angle"),"angle"===t&&this.addAnglePad(1-i,r,"angle")):null!=e?this.addRotPad(1-i,r,e):null!=t&&this.addAnglePad(1-i,r,t),0<i&&this.addMovePad(i)):(this.isMovable=!1,this.isTouchable=!1,null!=this._anglePad&&this._anglePad.setMovable(!1),null!=this._rotPad&&this._rotPad.setMovable(!1)),this.updateMovePads()}},{key:"getLength",value:function(){return null!=this.corner&&null!=this.corner.length?this.corner.length:null!=this.curve&&null!=this.curve.radius?this.curve.radius:null!=this.label&&null!=this.label.radius?this.label.radius:1}},{key:"addAnglePad",value:function(){var t,e,n=this,i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,o=2<arguments.length?arguments[2]:void 0;null==this._anglePad&&(t=this.getLength(),e=this.collections.primitives.rectangle({offset:[t*(1-i),0],xAlign:"left",yAlign:"middle",width:t*i+r,height:r,color:[0,0,1,0],border:[[]],touchBorder:"buffer"}),this.add("anglePad",e),e.setMovable(),e.move.type="rotation",e.drawingObject.border=[[]],"rotation"===o?e.notifications.add("beforeSetTransform",(function(t){t=t[0].r()-e.getRotation(),n.transform.updateRotation(n.getRotation()+t),e.cancelSetTransform=!0})):e.notifications.add("setTransform",(function(){var t=e.getRotation();t=0<n.angle?ae(t,"0to360"):ae(t,"-360to0"),n.setAngle({angle:t})})))}},{key:"addRotPad",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,r=2<arguments.length?arguments[2]:void 0;null==this._rotPad&&(t=this.getLength(),n=this.collections.primitives.rectangle({xAlign:"left",yAlign:"middle",width:t*n+i,height:i,color:[1,0,1,0],offset:[t*(1-n),0],border:[[]],touchBorder:"buffer"}),this.add("rotPad",n),n.setMovable(),n.move.type="rotation",n.drawingObject.border=[[]],"angle"===r?(n.move.element=this).notifications.add("beforeSetTransform",(function(t){var n=t[0].r();t=e.getRotation(),t=e.angle-(n-t),t=0<e.angle?ae(t,"0to360"):ae(t,"-360to0"),e.setAngle({angle:t})})):n.move.element=this)}},{key:"addMovePad",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;null==this._movePad&&(t=this.getLength(),e=this.collections.primitives.polygon({radius:t*e,sides:8,fill:!0,color:[1,0,0,0],border:[[]],touchBorder:"buffer"}),this.add("movePad",e),e.setMovable(),e.move.type="translation",e.drawingObject.border=[[]],e.move.element=this)}},{key:"updateMovePads",value:function(){null!=this._anglePad&&this._anglePad.transform.updateRotation(this.angle)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(n.prototype,t),n}();function ih(t){return(ih="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function rh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function oh(t,e,n){return(oh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=sh(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ah(t,e){return(ah=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function sh(t){return(sh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function lh(t,e,n,i){if(Array.isArray(t)){for(var r=[],o=0;o<i;o+=1){var a=t[o%t.length];null!=a.label?r.push(ct({},e,{label:n},a)):r.push(ct({},e,a))}return r}for(var s=[],l=0;l<i;l+=1)s.push("".concat(l));var u,c=ut({except:s},{},t),h=[];null!=c.label&&null!=c.label.text&&Array.isArray(c.label.text)&&(h=c.label.text),null===c.label&&(c.label={text:null}),u=null!=c.show?c.show:1<i?A(0,i-1,1):[0],null!=c.hide&&c.hide.forEach((function(t){-1!==(t=u.indexOf(t))&&u.splice(t,1)}));for(var f,d,p,m=[],y=0;y<i;y+=1)-1===u.indexOf(y)?m.push(null):(f=u.indexOf(y),d=u[f],p={},null!=t["".concat(d)]&&(p=t["".concat(d)]),d={},null!=(p=ct({},e,c,d=0<h.length?{label:{text:h[f%h.length]}}:d,p)).label?m.push(ct({},{label:n},p)):m.push(p));return m}var uh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ah(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=sh(e);return function(t,e){if(e&&("object"===ih(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=sh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e,n){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var a={color:t.primitives.defaultColor,points:[new pe(1,0),new pe(0,0),new pe(0,1)],close:!1,showLine:!0,width:t.primitives.defaultLineWidth,reverse:!1,transform:new Ee("PolyLine").scale(1,1).rotate(0).translate(0,0),makeValid:null,limits:t.primitives.limits};null!=o.makeValid&&null!=o.makeValid.shape&&"triangle"===o.makeValid.shape&&(a.makeValid={shape:"triangle",hide:{minAngle:null,maxAngle:null,minSide:null}});var s=ct({},a,o);return(a=i.call(this,s)).setColor(s.color),a.collections=t,a.largerTouchBorder=s.largerTouchBorder,a.isTouchDevice=e,a.animateNextFrame=n,a.updatePointsCallback=null,a.position=a.getPosition(),a.close=s.close,a.options=s,a.reverse=s.reverse,a.makeValid=s.makeValid,a.points=s.points.map(ue),s.pad&&a.addPads(s.pad),s.angle&&a.addAngles(s.angle,s.close),s.showLine&&(o=a.collections.primitives.polyline({points:a.points,width:o.width,close:o.close,widthIs:o.widthIs,cornerStyle:o.cornerStyle,cornerSize:o.cornerSize,cornerSides:o.cornerSides,minAutoCornerAngle:o.minAutoCornerAngle,dash:o.dash,color:o.color,pulse:o.pulse,arrow:o.arrow,drawBorderBuffer:o.drawBorderBuffer,touchBorder:"buffer"}),a.add("line",o)),s.side&&a.addSides(s.side,s.close),a}return t=[{key:"addPads",value:function(t){for(var e=this,n={sides:20,radius:.1,color:this.color,isMovable:!1,boundary:"figure"},i=this.points.length,r=lh(t,n,{},i),o=0;o<i;o+=1)null!=r[o]&&function(){var t="pad".concat(o),n=ct({},{transform:(new Ee).translate(e.points[o])},r[o]),i=e.collections.primitives.polygon(n),a=(n=(a=r[o]).isMovable,a.boundary);n&&(i.onAdd=function(){i.setMovable()},null!=a&&(i.move.sizeInBounds=!0,i.setMoveBounds(a)),a="_polyline_pad".concat(o),i.fnMap.add(a,(function(t){var n=parseInt(i.name.slice(3),10);null!=(t=t.t())&&(e.points[n]=t._dup(),e.updatePoints(e.points))})),i.setTransformCallback=a),e.add(t,i)}()}},{key:"addAngles",value:function(t,e){var n={color:this.color,curve:{},autoRightAngle:!0},i=this.points.length;!1===e&&(i-=2);for(var r=lh(t,n,{text:null,offset:.05},i),o=0;o<i;o+=1){var a,s,l=o,u=o+1,c=o===i-2&&e?0:o+2;o===i-1&&e&&(u=0,c=1),null!=r[o]&&(a="angle".concat(o),this.reverse&&(s=c,c=l,l=s),c=ct({},{p1:this.points[l],p2:this.points[u],p3:this.points[c]},r[o]),c=this.collections.angle(c),this.add(a,c))}}},{key:"addSides",value:function(t,e){var n={showLine:!1,offset:0,width:0,color:this.color},i=this.points.length-1;e&&(i+=1);for(var r=lh(t,n,{offset:.1,text:null,location:"outside",subLocation:"top",orientation:"horizontal",linePosition:.5,scale:.7},i),o=0;o<i;o+=1){var a,s,l=o===i-1&&e?0:o+1;null!=r[o]&&(a="side".concat(o).concat(l),s=ct({},{p1:this.points[o],p2:this.points[l]},r[o]),this.reverse&&(s=ct({},{p1:this.points[l],p2:this.points[o]},r[o])),(l=this.collections.line(s))._custom.offset=s.offset,this.add(a,l))}}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return rh(t)}(e=oh(sh(r.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return rh(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?rh(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["points"]);var e}},{key:"_fromState",value:function(t){return ct(this,t),this.updatePoints(this.points),this}},{key:"updateSideLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(null!=this.options.side){var e=this.points.length-1;this.close&&(e+=1);for(var n=0;n<e;n+=1){var i=n+1;n===e-1&&this.close&&(i=0);var r="side".concat(n).concat(i);null!=this.elements[r]&&(i=!this.elements[r].isShown,this.elements[r].updateLabel(t),i&&this.elements[r].hide())}}}},{key:"updateAngleLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(null!=this.options.angle){var e=this.points.length;!1===this.close&&(e-=2);for(var n=0,i=n=!1===this.close?1:n;i<e+n;i+=1){var r,o="angle".concat(i);null!=this.elements[o]&&(r=!this.elements[o].isShown,this.elements[o].updateLabel(t),r&&this.elements[o].hide())}}}},{key:"updatePoints",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=t.map(ue);null!=this._line&&this._line.custom.updatePoints({points:n});var i=this.points.length;if(this.options.pad)for(var r=0;r<i;r+=1){var o="pad".concat(r);this.elements[o]&&this.elements[o].transform.updateTranslation(n[r])}if(null!=this.options.side){i=this.points.length-1,this.close&&(i+=1);for(var a=0;a<i;a+=1){var s=a+1;a===i-1&&this.close&&(s=0);var l="side".concat(a).concat(s);null!=this.elements[l]&&(this.reverse?this.elements[l].setEndPoints(n[s],n[a],this.elements[l]._custom.offset):this.elements[l].setEndPoints(n[a],n[s],this.elements[l]._custom.offset))}}this.points=n,this.updateAngles(),null==this.makeValid||"triangle"!==this.makeValid.shape||e||this.makeValidTriangle(),null==this.updatePointsCallback||e||(this.fnMap.exec(this.updatePointsCallback),this.notifications.publish("updatePoints"))}},{key:"updateAngles",value:function(){if(null!=this.options.angle){var t=this.points.length;!1===this.close&&(t-=2);for(var e=0;e<t;e+=1){var n=e,i=e+1,r=e+2;e===t-2&&this.close&&(r=0),e===t-1&&this.close&&(i=0,r=1);var o,a="angle".concat(e);null!=this.elements[a]&&(this.reverse&&(o=r,r=n,n=o),this.elements[a].setAngle({p1:this.points[n],p2:this.points[i],p3:this.points[r]}))}}}},{key:"updateRotation",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=this["_angle".concat(n=0)];null!=e;)e.update(this.getRotation()+t),e=this["_angle".concat(n+=1)];for(var n,i=this["_side".concat(n=0).concat(n+1)];null!=i;)i.updateLabel(this.getRotation()+t),i=this["_side".concat(n+=1).concat(n+1)];null!=(i=this["_side".concat(n,0)])&&i.updateLabel(this.getRotation()+t)}},{key:"reversePoints",value:function(){for(var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=[],n=0;n<this.points.length;n+=1)e.push(this.points[this.points.length-1-n]);this.updatePoints(e,t)}},{key:"setPositionWithoutMoving",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=new pe(0,0);"number"==typeof t?(n.x=t,n.y=e):n=t;var i=this.getPosition().sub(n);this.setPosition(n),n=this.points.map((function(t){return t.add(i)})),this.updatePoints(n)}},{key:"setRotationWithoutMoving",value:function(t){var e=this.getRotation()-t,n=(new Ee).rotate(e).m();this.setRotation(t),t=this.points.map((function(t){return t.transformBy(n)})),this.updatePoints(t)}},{key:"setScaleWithoutMoving",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=new pe(0,0);"number"==typeof t?(n.x=t,n.y=e):n=t,t=this.getScale(),t=new pe(t.x/n.x,t.y/n.y);var i=(new Ee).scale(t).m();this.setScale(n),n=this.points.map((function(t){return t.transformBy(i)})),this.updatePoints(n)}},{key:"setShow",value:function(t,e){for(var n=0;n<this.drawOrder.length;n+=1){var i=this.elements[this.drawOrder[n]];i.name.startsWith(t)&&(e?i.showAll():i.hide())}}},{key:"hideAngles",value:function(){this.setShow("angle",!1)}},{key:"hideSides",value:function(){this.setShow("side",!1)}},{key:"showAngles",value:function(){this.setShow("angle",!0)}},{key:"showSides",value:function(){this.setShow("side",!0)}},{key:"updateLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getRotation();this.updateAngleLabels(t),this.updateSideLabels(t)}},{key:"makeValidTriangle",value:function(){var t=this._angle0,e=this._angle1,n=this._angle2,i=this._side01,r=this._side12,o=this._side20,a=t.label.precision,s=i.label.precision,l=180*ae(t.getAngle(),"0to360")/Math.PI,u=180*ae(e.getAngle(),"0to360")/Math.PI,c=180*ae(n.getAngle(),"0to360")/Math.PI,h=d(l,a),f=d(u,a),p=d(c,a),m=d(i.getLength(),s),y=d(r.getLength(),s),v=d(o.getLength(),s);90<h&&90<f&&90<p&&(this.reverse=!this.reverse,this.updatePoints(this.points,!1),h=d(180*ae(t.getAngle(),"0to360")/Math.PI,a),f=d(180*ae(e.getAngle(),"0to360")/Math.PI,a),p=d(180*ae(n.getAngle(),"0to360")/Math.PI,a));var g,b=(h=180<h?360-t:h)+(f=180<f?360-e:f)+(p=180<p?360-n:p),w=b-180;l=[d(l,a+1),d(u,a+1),d(c,a+1)].map((function(t){return t-Math.floor(t*Math.pow(10,a))/Math.pow(10,a)})),u=[h,f,p],c=0,180<b?c=l.reduce((function(t,e,n,i){return e>i[t]?n:t}),0):b<180&&(c=l.reduce((function(t,e,n,i){return e<i[t]?n:t}),1)),u[c]-=w,h=u[0],f=u[1],p=u[2],t.setLabel("".concat(h.toFixed(a),"º")),e.setLabel("".concat(f.toFixed(a),"º")),n.setLabel("".concat(p.toFixed(a),"º")),t.checkLabelForRightAngle(),e.checkLabelForRightAngle(),n.checkLabelForRightAngle(),null!=this.makeValid&&(t=this.makeValid.hide.minSide,e=(g=this.makeValid.hide).minAngle,n=g.maxAngle,g=!1,null!=e&&(h<(e*=180/Math.PI)||f<e||p<e)&&(g=!0),null!=n&&((n*=180/Math.PI)<h||n<f||n<p)&&(g=!0),(g=null!=t&&(m<t||y<t||v<t)||g)&&this.hideAngles()),(i.isShown||r.isShown||o.isShown)&&0<h&&h<180&&0<f&&f<180&&0<p&&p<180&&(g=1/Math.pow(10,s),60===h&&60===f&&60===p?v=y=m:h===f?m===(v=y)&&(d(i.getLength(),s+1)<m?m-=g:m+=g):h===p?v===(m=y)&&(d(o.getLength(),s+1)<v?v-=g:v+=g):f===p&&y===(v=m)&&(d(r.getLength(),s+1)<y?y-=g:y+=g)),i.setLabel("".concat(m.toFixed(s))),r.setLabel("".concat(y.toFixed(s))),o.setLabel("".concat(v.toFixed(s)))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function ch(t){return(ch="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function hh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function fh(t,e){return(fh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function dh(t){return(dh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const ph=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&fh(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=dh(e);return function(t,e){if(e&&("object"===ch(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=dh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var n,o,a,s,l={length:t.primitives.defaultLength,angle:0,start:0,color:t.primitives.defaultColor,font:t.primitives.defaultFont,name:"",line:{},show:!0,axis:"x",transform:new Ee("Axis").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},u=ct({},l,e);return(s=i.call(this,u)).collections=t,(s.autoStep=null)!=e.auto&&(n=(a=s.calcAuto(e.auto)).start,o=a.stop,t=a.step,a=a.precision,l.start=n,l.stop=o,l.ticks={},l.labels={precision:a},s.autoStep=t),(null==(u=ct({},l,e)).stop||u.stop<=u.start)&&(u.stop=u.start+1),s.name=u.name,s.defaultFont=u.font,null!=e.font&&null!=e.font.color||(s.defaultFont.color=u.color),s.showAxis=u.show,s.startValue=u.start,s.stopValue=u.stop,s.startValue>=s.stopValue&&(s.startValue=s.stopValue-1),s.length=u.length,s.axis=u.axis,s.angle="x"===s.axis?0:Math.PI/2,s.drawToValueRatio=(u.stop-u.start)/u.length,s.valueToDrawRatio=1/s.drawToValueRatio,null!=u.ticks&&void 0===u.labels&&(u.labels={}),s.setColor(u.color),s.ticks=[],s.grid=[],s.labels=[],s.showAxis&&null!=u.line&&!1!==u.line&&s.addLine(u.line),s.showAxis&&null!=u.ticks&&!1!==u.ticks&&s.addTicks(u.ticks,"ticks"),s.showAxis&&null!=u.labels&&!1!==u.labels&&s.addLabels(u.labels),s.showAxis&&null!=u.title&&s.addTitle(u.title),s.showAxis&&null!=u.grid&&!1!==u.grid&&s.addTicks(u.grid,"grid"),s.reorder(),s}return t=[{key:"addLine",value:function(t){var e=t;t=ct({},{length:this.length,angle:this.angle,width:this.collections.primitives.defaultLineWidth,color:this.color},e=!0===t?{}:e),e=this.collections.primitives.line(t),this.line=t,this.add("line",e)}},{key:"reorder",value:function(){var t=[],e=[],n=[];this.drawOrder.forEach((function(i){i.startsWith("grid")&&t.push(i),i.startsWith("tick")&&e.push(i),i.startsWith("line")&&n.push(i)})),e=e.reverse(),t=t.reverse(),this.toBack(e),this.toBack(n),this.toBack(t)}},{key:"processTicks",value:function(t,e,n){var i,r,o=this.startValue,a=this.stopValue;return null!=e.start&&(o=e.start),null!=e.stop&&(a=e.stop),null!=e.step&&(i=e.step),null!=e.values&&(r=e.values),"grid"===t&&this.ticks.length>=n+1&&(null==e.start&&(o=this.ticks[n].start),null==e.stop&&(a=this.ticks[n].stop),null==e.step&&(i=this.ticks[n].step),null==e.values&&(r=this.ticks[n].values)),null==i&&null!=this.autoStep&&this.autoStep<(a-o)/2?i=this.autoStep:null==i&&0===n?i=(a-o)/5:null==i&&(i=this[t].step/2),{start:o,stop:a,step:i,values:r}}},{key:"addTicks",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"ticks",i=t;!0===t&&(i={});var r={width:null!=this.line?this.line.width:this.collections.primitives.defaultLineWidth,length:"ticks"===n?10*this.collections.primitives.defaultLineWidth:50*this.collections.primitives.defaultLineWidth,angle:this.angle+Math.PI/2,color:this.color};i=Array.isArray(i)?i:[i],this[n]=[];var o=[],a="x"===this.axis?1:-1;i.forEach((function(t,i){var s=ct({},r,t),l=(u=e.processTicks(n,s,i)).start,u=(t=u.stop,i=u.step,u.values);s.start=l,s.stop=t,s.step=i,s.length*=a,null==s.offset&&"ticks"===n?s.offset="x"===e.axis?-s.length/2:s.length/2:null==s.offset&&"grid"===n&&(c=e.transform.t()||new pe(0,0),"x"===e.axis?s.offset=-c.y:s.offset=-c.x);var c=Math.floor((s.stop+s.step/1e4-s.start)/s.step);s.num=c,s.values=null==u?A(s.start,s.stop,s.step):u,"x"===e.axis?s.copy=[{to:s.values.map((function(t){return new pe(e.valueToDraw(t),0)}))}]:s.copy=[{to:s.values.map((function(t){return new pe(0,e.valueToDraw(t))}))}],s.copy[0].original=!1,null==s.p1&&(s.p1=new pe(0,s.offset*a).rotate(e.angle)),u=e.collections.primitives.line(s),o.push(u),e[n].push(s)})),o.reverse(),o.forEach((function(t,i){e.add("".concat(n).concat(i),t)}))}},{key:"addTitle",value:function(t){var e={font:ct({},this.defaultFont,{size:this.defaultFont.size||.13}),justify:"center",xAlign:"center",yAlign:"x"===this.axis?"top":"bottom",rotation:"x"===this.axis?0:Math.PI/2,offset:[0,0]};(e=ct({},e,"string"==typeof t?{text:[t]}:t)).offset=ue(e.offset),t=this.getBoundingRect("draw"),null==e.position&&("x"===this.axis?e.position=new pe(this.length/2,t.bottom-e.font.size/1.5).add(e.offset):e.position=new pe(t.left-e.font.size/1.5,this.length/2).add(e.offset)),(t=this.collections.primitives.textLines(e)).transform.updateRotation(e.rotation),this.add("title",t)}},{key:"addLabels",value:function(t){var e=this,n=t;!0===t&&(n={});var i={text:null,precision:1,values:null,format:"decimal",font:this.defaultFont,xAlign:"x"===this.axis?"center":"right",yAlign:"x"===this.axis?"baseline":"middle",rotation:0};n=Array.isArray(n)?n:[n],this.labels=[];var r=this.getBoundingRect("draw");n.forEach((function(t,n){var o=ct({},i,t);"number"==typeof o.hide&&(o.hide=[o.hide]),"number"==typeof o.values&&(o.values=[o.values]),o.offset=ue(o.offset),"string"==typeof o.text&&(o.text=[o.text]);var a=[];null==(a=(null==o.values&&0<e.ticks.length?e.ticks[n]:o).values)&&(a=[]),null==o.text&&(o.text=[],o.text=Array(a.length).map((function(){return null}))),null==o.space&&(o.space="x"===e.axis?o.font.size+5*e.collections.primitives.defaultLineWidth:10*e.collections.primitives.defaultLineWidth);for(var s=[],l=0;l<a.length;l+=1){var u=e.valueToDraw(a[l]),c=("x"===e.axis?new pe(u+o.offset.x,r.bottom-o.space+o.offset.y):new pe(r.left+o.offset.x-o.space,u+o.offset.y)).rotate(-o.rotation);(null==o.hide||null!=o.hide&&-1===o.hide.indexOf(l))&&("number"==typeof(u=null==(u=o.text[l])?a[l]:u)&&(u="decimal"===o.format?"".concat(d(u,o.precision).toFixed(o.precision)):"".concat(u.toExponential(o.precision))),s.push({text:u,location:c}))}o.text=s,(t=e.collections.primitives.text(o)).transform.updateRotation(o.rotation),e.add("labels".concat(n),t),e.labels.push(o)}))}},{key:"calcAuto",value:function(t){var e=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(n,i)||function(t,e){if(t){if("string"==typeof t)return hh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?hh(t,e):void 0}}(n,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=e[0],i=e[1];0===(e=(t=i-n)<1?Math.floor(Math.log10(t)):1<=t&&t<3?Math.floor(Math.log10(t/3)):Math.ceil(Math.log10(t)))&&(e=1),t=Math.pow(10,e-1),n=Math.floor(n/t)*t;var r,o=(i=Math.ceil(i/t)*t)-n;switch(d(o/t)){case 3:case 6:r=o/3;break;case 4:case 8:r=o/4;break;case 7:r=o/7;break;case 9:r=o/3;break;default:r=o/5}return e<(t=0)&&(t=Math.abs(e)+1),{start:d(n),stop:d(i),step:d(r),precision:d(t)}}},{key:"valueToDraw",value:function(t){var e=this;return"number"==typeof t?(t-this.startValue)*this.valueToDrawRatio:t.map((function(t){return(t-e.startValue)*e.valueToDrawRatio}))}},{key:"drawToValue",value:function(t){var e=this;return"number"==typeof t?t*this.drawToValueRatio+this.startValue:t.map((function(t){return t*e.drawToValueRatio+e.startValue}))}},{key:"inAxis",value:function(t){return!((t=d(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8))<this.startValue||t>this.stopValue)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function mh(t){return(mh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function yh(t){return function(t){if(Array.isArray(t))return vh(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return vh(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?vh(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function gh(t,e,n){return(gh="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=wh(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function bh(t,e){return(bh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function wh(t){return(wh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const xh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&bh(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=wh(e);return function(t,e){if(e&&("object"===mh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=wh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var n=ct({},{color:t.primitives.defaultColor,font:{family:"Times New Roman",size:.1,style:"normal",weight:"normal",color:t.primitives.defaultColor,opacity:1},name:"",transform:new Ee("Trace").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},e);return null==n.markers&&void 0===n.line&&(n.line={}),(e=i.call(this,n)).collections=t,e.defaultFont=n.font,e.points=ce(n.points),e.xAxis=n.xAxis,e.yAxis=n.yAxis,e.name=n.name,e.setColor(n.color),null==n.xSampleDistance&&(n.xSampleDistance=(e.xAxis.stopValue-e.xAxis.startValue)/4e3),null==n.ySampleDistance&&(n.ySampleDistance=(e.yAxis.stopValue-e.yAxis.startValue)/4e3),e.xSampleDistance=n.xSampleDistance,e.ySampleDistance=n.ySampleDistance,null!=n.line&&e.addLine(n.line),null!=n.markers&&e.addMarkers(n.markers),e}return t=[{key:"update",value:function(t){this.removeLine(),this.removeMarkers(),this.points=ce(t),null!=this.line&&this.addLine(this.line),null!=this.markers&&(this.markers.copy=[],this.addMarkers(this.markers))}},{key:"getY",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=[],i=Math.abs(t-this.points[0].x),r=0,o=0;o<this.points.length;o+=1){var a=this.points[o].x;(a=Math.abs(a-t))<i&&(r=o,i=a),0===d(a,e)&&n.push(this.points[o].y)}return 0===n.length&&n.push(this.points[r].y),n}},{key:"getX",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=[],i=Math.abs(t-this.points[0].y),r=0,o=0;o<this.points.length;o+=1){var a=this.points[o].y;(a=Math.abs(a-t))<i&&(r=o,i=a),0===d(a,e)&&n.push(this.points[o].x)}return 0===n.length&&n.push(this.points[r].x),n}},{key:"pointToDraw",value:function(t){return new pe(this.xAxis.valueToDraw(t.x),this.yAxis.valueToDraw(t.y))}},{key:"inAxes",value:function(t){return!(!this.xAxis.inAxis(t.x)||!this.yAxis.inAxis(t.y))}},{key:"intersect",value:function(t,e){if(t.x<0&&e.x<0)return{result:!1};if(t.y<0&&e.y<0)return{result:!1};if(t.x>this.xAxis.length&&e.x>this.xAxis.length)return{result:!1};if(t.y>this.yAxis.length&&e.y>this.yAxis.length)return{result:!1};var n=new Se(t,e),i=!1,r=[];return[new Se([0,0],[0,this.yAxis.length]),new Se([this.xAxis.length,0],[this.xAxis.length,this.yAxis.length]),new Se([0,0],[this.xAxis.length,0]),new Se([0,this.yAxis.length],[this.xAxis.length,this.yAxis.length])].forEach((function(t){(t=n.intersectsWith(t)).withinLine&&(i=!0,r.push(t.intersect))})),{result:i,intersect:r}}},{key:"updatePoints",value:function(){this.polylines=[];var t,e=!(this.drawPoints=[]);null!=this.xSampleDistance&&null!=this.ySampleDistance&&(e=!0);for(var n=[],i=0;i<this.points.length;i+=1)(!e||null==t||Math.abs(this.points[i].x-t.x)>=this.xSampleDistance||Math.abs(this.points[i].y-t.y)>=this.ySampleDistance)&&(this.drawPoints.push(this.pointToDraw(this.points[i])),t=this.points[i],n.push(i));for(var r=[],o=[],a=0;a<n.length;a+=1)r.push(this.xAxis.inAxis(this.points[n[a]].x)),o.push(this.yAxis.inAxis(this.points[n[a]].y));for(var s,l,u=!1,c=[],h=0;h<this.drawPoints.length;h+=1)r[h]&&o[h]&&(u=!0,c.push(this.drawPoints[h])),u&&h===this.drawPoints.length-1?(this.polylines.push(c),c=[]):u&&r[h+1]&&o[h+1]||(!u||!1!==r[h+1]&&!1!==o[h+1]?!1===u&&r[h+1]&&o[h+1]?(s=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&c.push.apply(c,yh(s.intersect)):!1===u&&h<this.drawPoints.length-1&&(l=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&this.polylines.push(l.intersect.map((function(t){return t._dup()}))):((l=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&c.push.apply(c,yh(l.intersect)),this.polylines.push(c),u=!(c=[])))}},{key:"addLine",value:function(t){var e=this,n={color:this.color,width:this.collections.primitives.defaultLineWidth};this.updatePoints(),this.line=ct({},n,t),this.polylines.forEach((function(t,n){t=e.collections.primitives.polyline(ct({},e.line,{points:t})),e.add("line".concat(n),t)}))}},{key:"removeLine",value:function(){var t=this;this.drawOrder.filter((function(t){return t.startsWith("line")})).forEach((function(e){t.remove(e)}))}},{key:"removeMarkers",value:function(){var t=this;this.drawOrder.filter((function(t){return t.startsWith("markers")})).forEach((function(e){t.remove(e)}))}},{key:"addMarkers",value:function(t){var e=this,n={radius:.02,color:this.color},i=this.points.filter((function(t){return e.inAxes(t)}));t=ct({},n,t),this.markers=t,0!==i.length&&(null==t.copy?t.copy=[]:!1===Array.isArray(t.copy)&&(t.copy=[t.copy]),t.copy.push({to:i.map((function(t){return e.pointToDraw(t)})),original:!1}),this.add("markers",this.collections.primitives.polygon(t)))}},{key:"_getStateProperties",value:function(t){return yh(gh(wh(r.prototype),"_getStateProperties",this).call(this,t))}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Sh(t){return(Sh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Th(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ah(t,e){return(Ah=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function kh(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Oh(t){return(Oh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const _h=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ah(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Oh(e);return function(t,e){if(e&&("object"===Sh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return kh(t)}(this,n?(t=Oh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var n={font:t.primitives.defaultFont,color:t.primitives.defaultColor,theme:"classic",width:t.primitives.limits.width/3,height:t.primitives.limits.width/3,grid:[],xAlign:"plotAreaLeft",yAlign:"plotAreaBottom",limits:t.primitives.limits,transform:new Ee("Plot").scale(1,1).rotate(0).translate(0,0),touchBorder:"rect"};null!=e.color&&(null==e.font||null!=e.font&&null==e.font.color)&&(n.font.color=e.color);var o,a=ct({},n,e);return null==a.stop&&(a.stop=a.start+1),(n=i.call(this,a)).collections=t,n.defaultFont=a.font,n.defaultColor=a.color,n.width=a.width,n.height=a.height,n.theme=a.theme,n.grid=a.grid,!(n.xAxisShow=!0)===a.xAxis&&(n.xAxisShow=!1),!(n.yAxisShow=!0)===a.yAxis&&(n.yAxisShow=!1),null!=e.font&&null!=e.font.size||(n.defaultFont.size=Math.min(n.width,n.height)/20),n.setColor(a.color),n.axes=[],n.traces=[],e=(t=function(t){if(Array.isArray(t))return t}(o=function(t){var e=[];Array.isArray(t)?0===t.length?e=[]:le(t[0])instanceof pe?e=[{points:t}]:t.forEach((function(t){Array.isArray(t)?e.push({points:t}):e.push(t)})):e=[t];var n=!0,i={min:new pe(0,0),max:new pe(0,0)};return e.forEach((function(t){for(var e=0;e<t.points.length;e+=1){var r=ue(t.points[e]);i=je(r,i.min,i.max,n),n=!1}})),t=new fe(i.min.x,i.min.y,i.max.x-i.min.x,i.max.y-i.min.y),[e,t]}(a.trace))||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,i,r=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(r.push(n.value),2!==r.length);o=!0);}catch(t){a=!0,i=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw i}}return r}}(o)||function(t){if(t){if("string"==typeof t)return Th(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Th(t,2):void 0}}(o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],t=t[1],null!=a.frame&&!1!==a.frame&&n.addFrame(a.frame),null!=a.plotArea&&!1!==a.plotArea&&n.addPlotArea(a.plotArea),n.addAxes([ct({},{axis:"x",name:"x",auto:[t.left,t.right]},null!=a.xAxis?a.xAxis:{})]),n.addAxes([ct({},{axis:"y",name:"y",auto:[t.bottom,t.top]},null!=a.yAxis?a.yAxis:{})]),null!=a.axes&&n.addAxes(a.axes),null!=a.trace&&n.addTraces(e),null!=a.title&&n.addTitle(a.title),null!=a.legend&&!1!==a.legend&&n.addLegend(a.legend),null!=n.__frame&&null!=n.frameSpace&&n.__frame.surround(kh(n),n.frameSpace),n}return t=[{key:"getNonTraceBoundingRect",value:function(){var t=[];return Object.keys(this.elements).forEach((function(e){e.startsWith("trace")||t.push(e)})),this.getBoundingRect("draw","border",t)}},{key:"addAxes",value:function(t){var e=this,n={color:this.defaultColor,font:this.defaultFont,type:"x"};t.forEach((function(t){null!=t.axis?r=t.axis:null!=n.axis&&(r=n.axis),n.length="x"===r?e.width:e.height;var i=e.getTheme(e.theme,r,t.color),r="x"===r?e.xAxisShow:e.yAxisShow;n.show=r;var o=ct({},n,i.axis,t);if(Array.isArray(o.grid))for(var a=0;a<o.grid.length;a+=1)o.grid[a]=ct({},i.axis.grid,o.grid[a]);if(Array.isArray(o.ticks))for(var s=0;s<o.ticks.length;s+=1)o.ticks[s]=ct({},i.axis.ticks,o.ticks[s]);null==o.name&&(o.name="axis_".concat(e.axes.length)),t=e.collections.axis(o),e.add(o.name,t),e.axes.push(t)}))}},{key:"addPlotArea",value:function(t){var e={width:this.width,height:this.height,xAlign:"left",yAlign:"bottom",position:[0,0]};t=Array.isArray(t)?(e.fill=t,e):ct({},e,t),this.add("_plotArea",this.collections.rectangle(t))}},{key:"addFrame",value:function(t){var e={width:this.width/2,height:this.height/2,xAlign:"left",yAlign:"bottom",position:[0,0],space:Math.min(this.width,this.height)/20};!0===t?t={line:{width:this.collections.primitives.defaultLineWidth}}:Array.isArray(t)&&(t={fill:t}),t=ct({},e,t),this.frameSpace=t.space,this.add("_frame",this.collections.rectangle(t))}},{key:"getTraceIndex",value:function(t){if("number"==typeof t)return t;for(var e=0;e<this.traces.length;e+=1)if(t===this.traces[e].name)return e;return-1}},{key:"addLegend",value:function(t){t=!0===t?{}:t,t=ct({},{traces:this.traces,lineTextSpace:this.width/50,length:this.width/10,position:[this.width+this.width/20,this.height]},this.getTheme(this.theme).legend,t),t=this.collections.plotLegend(t),this.add("_legend",t)}},{key:"getAxis",value:function(t){for(var e=0;e<this.axes.length;e+=1)if(this.axes[e].name===t)return this.axes[e];return null}},{key:"getXAxis",value:function(){for(var t=0;t<this.axes.length;t+=1)if("x"===this.axes[t].axis)return this.axes[t];return null}},{key:"getYAxis",value:function(){for(var t=0;t<this.axes.length;t+=1)if("y"===this.axes[t].axis)return this.axes[t];return null}},{key:"pointToDraw",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"y";return e=this.getAxis(e),n=this.getAxis(n),null==e||null==n?null:(t=ue(t),new pe(e.valueToDraw(t.x),n.valueToDraw(t.y)))}},{key:"drawToPoint",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"y";return e=this.getAxis(e),n=this.getAxis(n),null==e||null==n?null:(t=ue(t),new pe(e.drawToValue(t.x),n.drawToValue(t.y)))}},{key:"addTraces",value:function(t){var e=this,n=this.getTheme(this.theme);t.forEach((function(t,i){null==(t=ct({},{xAxis:"x",yAxis:"y",color:n.traceColors[i%n.traceColors.length]},t)).name&&(t.name="trace_".concat(i)),t.xAxis=e.getAxis(t.xAxis),t.yAxis=e.getAxis(t.yAxis),i=e.collections.trace(t),e.add(t.name,i),e.traces.push(i)}))}},{key:"getTheme",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i="x"===e?this.width:this.height,r="x"===e?this.height:this.width,o={};return"classic"===t&&(e=null==n?[.35,.35,.35,1]:n,t=Math.min(this.width,this.height)/30,n=this.collections.primitives.defaultLineWidth,o={axis:{color:e,line:{width:this.collections.primitives.defaultLineWidth},ticks:{width:this.collections.primitives.defaultLineWidth,length:t,offset:-t},font:{color:e},length:i,grid:{color:e,width:this.collections.primitives.defaultLineWidth/2,length:r,dash:[n,n]}},title:{font:{color:e}},legend:{color:e,font:{color:e}},traceColors:[[0,0,1,1],[1,0,0,1],[0,.7,0,1],[.8,.8,.2,1],[.2,.8,.8,1],[.8,.2,.8,1]]}),null!=o.axis&&null!=o.axis.grid&&(!1===this.grid?delete o.axis.grid:"object"!==Sh(this.grid)&&!Array.isArray(this.grid)||(o.axis.grid=ct({},o.axis.grid,this.grid))),o}},{key:"addTitle",value:function(t){var e={font:ct({},this.defaultFont,{size:1.5*this.defaultFont.size}),justify:"center",xAlign:"center",yAlign:"bottom",offset:[0,0]};t="string"==typeof t?{text:[t]}:t,(e=ct({},e,this.getTheme(this.theme).title,t)).offset=ue(e.offset),t=this.getNonTraceBoundingRect(),null==e.position&&(e.position=new pe(this.width/2+e.offset.x,t.top+.5*e.font.size+e.offset.y)),e=this.collections.primitives.textLines(e),this.add("title",e)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function Ph(t){return(Ph="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Eh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Mh(t,e){return(Mh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Bh(t){return(Bh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Ch=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Mh(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Bh(e);return function(t,e){if(e&&("object"===Ph(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Bh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var n=ct({},{font:t.primitives.defaultFont,color:t.primitives.defaultColor,fontColorIsLineColor:!1,frame:!1,custom:{},length:t.primitives.defaultLength/10,space:.05,position:new pe(0,0),transform:new Ee("PlotLegend").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},e);return(e=i.call(this,n)).setPosition(0,0),e.collections=t,e.defaultFont=n.font,e.defaultColor=n.color,e.traces=n.traces,e.toShow=e.getTracesToShow(n),e.offset=e.getOffset(n),e.addTraces(n),null!=n.frame&&!1!==n.frame&&(e.addFrame(n.frame),e.toBack("frame")),e}return t=[{key:"getTraceIndex",value:function(t){if("number"==typeof t)return t;for(var e=0;e<this.traces.length;e+=1)if(t===this.traces[e].name)return e;return-1}},{key:"getTracesToShow",value:function(t){var e,n,i=this,r=function(t){if(Array.isArray(t))return Eh(t)}(n=Array(this.traces.length).keys())||function(){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}()||function(t){if(t){if("string"==typeof t)return Eh(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Eh(t,void 0):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();return t.show&&(r=[],(e="number"==typeof(e=t.show)?[e]:e).forEach((function(t){-1!==(t=i.getTraceIndex(t))&&r.push(t)}))),t.hide&&(t="number"==typeof(t=t.hide)?[t]:t).forEach((function(t){-1!==(t=i.getTraceIndex(t))&&-1!==r.indexOf(t)&&r.splice(t,1)})),r}},{key:"getOffset",value:function(t){for(var e=[],n=ce(n=null==(n=t.offset)?[new pe(0,1.5*-this.defaultFont.size)]:n),i=0;i<this.toShow.length;i+=1)e.push(n[i%n.length]._dup());return e}},{key:"addTraces",value:function(t){var e=this,n=new pe(0,0);this.toShow.forEach((function(i,r){var o=e.traces[i],a={};null!=t.custom["".concat(r)]?a=t.custom["".concat(r)]:null!=t.custom[o.name]&&(a=t.custom[o.name]),0===r&&null==a.position&&(a.position=ue(t.position||[0,0]));var s=ct({},{length:t.length,font:t.font,fontColorIsLineColor:t.fontColorIsLineColor,offset:e.offset[r],space:t.space,text:o.name},a);n=null!=s.position?ue(s.position):n.add(ue(s.offset)),0<s.length&&null!=o.line&&(r=ct({},o.line,{p1:n,length:s.length,angle:0}),r=e.collections.primitives.line(r),e.add("line".concat(i),r)),0<s.length&&null!=o.markers&&(l=ct({},o.markers,{position:new pe(n.x+s.length/2,n.y),copy:o.markers.copy.slice(0,-1)}),u=e.collections.primitives.polygon(l),e.add("marker".concat(i),u));var l={font:e.defaultFont,justify:"center",xAlign:"left",yAlign:"middle",position:new pe(n.x+s.length+s.space,n.y)};null!=a.font&&(l.font=ct({},l.font,a.font));var u=s.text;"string"==typeof s.text&&(u={text:[s.text]}),"string"==typeof a.text&&(a.text={text:[a.text]}),s={},a=ct({},l,s=t.fontColorIsLineColor?{font:{color:o.color.slice()}}:s,u,a.text),a=e.collections.primitives.textLines(a),e.add("trace".concat(i),a)}))}},{key:"addFrame",value:function(t){var e=t;!0===t?e={}:Array.isArray(t)&&(e={fill:t});var n={space:this.defaultFont.size};null==t.line&&null==t.fill&&(n.line={width:.01}),null!=(n=ct({},n,e)).line&&null==n.line.color&&(n.line.color=this.defaultColor.slice()),(e=this.collections.rectangle(n)).surround(this,n.space),this.add("frame",e)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function jh(t){return(jh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Rh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Fh(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fh(t,e){if(t){if("string"==typeof t)return Dh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dh(t,e):void 0}}function Dh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ih(t,e,n){return(Ih="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=zh(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Lh(t,e){return(Lh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Wh(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function zh(t){return(zh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Nh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Lh(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=zh(e);return function(t,e){if(e&&("object"===jh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Wh(t)}(this,n?(t=zh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){var n;return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),null==(e=ct({},{width:t.primitives.defaultLength,height:t.primitives.defaultLength/2,xAlign:"center",yAlign:"middle",color:t.primitives.defaultColor,border:"children",touchBorder:"border",holeBorder:[[]],corner:{radius:0,sides:1},transform:new Ee("Rectangle").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits},e)).fill&&null==e.line&&(e.fill=t.primitives.defaultColor.slice()),(n=i.call(this,e)).collections=t,n._line=null,n._fill=null,n._label=null,n.width=e.width,n.height=e.height,n.xAlign=e.xAlign,n.yAlign=e.yAlign,n.border=e.border,n.touchBorder=e.touchBorder,n.holeBorder=e.holeBorder,n.corner=e.corner,n.labelOffset=new pe(0,0),n.stateProperties=["width","height","xAlign","yAlign"],n.setColor(e.color),null!=e.fill&&n.addRect(e.fill,"fill",!0),null!=e.line&&n.addRect(e.line,"line",!1),null!=e.label&&n.addlabel(e.label),e.button&&n.addButtonBehavior(e.button),n.setPositions(),n.animations.surround=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var r,o,a,s,l,u,c,h,f=ct.apply(void 0,[{},{element:Wh(n),space:0}].concat(e)),d=!0;return f.callback=function(t){d&&(a=null==f.start?(r=n.getPosition("local"),o=n.width,n.height):(e=Rh(n.getSurround(f.start,f.space),3),r=e[0],o=e[1],e[2]),h=null==f.target?(s=n.getPosition("local"),l=n.width,n.height):(i=Rh(n.getSurround(f.target,f.space),3),s=i[0],l=i[1],i[2]),u=s.sub(r),c=l-o,h-=a,d=!1);var e=o+c*t,i=a+h*t;t=r.add(u.scale(t)),n.setSurround(t,e,i)},f.timeKeeper=n.timeKeeper,new go(f)},n.animations.customSteps.push({step:n.animations.surround.bind(Wh(n)),name:"surround"}),n}return t=[{key:"addButtonBehavior",value:function(t){function e(e){var i,r,o=n.elements[e];null!=o&&(i=o.color.slice(),Array.isArray(t)?r=t.slice():!0!==t&&null!=t[e]&&(r=t[e].slice()),o.animations.new().trigger({callback:function(){null==r?o.opacity=.8:o.setColor(r)},duration:.1}).trigger({callback:function(){null==r?o.opacity=1:o.setColor(i)}}).ifCanceledThenComplete().start())}var n=this;this.notifications.add("onClick",(function(){e("line"),e("fill"),e("label")}))}},{key:"addRect",value:function(t,e,n){var i={width:this.width,height:this.height,xAlign:"center",yAlign:"middle",color:this.color,corner:this.corner};n||(i.line={widthIs:"inside",cornerStyle:"auto",width:Math.max(Math.min(this.width,this.height)/100,this.collections.primitives.defaultLineWidth)},(i.line.width>this.width||i.line.width>this.height)&&(i.line.widthIs="mid")),t=ct({},i,n?Array.isArray(t)?{color:t}:{texture:t}:{line:t}),this[e]=t,t=this.collections.primitives.rectangle(t),this.add(e,t)}},{key:"setPositions",value:function(){var t=this.width,e=this.height,n=new pe(0,0);"left"===this.xAlign?n.x+=t/2:"right"===this.xAlign?n.x-=t/2:"number"==typeof this.xAlign&&(n.x=n.x+t/2-this.xAlign*t),"bottom"===this.yAlign?n.y+=e/2:"top"===this.yAlign?n.y-=e/2:"number"==typeof this.yAlign&&(n.y=n.y+e/2-e*this.yAlign);var i=this._line;t=this._fill,e=this._label,i&&i.setPosition(n),t&&t.setPosition(n),e&&e.setPosition(n.add(this.labelOffset))}},{key:"addlabel",value:function(t){var e={font:ct({},this.collections.primitives.defaultFont),xAlign:"center",yAlign:"baseline",justify:"center",color:this.color};e.font.size=.4*this.height,e.font.color=this.color,t=ct({},e,"string"==typeof t?{text:t}:t),this.labelOffset=new pe(0,-t.font.size/2.5),t=this.collections.primitives.textLines(t),this.add("label",t)}},{key:"getSurround",value:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=Array.isArray(t)?(e=[],t.forEach((function(t){var n;t=t.getBorder("figure"),e.push.apply(e,function(t){if(Array.isArray(t))return Dh(t)}(n=t)||function(){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}()||Fh(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})),Ie(e,n)):Ie(t.getBorder("figure"),n);return t=this.spaceTransformMatrix("figure","draw")[0],n=i.width*t,t=i.height*t,i=new pe(i.left+i.width/2,i.bottom+i.height/2).transformBy(this.spaceTransformMatrix("figure","local")),"left"===this.xAlign?i.x-=n/2:"right"===this.xAlign?i.x+=n/2:"number"==typeof this.xAlign&&(i.x=i.x-n/2+this.xAlign*n),"bottom"===this.yAlign?i.y-=t/2:"top"===this.yAlign?i.y+=t/2:"number"==typeof this.yAlign&&(i.y=i.y-t/2+t*this.yAlign),[i,n,t]}},{key:"surround",value:function(t){var e=(n=Rh(this.getSurround(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),3))[0],n=(t=n[1],n[2]);this.setSurround(e,t,n)}},{key:"setSurround",value:function(t,e,n){this.width=e,this.height=n,this._line&&this._line.custom.updatePoints({width:e,height:n}),this._fill&&this._fill.custom.updatePoints({width:e,height:n}),this.setPositions(),this.setPosition(t)}},{key:"stateSet",value:function(){Ih(zh(r.prototype),"stateSet",this).call(this);var t=this.width,e=this.height;this._line&&this._line.custom.updatePoints({width:t,height:e}),this._fill&&this._fill.custom.updatePoints({width:t,height:e}),this.setPositions()}},{key:"setLabel",value:function(t){null!=this._label&&this._label.custom.updateText("string"==typeof t?{text:t}:t),this.animateNextFrame()}},{key:"getLabel",value:function(){return null!=this._label?this._label.drawingObject.text[0].text:""}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();function qh(t){return(qh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Hh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||Kh(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kh(t,e){if(t){if("string"==typeof t)return Uh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Uh(t,e):void 0}}function Uh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var Vh=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.notifications=new jt,this.inTransition=!1,this.fromAutoSlide=!1,this.disableButtonOpacity=.7,null!=e&&this.load(e)}var e=[{key:"load",value:function(t){var e=this,n=t;if(n.collection instanceof rs?this.collection=n.collection:null!=n.collection&&null!=n.collection.elements&&(this.collection=n.collection.elements),this.collection.recorder.addEventType("slide",(function(t){t=(n=Hh(t,2))[0];var n=n[1];"prev"===t&&e.currentSlideIndex===n-1?e.nextSlide(!0):"prev"===t?(e.goToSlide(n-1),e.nextSlide(!0)):"next"===t&&e.currentSlideIndex===n+1?e.prevSlide():e.goToSlide(n)}),!0),this.collection.recorder.addEventType("_autoSlide",(function(t){t=Hh(t,1)[0],e.fromAutoSlide=!0,e.currentSlideIndex===t-1?e.nextSlide(!0):e.goToSlide(t)}),!0),null==this.collection.fnMap.global.map.slideNavigatorTransitionDone)this.slideTransitionDoneName="slideNavigatorTransitionDone";else{for(var i=0;null!=this.collection.fnMap.global.map["slideNavigatorTransitionDone".concat(i)];)i+=1;this.slideTransitionDoneName="slideNavigatorTransitionDone".concat(i)}this.collection.fnMap.global.add(this.slideTransitionDoneName,this.transitionDone.bind(this)),this.from="prev",null!=n.slides&&(this.slides=n.slides),"string"==typeof n.text?this.textElement=this.collection.getElement(n.text):null!=n.text?this.textElement=n.text:this.textElement=null,t=[],Array.isArray(n.equation)?t=n.equation:null!=n.equation&&(t=[n.equation]),this.setEquations(t),this.equationDefaults=ct({},{duration:1,animate:"move"},n.equationDefaults||{}),n.prevButton&&(this.prevButton=this.collection.getElement(n.prevButton)),n.nextButton&&(this.nextButton=this.collection.getElement(n.nextButton)),this.currentSlideIndex=0,this.inTransition=!1,t=this.prevButton,n=this.nextButton,null!=t&&(t.onClick=this.prevSlide.bind(this)),null!=n&&(n.onClick=this.nextSlide.bind(this,!1)),null!=this.slides||1!==this.equationsOrder.length||(n=Hh(this.equationsOrder,1)[0])instanceof Cc&&null!=(n=n.eqn).currentFormSeries&&0<n.currentFormSeries.length&&(this.slides=[],n.currentFormSeries.forEach((function(t){return e.slides.push({form:"".concat(t)})}))),this.loadRecorder()}},{key:"convertTime",value:function(t){var e;return"string"==typeof t?(e=t.split(":"),60*parseInt(e[0],10)+parseFloat(e[1])):t}},{key:"loadRecorder",value:function(){var t,e=this;null!=this.slides&&0!==this.slides.length&&(t=0,this.slides.forEach((function(n,i){var r=n.time,o=n.delta;n=n.execDelta,null!=r||0===i?(r=e.convertTime(r||0),e.collection.recorder.events._autoSlide.list.push([r,[i],0]),t=r):null!=o&&(t+=o,e.collection.recorder.events._autoSlide.list.push([t,[i],0])),null!=n&&0<n.length&&(n=Array.isArray(n[0])?n:[n]).forEach((function(n){var i=Hh(n,2),r=i[0];if(n=i[1],"number"!=typeof(i=t+r))throw new Error("Error in delta time: ".concat(i,", ").concat(r,", $ // $FlowFixMe{lastTime}, ").concat(n));e.collection.recorder.events._autoExec.list.push([i,[n],0])}))})),this.slides.forEach((function(t){null!=(t=t.exec)&&0!==t.length&&(t=Array.isArray(t[0])?t:[t]).forEach((function(t){var n=Hh(t,2),i=n[0];if(t=n[1],"number"!=typeof(n=e.convertTime(i)))throw new Error("Error in exec time: ".concat(n,", ").concat(i,", ").concat(t));e.collection.recorder.events._autoExec.list.push([n,[t],0])}))})),this.collection.recorder.events._autoExec.list.sort((function(t,e){return t[0]-e[0]})))}},{key:"loadSlides",value:function(t){this.slides=t,this.loadRecorder(),this.goToSlide(0)}},{key:"setEquations",value:function(t){var e=this,n={},i=[];t.forEach((function(t){null!=(t=e.collection.getElement(t))&&(i.push(t),n[t.name]=t)})),this.equations=n,this.equationsOrder=i}},{key:"getProperty",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=e,r=this.slides[i][t];if(this.slides[i].clear)return void 0===r?n:r;for(;void 0===r&&0<i;)if(r=this.slides[--i][t],this.slides[i].clear)return void 0===r?n:r;return void 0===r?n:r}},{key:"getText",value:function(t){return this.getProperty("text",t,"")}},{key:"getForm",value:function(t){return this.getFormGeneric("form",t)}},{key:"getFormGeneric",value:function(t,e){var n=this;if(void 0===(e="form"===t?this.getProperty("form",e,null):this.slides[e][t]))return{};if(Array.isArray(e)){var i={};return e.forEach((function(t,e){n.equationsOrder.length>e&&(i[n.equationsOrder[e].name]=t)})),i}return"string"!=typeof e&&null!==e?e:(t={},0<this.equationsOrder.length&&(t[this.equationsOrder[0].name]=e),t)}},{key:"getFromForm",value:function(t){return void 0===this.slides[t].fromForm?0===t||this.slides[t].clear?{}:this.getFormGeneric("form",t-1):this.getFormGeneric("fromForm",t)}},{key:"showForms",value:function(t){var e=this;Object.keys(t).forEach((function(n){var i=t[n];null!=(n=e.collection.getElement(n))&&(null==i?n.hide():n.showForm(i))}))}},{key:"setSteadyState",value:function(t){var e=this.currentSlideIndex,n=this.slides[e],i=this.getForm(e);this.showForms(i),null!=n.transition&&Array.isArray(n.transition)&&this.setFinalFromAutoTransition(n.transition),null!=n.transition&&"object"===qh(n.transition)&&this.setFinalFromAutoTransition([n.transition]),this.collection.fnMap.exec(this.getProperty("steadyStateCommon",e,(function(){})),t,e),null!=n.steadyState&&this.collection.fnMap.exec(n.steadyState,t,e),t=this.prevButton,e=this.nextButton,null!=t&&(0===this.currentSlideIndex?(t.setOpacity(this.disableButtonOpacity),t.isTouchable=!1):!1===t.isTouchable&&(t.setOpacity(1),t.isTouchable=!0)),null!=e&&null!=e.setLabel&&(this.currentSlideIndex===this.slides.length-1?e.setLabel("Restart"):e.setLabel("Next")),this.inTransition=!1,this.notifications.publish("steady")}},{key:"transitionDone",value:function(){"freeze"!==(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"complete")&&(this.setSteadyState(this.from),this.inTransition=!1)}},{key:"setFinalFromAutoTransition",value:function(t){var e=this;t.forEach((function(t){(t=Array.isArray(t)?t:[t]).forEach((function(t){!1!==t.final&&(e.processAutoTransitionSet(t,"in","showAll"),e.processAutoTransitionSet(t,"out","hide"),e.processAutoTransitionSet(t,"scenario","setScenario","target"),e.processAutoTransitionSet(t,"dim","dim"),e.processAutoTransitionSet(t,"undim","undim"),e.processAutoTransitionSet(t,"rotation","setRotation","target"),e.processAutoTransitionSet(t,"position","setPosition","target"),e.processAutoTransitionSet(t,"scale","setScale","target"))}))}))}},{key:"processAutoTransitionAnim",value:function(t,e){var n,i,r,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",a=3<arguments.length?arguments[3]:void 0,s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{};null!=t.trigger&&"trigger"===e?(n=ut({except:e},{callback:t.trigger},s,t),a.push(this.collection.animations[o](n))):null!=t[e]&&(n=this.collection.getElements(t[e]),i=ut({except:e},{},s,t),a.push.apply(a,function(t){if(Array.isArray(t))return Uh(t)}(r=n.map((function(t){return t.animations[o](i)})))||function(){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}()||Kh(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))}},{key:"processAutoTransitionSet",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";null!=t[e]&&(e=this.collection.getElements(t[e]),""!==i?e.map((function(e){return e[n](t[i])})):e.map((function(t){return t[n]()})))}},{key:"showAutoTransitionDissolve",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(null!=(t=this.slides[t]).transition&&"function"!=typeof t.transition)for(var i=t.transition,r=(i=Array.isArray(i)?i:[i]).length-1;0<=r;--r){var o=i[r];(Array.isArray(o)?o:[o]).forEach((function(t){n?null!=t.in?e.collection.getElements(t.in).map((function(t){return t.showAll()})):null!=t.out&&e.collection.getElements(t.out).map((function(t){return t.showAll()})):(null==t.out||null!=t.show&&!1===t.show||e.collection.getElements(t.out).map((function(t){return t.showAll()})),null==t.in||null!=t.show&&!0===t.show||e.collection.getElements(t.in).map((function(t){return t.hide()})))}))}}},{key:"autoTransition",value:function(t){var e=this,n=this.collection.animations.new();t.forEach((function(t){t=Array.isArray(t)?t:[t];var i=[];t.forEach((function(t){e.processAutoTransitionAnim(t,"in","dissolveIn",i,{duration:.5}),e.processAutoTransitionAnim(t,"out","dissolveOut",i,{duration:.5}),e.processAutoTransitionAnim(t,"rotation","rotation",i,{duration:2}),e.processAutoTransitionAnim(t,"position","position",i,{duration:2}),e.processAutoTransitionAnim(t,"scale","scale",i,{duration:2}),e.processAutoTransitionAnim(t,"scenario","scenario",i,{duration:2}),e.processAutoTransitionAnim(t,"scenarios","scenarios",i,{duration:2}),e.processAutoTransitionAnim(t,"pulseWidth","pulseWidth",i,{duration:1.5}),e.processAutoTransitionAnim(t,"length","length",i,{duration:1.5}),e.processAutoTransitionAnim(t,"pulseAngle","pulseAngle",i,{duration:1.5}),e.processAutoTransitionAnim(t,"pulse","pulse",i,{duration:1.5}),e.processAutoTransitionAnim(t,"dim","dim",i,{duration:1}),e.processAutoTransitionAnim(t,"undim","undim",i,{duration:1}),e.processAutoTransitionAnim(t,"trigger","trigger",i,{duration:0}),e.processAutoTransitionAnim(t,"goToForm","goToForm",i,{duration:1.5,animate:"move"}),1===Object.keys(t).length&&null!=t.delay&&i.push(e.collection.animations.delay({duration:t.delay}))})),1===i.length?n.then(i[0]):n.inParallel(i)})),n.whenFinished(this.slideTransitionDoneName).start()}},{key:"transition",value:function(t){var e=this;if(this.notifications.publish("beforeTransition"),"prev"!==(this.from=t))return this.transitionDone();this.inTransition=!0;var n=this.slides[this.currentSlideIndex];if("function"==typeof n.transition)return n.transition(this.slideTransitionDoneName,this.currentSlideIndex,t);if(null!=n.transition&&Array.isArray(n.transition))return this.autoTransition(n.transition);if(null!=n.transition&&"object"===qh(n.transition))return this.autoTransition([n.transition]);var i=this.getForm(this.currentSlideIndex),r=this.getFromForm(this.currentSlideIndex),o=this.slideTransitionDoneName;return Object.keys(r).forEach((function(t){var n,a=e.collection.getElement(e.equations[t]);null!=a&&a instanceof Cc&&void 0!==i[t]&&(n=r[t],t=i[t],null==n&&null!=t?(a.showForm(t),a.animations.new().dissolveIn(.4).whenFinished(o).start(),o=null):n!==t&&(a.animations.new().goToForm(ct({},{start:n,target:t},e.equationDefaults)).whenFinished(o).start(),o=null))})),null!=o?this.transitionDone():null}},{key:"setText",value:function(t){var e,n,i=this.textElement;null!=i&&(e=this.getProperty("modifiers",t,{}),n=this.getProperty("modifiersCommon",t,{}),t=this.getText(t)||" ",i.custom.updateText({text:t,modifiers:ct({},n,e)}))}},{key:"showElements",value:function(t){var e=this.getProperty("showCommon",t,[]);t=this.slides[t].show||[],this.collection.show(e),this.collection.show(t),null!=t&&Array.isArray(t)&&this.collection.show(),null!=this.nextButton&&this.nextButton.showAll(),null!=this.prevButton&&this.prevButton.showAll(),null!=this.textElement&&this.textElement.showAll()}},{key:"hideElements",value:function(t){var e=this.getProperty("hideCommon",t,[]);t=this.slides[t].hide||[],this.collection.hide(e),this.collection.hide(t)}},{key:"goToSlide",value:function(t){var e,n,i,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;this.notifications.publish("goToSlide",t),null!=this.slides&&0!==this.slides.length&&(e=t<0?this.slides.length-1:t,this.inTransition=!0,null==(n=r)&&(n=this.currentSlideIndex,e===this.currentSlideIndex+1?n="prev":e===this.currentSlideIndex-1&&(n="next")),"recording"===this.collection.recorder.state&&("next"===n||"prev"===n?!1===this.fromAutoSlide&&this.collection.recorder.recordEvent("slide",[n,e]):!1===this.fromAutoSlide&&this.collection.recorder.recordEvent("slide",["goTo",e]),this.fromAutoSlide=!1),this.getProperty("leaveStateCommon",this.currentSlideIndex,(function(){}))(this.currentSlideIndex,e),null!=this.slides[this.currentSlideIndex].leaveState&&this.collection.fnMap.exec(this.slides[this.currentSlideIndex].leaveState,this.currentSlideIndex,e),this.collection.stop("complete"),null!=(t=this.textElement)&&(this.setText(e),"prev"===n&&(i=this.getText(this.currentSlideIndex),r=this.getText(e),JSON.stringify(r)!==JSON.stringify(i)&&t.animations.new().dissolveIn(.2).start())),this.currentSlideIndex=e,i=this.slides[e],this.collection.hideAll(),this.showElements(e),this.hideElements(e),t=this.getFromForm(e),this.showForms(t),this.showAutoTransitionDissolve(e,!0),this.collection.setScenarios(this.getProperty("scenarioCommon",e,[])),this.collection.setScenarios(i.scenario||[]),this.collection.fnMap.exec(this.getProperty("enterStateCommon",e,(function(){})),n,e),null!=i.enterState&&this.collection.fnMap.exec(i.enterState,n,e),i.addReference&&"recording"===this.collection.recorder.state&&this.collection.recorder.addCurrentStateAsReference(),this.showAutoTransitionDissolve(e,!1),this.transition(n))}},{key:"nextSlide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=(this.currentSlideIndex+1)%this.slides.length;this.inTransition&&(this.inTransition=!1,this.collection.stop("complete"),!t)||(this.goToSlide(e,null),this.collection.animateNextFrame())}},{key:"prevSlide",value:function(){var t=this.currentSlideIndex-1;t<0&&(t=this.slides.length-1),this.collection.stop("complete"),this.goToSlide(t),this.collection.animateNextFrame()}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function Gh(t){return(Gh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Yh(t,e){return(Yh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Xh(t){return(Xh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const $h=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Yh(t,e)}(r,rs);var t,e,n,i=(e=r,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,i=Xh(e);return function(t,e){if(e&&("object"===Gh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Xh(this).constructor,Reflect.construct(i,arguments,t)):i.apply(this,arguments))});function r(t,e){!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);var n,o=ct({},{transform:new Ee("SlideNavigator").scale(1,1).rotate(0).translate(0,0),limits:t.primitives.limits,color:t.primitives.defaultColor,disableOpacity:.7},e);return(n=i.call(this,o)).collections=t,n._nextButton=null,n._prevButton=null,(n._text=null)!==o.prevButton&&n.addButton(o.prevButton||{},"Prev"),null!==o.nextButton&&n.addButton(o.nextButton||{},"Next"),null!==o.text&&n.addText(o.text||{}),n.nav=new Vh,n.nav.disableButtonOpacity=o.disableOpacity,n.custom.options=o,n.hasTouchableElements=!0,n.onAdd=function(){n.nav.load({collection:n.parent,slides:o.slides,equation:o.equation,equationDefaults:o.equationDefaults,prevButton:n._prevButton,nextButton:n._nextButton,text:n._text}),n.nav.goToSlide(0)},n}return t=[{key:"loadSlides",value:function(t){this.nav.slides=t,this.nav.loadRecorder(),this.nav.goToSlide(0)}},{key:"goToSlide",value:function(t){this.nav.goToSlide(t)}},{key:"nextSlide",value:function(){this.nav.nextSlide(0<arguments.length&&void 0!==arguments[0]&&arguments[0])}},{key:"prevSlide",value:function(){this.nav.prevSlide()}},{key:"addText",value:function(t){var e={font:ct({},this.collections.primitives.defaultFont),text:"",xAlign:"center"};e.font.color=this.color,t=ct({},e,"string"==typeof t?{text:t}:t),(t=this.collections.primitives.textLines(t)).isTouchable=!0,this.add("text",t)}},{key:"addButton",value:function(t,e){(t="arrow"===t.type?this.getArrowButton(t,e):this.getRectangleButton(t,e)).isTouchable=!0,"Next"===e?this.add("nextButton",t):this.add("prevButton",t)}},{key:"getRectangleButton",value:function(t,e){var n=this.collections.primitives.defaultLength;return t=ct({},{width:n/3,height:n/5,line:{width:this.collections.primitives.defaultLineWidth},corner:{radius:n/30,sides:10},button:!0,label:e,position:["Next"===e?n/3:-n/3,-n/4]},t),this.collections.rectangle(t)}},{key:"getArrowButton",value:function(t,e){var n=this.collections.primitives.defaultLength/4,i=0,r=n;return"Prev"===e&&(i=Math.PI,r=-r),t=ct({},{head:"triangle",length:n,width:n,angle:i,position:[r,-n],align:"mid"},t),this.collections.primitives.arrow(t)}}],function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(r.prototype,t),r}();var Qh=function(){function t(e,n,i){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.webgl=e.webgl,this.draw2D=e.draw2D,this.limits=e.limits,this.primitives=e,this.isTouchDevice=n,this.animateNextFrame=i}var e=[{key:"collection",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e={transform:new Ee("collection").scale(1,1).rotate(0).translate(0,0),border:"children",touchBorder:"children",holeBorder:"children",color:this.primitives.defaultColor,parent:null,limits:this.limits},n=arguments.length,i=new Array(1<n?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return e=t instanceof pe?(e.transform.updateTranslation(t),ct.apply(void 0,[{},e].concat(i))):t instanceof Ee?(e.transform=t._dup(),ct.apply(void 0,[{},e].concat(i))):ct.apply(void 0,[{},e,t].concat(i)),(t=new rs(e)).timeKeeper=this.primitives.timeKeeper,t.dimColor=this.primitives.defaultDimColor.slice(),null!=e.pulse&&"function"!=typeof t.pulseDefault&&"string"!=typeof t.pulseDefault&&(t.pulseDefault.scale=e.pulse),t.collections=this,t}},{key:"line",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new Kc(this,this.isTouchDevice,i)}},{key:"angle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new nh(this,this.isTouchDevice,this.animateNextFrame,i)}},{key:"label",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new jc(this,i)}},{key:"polyline",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new uh(this,this.isTouchDevice,this.animateNextFrame,i)}},{key:"rectangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Nh(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"slideNavigator",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new $h(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"axis",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new ph(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"trace",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new xh(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"plot",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new _h(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"plotLegend",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Ch(this,ct.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"equation",value:function(t){return new Cc(this.primitives,t)}},{key:"addEquation",value:function(t,e){var n=new Cc(this.primitives,2<arguments.length&&void 0!==arguments[2]?arguments[2]:{});return t.add(e,n),n}},{key:"cursor",value:function(t){(e={color:this.primitives.defaultColor,width:.008,radius:.05}).color[3]=.9;var e=ct(e,t),n=this.collection();return t={color:e.color,radius:e.radius,sides:50},e=this.primitives.polygon(ct({},t,{line:{width:e.width}})),t=this.primitives.polygon(ct({},t)),n.add("up",e),n.add("down",t),n}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();function Jh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Zh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zh(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function tf(t){return(tf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ef(t,e,n){return(ef="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=af(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function nf(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rf(t,e)}function rf(t,e){return(rf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function of(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=af(t);return function(t,e){if(e&&("object"===tf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=af(this).constructor,Reflect.construct(i,arguments,n)):i.apply(this,arguments))}}function af(t){return(af=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function sf(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function lf(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function uf(t,e,n){return e&&lf(t.prototype,e),n&&lf(t,n),t}Do=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);var n={htmlId:"figureOneContainer",limits:new fe(-1,-1,2,2),fontScale:1,color:[0,0,0,1],dimColor:[.5,.5,.5,1],font:{family:"Helvetica",size:.2,style:"normal",weight:"100",opacity:1},backgroundColor:[1,1,1,1]};this.frameRate={information:null,num:1,history:[]},this.fnMap=new G,this.isPaused=!1,this.scrolled=!1,this.cursorElementName="_cursor_",this.slideNavigatorElementName="_nav_",this.setStateCallback=null,this.shortcuts={},this.mockPreviousTouchPoint=new pe(0,0),this.nextDrawTimer=null,this.nextDrawTimerStart=0,this.nextDrawTimerDuration=0;var i=ct({},n,e),r=i.htmlId,o=i.limits;if(this.defaultColor=i.color,null==i.font.color&&(i.font.color=this.defaultColor.slice()),this.defaultDimColor=i.dimColor,this.defaultFont=i.font,this.htmlId=r,this.animationFinishedCallback=null,"string"==typeof r&&(n=document.getElementById(r))instanceof HTMLElement){for(var a=(this.container=n).children,s=0;s<a.length;s+=1){var l=a[s];l instanceof HTMLCanvasElement&&l.classList.contains("figureone__gl")&&(this.canvasLow=l),l instanceof HTMLCanvasElement&&l.classList.contains("figureone__gl__offscreen")&&(this.canvasOffscreen=l),l instanceof HTMLCanvasElement&&l.classList.contains("figureone__text")&&(this.textCanvasLow=l),l instanceof HTMLCanvasElement&&l.classList.contains("figureone__text__offscreen")&&(this.textCanvasOffscreen=l),l.classList.contains("figureone__html")&&(this.htmlCanvas=l)}var u;null==this.canvasLow&&(this.canvasLow=document.createElement("canvas"),this.canvasLow.classList.add("figureone__gl","figureone__canvas"),n.appendChild(this.canvasLow)),null==this.textCanvasLow&&(this.textCanvasLow=document.createElement("canvas"),this.textCanvasLow.classList.add("figureone__text","figureone__canvas"),n.appendChild(this.textCanvasLow)),null==this.htmlCanvas&&(this.htmlCanvas=document.createElement("div"),this.htmlCanvas.classList.add("figureone__html","figureone__canvas"),n.appendChild(this.htmlCanvas)),(r=document.createElement("style")).type="text/css",n.classList.add("figureone__container"),r.innerHTML="\n .figureone__container {\n position: relative;\n pointer-events: none;\n }\n .figureone__canvas {\n width: 100%;\n height: 100%;\n position: absolute;\n }\n .figureone__html {\n pointer-events: auto;\n }\n ",document.getElementsByTagName("head")[0].appendChild(r),this.backgroundColor=i.backgroundColor,r=new si(this.canvasLow,this.backgroundColor),this.webglLow=r,this.canvasOffscreen&&(r=new si(this.canvasOffscreen,this.backgroundColor),this.webglOffscreen=r),this.draw2DLow=new vs(this.textCanvasLow),this.textCanvasOffscreen&&(u=new vs(this.textCanvasOffscreen),this.draw2DOffscreen=u)}null==i.gestureCanvas||null!=(u=document.getElementById(i.gestureCanvas))&&(this.gestureCanvas=u),null==this.gestureCanvas&&(this.gestureCanvas=this.htmlCanvas),this instanceof t&&(this.gesture=new ys(this)),this.previousCursorPoint=new pe(0,0),this.isTouchDown=!1,this.fontScale=i.fontScale,this.updateLimits(o),this.setDefaultLineWidth(e.lineWidth||null),this.setDefaultLength(e.length||null),this.drawQueued=!1,this.lastDrawTime=0,this.beingMovedElements=[],this.beingTouchedElements=[],this.touchTopElementOnly=!0,this.timeKeeper=new za,this.notifications=new jt(this.fnMap),this.recorder=new Xo(this.timeKeeper),(this.recorder.figure=this).bindRecorder(),this.pauseTime=this.timeKeeper.now()/1e3,this.shapesLow=this.getShapes(),this.shapes=this.shapesLow,this.primitives=this.shapes,this.collectionsLow=this.getObjects(),this.collections=this.collectionsLow,this.createFigureElements(),""===this.elements.name&&(this.elements.name="figureRoot"),this.state={pause:"unpaused",preparingToStop:!1,preparingToSetState:!1},this.stateTime=this.timeKeeper.now()/1e3,this.focused=!0,window.addEventListener("resize",this.resize.bind(this)),window.addEventListener("focus",this.focusGained.bind(this)),window.addEventListener("blur",this.focusLost.bind(this)),this.sizeHtmlText(),this.isTouchDevice=pt(),this.animateNextFrame(!0,"first frame"),i.elements&&(this.elements=new i.elements(this),this.elements.figureLimits=this.limits,this.initElements()),this.waitForFrames=0,this.scrollingFast=!1,this.scrollTimeoutId=null,this.drawTimeoutId=null,this.oldScroll=window.pageYOffset,this.drawAnimationFrames=0,this.cursorShown=!1}var e=[{key:"addSlideNavigator",value:function(t){return t=this.add(ct({},{name:"_nav_",make:"collections.slideNavigator"},{options:t})),this.slideNavigatorElementName="_nav_",t}},{key:"getSlideNavigator",value:function(){return this.getElement(this.slideNavigatorElementName)}},{key:"addCursor",value:function(t){return t=this.add(ct({},{name:"_cursor_",make:"collections.cursor",mods:{isShown:!1}},{options:t})),this.cursorElementName="_cursor_",t}},{key:"getCursor",value:function(){return this.getElement(this.cursorElementName)}},{key:"bindRecorder",value:function(){var t=this;this.recorder.addEventType("cursor",(function(e){var n=(i=Jh(e,3))[0],i=(e=i[1],i[2]);"show"===n?(t.showCursor("up",new pe(e,i)),"recording"===t.recorder.state&&t.recorder.recordEvent("cursor",["show",e,i])):(t.showCursor("hide"),"recording"===t.recorder.state&&t.recorder.recordEvent("cursor",["hide"]))})),this.recorder.addEventType("_autoCursor",(function(e){var n=(i=Jh(e,3))[0],i=(e=i[1],i[2]);"show"===n?t.showCursor("up",new pe(e,i)):t.showCursor("hide")})),this.recorder.addEventType("cursorMove",(function(e){e=(n=Jh(e,2))[0];var n=n[1];t.setCursor(new pe(e,n)),t.touchMove(new pe(e,n))})),this.recorder.addEventType("_autoCursorMove",(function(e){e=(n=Jh(e,2))[0];var n=n[1];t.setCursor(new pe(e,n)),t.touchMove(new pe(e,n),!0)})),this.recorder.addEventType("touch",(function(e){var n=(i=Jh(e,3))[0],i=(e=i[1],i[2]);"down"===n?t.touchDown(new pe(e,i),!0):t.touchUp()})),this.recorder.addEventType("_autoTouch",(function(e){var n=(i=Jh(e,3))[0],i=(e=i[1],i[2]);"down"===n?t.touchDown(new pe(e,i),!0,!0):t.touchUp(!0)})),this.recorder.addEventType("exec",(function(e){var n=(i=Jh(e,2))[0],i=i[1];t.fnMap.exec(n,i),"recording"===t.recorder.state&&t.recorder.recordEvent("exec",e)})),this.recorder.addEventType("_autoExec",(function(e){e=(n=Jh(e,2))[0];var n=n[1];t.fnMap.exec(e,n)}))}},{key:"setDefaultLineWidth",value:function(t){var e;null==t?(e=this.spaceTransforms.pixelToFigure.matrix(),this.defaultLineWidth=Math.abs(e[0])):this.defaultLineWidth=t}},{key:"setDefaultLength",value:function(t){this.defaultLength=null==t?this.limits.width/4:t}},{key:"scrollEvent",value:function(){this.scrolled=!0,this.animateNextFrame(!1,"scroll event")}},{key:"enableScrolling",value:function(){document.addEventListener("scroll",this.scrollEvent.bind(this),!1)}},{key:"disableScrolling",value:function(){document.removeEventListener("scroll",this.scrollEvent.bind(this),!1)}},{key:"getState",value:function(t){this.notifications.publish("getState"),this.stateTime=this.timeKeeper.now()/1e3;var e=ci(this,["lastDrawTime","elements","stateTime","mockPreviousTouchPoint","isTouchDown"],ct({},t,{returnF1Type:!1}));return e.beingTouchedElements=[],e.beingMovedElements=[],this.beingTouchedElements.forEach((function(t){e.beingTouchedElements.push({f1Type:"de",state:t.getPath()})})),this.beingMovedElements.forEach((function(t){e.beingMovedElements.push({f1Type:"de",state:t.getPath()})})),e}},{key:"setState",value:function(t){function e(){o=!0,n.state.preparingToSetState=!1,ct(n,r),n.beingMovedElements=n.beingMovedElements.filter((function(t){return 0<Object.keys(t).length})),n.beingTouchedElements=n.beingTouchedElements.filter((function(t){return 0<Object.keys(t).length})),n.notifications.publish("setStateInit"),n.elements.setTimeDelta(n.timeKeeper.now()/1e3-n.stateTime),n.elements.updateDrawTransforms([n.spaceTransforms.figureToGL]),n.elements.stateSet(),n.elements.setPointsFromDefinition(),n.elements.setPrimitiveColors(),null!=n.setStateCallback&&n.fnMap.exec(n.setStateCallback),n.animateNextFrame(),n.notifications.publish("setState",n.timeKeeper.now()/1e3-n.stateTime)}var n=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"instant",r=function t(e,n){if("number"==typeof e)return e;if("string"==typeof e)return e;if("boolean"==typeof e)return e;if(null==e)return e;if(Array.isArray(e)){var i=[];return e.forEach((function(e){i.push(t(e,n))})),i}if(null!=e.f1Type){if("rect"===e.f1Type)return de(e);if("p"===e.f1Type)return ue(e);if("tf"===e.f1Type)return Be(e);if("t"===e.f1Type)return new _e(e);if("s"===e.f1Type)return new Pe(e);if("r"===e.f1Type)return new Oe(e);if("l"===e.f1Type)return ke(e);if("rangeBounds"===e.f1Type)return Ye(e);if("rectBounds"===e.f1Type)return Ye(e);if("lineBounds"===e.f1Type)return Ye(e);if("transformBounds"===e.f1Type)return Ye(e);if("de"===e.f1Type)return null!=(r=n.getElement(e.state))&&(r._assignAsLinkOnly=!0),r;if("positionAnimationStep"===e.f1Type)return(new Ti)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("rotationAnimationStep"===e.f1Type)return(new qr)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("scaleAnimationStep"===e.f1Type)return(new Yr)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("transformAnimationStep"===e.f1Type)return(new Mr)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("scenarioAnimationStep"===e.f1Type)return(new Ji)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("colorAnimationStep"===e.f1Type)return(new ur)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("opacityAnimationStep"===e.f1Type)return(new Sr)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("pulseAnimationStep"===e.f1Type)return(new to)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("customAnimationStep"===e.f1Type)return(new go)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("delayAnimationStep"===e.f1Type)return(new Ro)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("parallelAnimationStep"===e.f1Type)return(new Ki)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("serialAnimationStep"===e.f1Type)return(new Oo)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("triggerAnimationStep"===e.f1Type)return(new lo)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("animationBuilder"===e.f1Type)return(new ms)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper)}var r,o={};return Object.keys(e).forEach((function(i){o[i]=t(e[i],n)})),o}(t,this),o=!1;t={how:"instant",maxDuration:6,allDurationsSame:!(this.state.preparingToSetState=!1),zeroDurationThreshold:1e-5,duration:0},null!=i.velocity&&(t.velocity={position:2,rotation:2*Math.PI/2,scale:1,opacity:.8,color:.8}),"string"==typeof i?t.how=i:t=ct({},t,i),"dissolve"===t.how?(i={dissolveIn:.8,dissolveOut:.8,delay:.2},0===t.duration?t.duration=i:"number"==typeof t.duration?t.duration={dissolveOut:t.duration/10*4.5,dissolveIn:t.duration/10*4.5,delay:t.duration/10*1}:t.duration=ct({},i,t.duration)):null!=t.duration&&"number"!=typeof t.duration&&(t.duration={dissolveOut:0,dissolveIn:0,delay:0}),"instant"===t.how||this.elements.isStateSame(r.elements,!0,["cursor"])?e():"animate"===t.how?(this.elements.stop("freeze"),this.animateToState(r,t,e,"now")):(this.elements.stop("freeze"),this.dissolveToState({state:r,dissolveInDuration:t.duration.dissolveIn,dissolveOutDuration:t.duration.dissolveOut,done:e,delay:t.duration.delay,startTime:"now"})),o||(this.state.preparingToSetState=!0,this.notifications.publish("preparingToSetState")),this.animateNextFrame()}},{key:"animateToState",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0;e=this.elements.animateToState(t.elements,e,!0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:null),null!=n&&(0===e?this.fnMap.exec(n):null!=n&&this.notifications.add("animationsFinished",n,1))}},{key:"dissolveToState",value:function(t){var e=this,n=ct({},{dissolveOutDuration:.8,dissolveInDuration:.8,delay:.2,done:null,startTime:null},t);this.elements.animations.new().opacity({duration:n.dissolveOutDuration,start:1,target:.001}).trigger({callback:function(){e.elements.hideAll(),e.elements.show()}}).delay({duration:n.delay}).trigger({callback:function(){e.dissolveInToState({state:n.state,duration:n.dissolveInDuration,done:n.done,startTime:n.startTime})},duration:0}).start(n.startTime)}},{key:"dissolveInToState",value:function(t){var e=(i=ct({},{duration:.8,done:null,startTime:null},t)).state,n=i.duration,i=(t=i.done,i.startTime);i=this.elements.dissolveInToState(e.elements,n,i),this.elements.getAllElements().forEach((function(t){t.isShown&&!1===t.dependantTransform&&t.setTransform(t.transform)})),null!=t&&(0===i?this.fnMap.exec(t):null!=t&&this.notifications.add("animationsFinished",t,1))}},{key:"add",value:function(t){return this.elements.add(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)}},{key:"getElement",value:function(t){return t===this.elements.name?this.elements:this.elements.getElement(t)}},{key:"getElements",value:function(t){return this.elements.getElements(t)}},{key:"get",value:function(t){return"string"==typeof t?this.getElement(t):this.getElements(t)}},{key:"setTouchable",value:function(){this.elements.hasTouchableElements=!(0<arguments.length&&void 0!==arguments[0]&&!arguments[0])}},{key:"getShapes",value:function(){var t=[this.webglLow];this.webglOffscreen&&t.push(this.webglOffscreen);var e=[this.draw2DLow];return this.draw2DOffscreen&&e.push(this.draw2DOffscreen),new Xs(t,e,this.htmlCanvas,this.limits,this.spaceTransforms,this.animateNextFrame.bind(this,!0,"getShapes"),this.defaultColor,this.defaultDimColor,this.defaultFont,this.defaultLineWidth,this.defaultLength,this.timeKeeper,this.recorder)}},{key:"getObjects",value:function(){var t=this.shapesLow;return new Qh(t,this.isTouchDevice,this.animateNextFrame.bind(this,!0,"collections"))}},{key:"sizeHtmlText",value:function(){var t=this.container.getBoundingClientRect(),e=t.width/35,n=document.getElementById("".concat(this.htmlId,"_measure"));null!=n&&(n.style.fontSize="".concat(e,"px"),n=(n.clientWidth+1)/t.width,e=t.width<500?Math.floor(.84/n*e*1e4)/1e4:Math.floor(.85/n*e*1e4)/1e4),this.htmlCanvas.style.fontSize="".concat(e,"px")}},{key:"destroy",value:function(){this.gesture.destroy(),this.webglLow.gl.getExtension("WEBGL_lose_context").loseContext()}},{key:"setSpaceTransforms",value:function(){var t={x:{bottomLeft:-1,width:2},y:{bottomLeft:-1,height:2}},e={x:{bottomLeft:this.limits.left,width:this.limits.width},y:{bottomLeft:this.limits.bottom,height:this.limits.height}},n={x:{bottomLeft:0,width:(n=this.canvasLow.getBoundingClientRect()).width},y:{bottomLeft:n.height,height:-n.height}};this.spaceTransforms={figureToGL:Ce(e,t,"Figure"),glToFigure:Ce(t,e),pixelToFigure:Ce(n,e),figureToPixel:Ce(e,n),pixelToGL:Ce(n,t),glToPixel:Ce(t,n),figureToCSSPercent:Ce(e,{x:{bottomLeft:0,width:1},y:{bottomLeft:1,height:-1}})}}},{key:"initialize",value:function(){}},{key:"initElements",value:function(){this.elements.setFigure({limits:this.limits,spaceTransforms:this.spaceTransforms,animateNextFrame:this.animateNextFrame.bind(this),animationFinished:this.animationFinished.bind(this),recorder:this.recorder,timeKeeper:this.timeKeeper}),this.setFirstTransform(),this.animateNextFrame()}},{key:"setElements",value:function(t){this.elements=t,this.animations=this.elements.animations,this.initElements()}},{key:"getRemainingAnimationTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3,e=this.elements.getAllElements(),n=t;"paused"===this.state.pause&&(n=this.pauseTime);for(var i=0,r=0;r<e.length;r+=1){var o=e[r],a=o.animations.getRemainingTime([],n);if(null==a)return null;if(i<a&&(i=a),null==(a=o.getRemainingPulseTime(n)))return null;if(i<a&&(i=a),null==(o=o.getRemainingMovingFreelyTime(n)))return null;i<o&&(i=o)}return i}},{key:"setAnimationFinishedCallback",value:function(t){this.animationFinishedCallback=t}},{key:"animationFinished",value:function(){this.isAnimating()||(this.fnMap.exec(this.animationFinishedCallback),this.notifications.publish("animationsFinished"))}},{key:"setFirstTransform",value:function(){this.elements.setFirstTransform(this.spaceTransforms.figureToGL)}},{key:"updateLimits",value:function(t){t=de(t),this.limits=t._dup(),this.setSpaceTransforms()}},{key:"renderAllElementsToTiedCanvases",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]&&arguments[0];null!=this.canvasOffscreen&&(t=!1,Object.keys(this.elements.elements).forEach((function(i){var r=e.elements.elements[i];r.isShown&&(!1===r.isRenderedAsImage||n)&&null!=r.tieToHTML.element&&(r.isRenderedAsImage=!0,e.renderElementToTiedCanvas(i),t=!0)})),t&&(this.drawQueued=!0,this.clearContext(),this.draw2DLow.ctx.clearRect(0,0,this.textCanvasLow.width,this.textCanvasLow.height),this.draw(-1)))}},{key:"renderElementToTiedCanvas",value:function(t){var e=this,n={};Object.keys(this.elements.elements).forEach((function(t){var i=e.elements.elements[t];n[t]=i.isShown})),Object.keys(this.elements.elements).forEach((function(t){e.elements.elements[t].hide()}));var i=this.elements.elements[t];i.show();var r=i.getPosition(),o=i.getScale();(t=document.getElementById(i.tieToHTML.element))instanceof HTMLElement&&(this.canvasOffscreen.style.width="".concat(t.clientWidth,"px"),this.canvasOffscreen.style.height="".concat(t.clientHeight,"px"),this.textCanvasOffscreen.style.width="".concat(t.clientWidth,"px"),this.textCanvasOffscreen.style.height="".concat(t.clientHeight,"px"),this.webglOffscreen.resize(),this.draw2DOffscreen.resize()),i.updateHTMLElementTie(this.canvasOffscreen),t=i.getScale(),i.setPosition(0-t.x*(i.tieToHTML.window.left+i.tieToHTML.window.width/2),0-t.y*(i.tieToHTML.window.bottom+i.tieToHTML.window.height/2)),i.isRenderedAsImage=!1,i.stop("complete"),this.renderToCanvas(i.tieToHTML.element),i.isRenderedAsImage=!0,i.setPosition(r),i.setScale(o),Object.keys(this.elements.elements).forEach((function(t){var i=e.elements.elements[t];!0===n[t]?i.show():i.hide()}))}},{key:"renderToCanvas",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=t;(e="string"==typeof t?document.getElementById(t):e)instanceof HTMLElement&&(this.drawQueued=!0,this.draw(-1,1),(e=document.getElementById("".concat(t,"_webgl")))instanceof HTMLImageElement&&(e.src=this.webglOffscreen.gl.canvas.toDataURL("image/png",.5),e.style.display="block"),(t=document.getElementById("".concat(t,"_2d")))instanceof HTMLImageElement&&(t.src=this.draw2DOffscreen.canvas.toDataURL("image/png",.5),t.style.display="block"),this.clearContext(1))}},{key:"unrenderAll",value:function(){for(var t=0;t<this.elements.drawOrder.length;t+=1)this.elements.elements[this.elements.drawOrder[t]].unrender()}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this.webglLow.resize(),this.draw2DLow.resize(),this.setSpaceTransforms(),null!=this.elements&&this.elements.updateLimits(this.limits,this.spaceTransforms),this.sizeHtmlText(),t?this.elements.resize():this.elements.resize(this.canvasLow),this.oldWidth!==this.canvasLow.clientWidth&&(this.renderAllElementsToTiedCanvases(),this.oldWidth=this.canvasLow.clientWidth),this.notifications.publish("resize"),this.animateNextFrame(!0,"resize"),this.drawAnimationFrames=2}},{key:"updateHTMLElementTie",value:function(){null!=this.elements&&this.elements.updateHTMLElementTie(this.canvasLow)}},{key:"show",value:function(){this.elements.show(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"hide",value:function(){this.elements.hide(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"showOnly",value:function(){this.elements.showOnly(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"setScenarios",value:function(t){this.elements.setScenarios(t,1<arguments.length&&void 0!==arguments[1]&&arguments[1])}},{key:"toggleCursor",value:function(){this.cursorShown=!this.cursorShown,"recording"===this.recorder.state&&(this.cursorShown?(this.recorder.recordEvent("cursor",["show",this.previousCursorPoint.x,this.previousCursorPoint.y]),this.isTouchDown?this.showCursor("down"):this.showCursor("up"),this.setCursor(this.previousCursorPoint)):(this.recorder.recordEvent("cursor",["hide"]),this.showCursor("hide")))}},{key:"showCursor",value:function(t){var e,n,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=this.getCursor();null!=r&&(e=r.getElement("up"),n=r.getElement("down"),null!=e&&null!=n&&("up"===t?(e.showAll(),n.hide()):"down"===t?(e.hide(),n.showAll()):r.hide(),null!=i&&this.setCursor(i),this.animateNextFrame()))}},{key:"isCursorShown",value:function(){var t=this.getElement(this.cursorElementName);return null!=t&&t.isShown}},{key:"touchDownHandlerClient",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return t=this.clientToPixel(t).transformBy(this.spaceTransforms.pixelToFigure.matrix()),this.touchDownHandler(t,e)}},{key:"touchDownHandler",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];"recording"===this.recorder.state&&(2<arguments.length&&void 0!==arguments[2]&&arguments[2]||this.recorder.recordEvent("touch",["down",t.x,t.y]),this.cursorShown&&this.showCursor("down")),this.previousCursorPoint=t._dup(),this.isPaused&&this.unpause(),"idle"===this.recorder.state&&(this.recorder.lastSeekTime=null),"playing"!==this.recorder.state||e||(this.recorder.pausePlayback(),this.showCursor("hide")),this.isTouchDown=!0;var n=t.transformBy(this.spaceTransforms.figureToGL.matrix());this.beingTouchedElements=this.elements.getTouched(n),this.touchTopElementOnly&&1<this.beingTouchedElements.length&&(this.beingTouchedElements=[this.beingTouchedElements[0]]),this.beingTouchedElements.forEach((function(t){return t.click(n)})),this.beingMovedElements=[];for(var i=0;i<this.beingTouchedElements.length;i+=1){var r=this.beingTouchedElements[i];r.isMovable&&(this.beingMovedElements.push(r),r.startBeingMoved())}return 0<this.beingMovedElements.length&&this.animateNextFrame(!0,"touch down handler"),0<this.beingTouchedElements.length}},{key:"touchUpHandler",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!1!==this.isTouchDown&&("playing"!==this.recorder.state&&"preparingToPlay"!==this.recorder.state||!(1<arguments.length&&void 0!==arguments[1]&&arguments[1]))){"recording"!==this.recorder.state||t||(this.recorder.recordEvent("touch",["up"]),this.cursorShown&&this.showCursor("up"));for(var e=0;e<this.beingMovedElements.length;e+=1){var n=this.beingMovedElements[e];n.state.isBeingMoved&&(n.stopBeingMoved(),n.startMovingFreely())}this.isTouchDown=!1,this.beingMovedElements=[],this.beingTouchedElements=[]}}},{key:"setCursor",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this.getElement(this.cursorElementName);null!=n&&(n.setPosition(t),e&&this.animateNextFrame())}},{key:"touchFreeHandler",value:function(t){"recording"===this.recorder.state&&(t=this.clientToPixel(t).transformBy(this.spaceTransforms.pixelToFigure.matrix()),this.previousCursorPoint=t,this.cursorShown?(this.recorder.recordEvent("cursorMove",[t.x,t.y]),this.setCursor(t)):this.setCursor(t,!1))}},{key:"rotateElement",value:function(t,e,n){var i=t.getPosition("figure");null==i&&(i=new pe(0,0)),n=be(Math.atan2(n.y-i.y,n.x-i.x),Math.atan2(e.y-i.y,e.x-i.x)),i=(e=t.transform._dup()).r(),e.updateRotation((i=null==i?0:i)+n),t.moved(e._dup())}},{key:"translateElement",value:function(t,e,n){var i=t.spaceTransformMatrix("figure","local");n=n.transformBy(i),e=e.transformBy(i),i=n.sub(e),null!=(e=(n=t.transform._dup()).t())&&(i=e.add(i),n.updateTranslation(i),t.moved(n))}},{key:"scaleElement",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",r=t.getPosition("figure"),o=e.sub(r).distance(),a=n.sub(r).distance();null!=(e=t.transform.s())&&(n=t.transform._dup(),r=e.x*a/o,o=e.y*a/o,"x"===i?n.updateScale(r,1):"y"===i?n.updateScale(1,o):n.updateScale(r,o),t.moved(n))}},{key:"touchMoveHandlerClient",value:function(t,e){return e=this.clientToPixel(e).transformBy(this.spaceTransforms.pixelToFigure.matrix()),t=this.clientToPixel(t).transformBy(this.spaceTransforms.pixelToFigure.matrix()),this.touchMoveHandler(t,e)}},{key:"touchMoveHandler",value:function(t,e){if("recording"!==this.recorder.state||2<arguments.length&&void 0!==arguments[2]&&arguments[2]||(this.recorder.recordEvent("cursorMove",[e.x,e.y]),this.cursorShown&&this.setCursor(e)),this.previousCursorPoint.x=e.x,this.previousCursorPoint.y=e.y,0===this.beingMovedElements.length)return!1;for(var n=t.transformBy(this.spaceTransforms.figureToGL.matrix()),i=0;i<this.beingMovedElements.length;i+=1){var r,o=this.beingMovedElements[i];o!==this.elements&&(o.isBeingTouched(n)||o.move.canBeMovedAfterLosingTouch)&&(r=void 0,!1===(r=null==o.move.element?o:"string"==typeof o.move.element?this.getElement(o.move.element):o.move.element).state.isBeingMoved&&r.startBeingMoved(),-1===this.beingMovedElements.indexOf(r)&&this.beingMovedElements.push(r),"rotation"===o.move.type?this.rotateElement(r,t,e):"scale"===o.move.type?this.scaleElement(r,t,e):"scaleX"===o.move.type?this.scaleElement(r,t,e,"x"):"scaleY"===o.move.type?this.scaleElement(r,t,e,"y"):this.translateElement(r,t,e)),this.touchTopElementOnly&&(i=this.beingMovedElements.length)}return this.animateNextFrame(!0,"touch move handler"),!0}},{key:"stop",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=function(){t.notifications.publish("stopped"),t.state.preparingToStop=!1};if(this.elements.isAnimating()){if("freeze"===e||"cancel"===e||"complete"===e)return this.elements.stop(e),void n();if(this.state.preparingToStop=!1,"animateToComplete"===e){this.elements.stop(e);var i=this.elements.getAllElements(),r=0,o=function(){0<r&&--r,0===r&&n()};return i.forEach((function(t){t.state.preparingToStop&&(r+=1,t.notifications.add("stopped",o,1))})),void(0===r?o():0<r&&(this.notifications.publish("preparingToStop"),this.state.preparingToStop=!0))}e=this.getState({}),this.elements.stop("complete"),i=this.getState({}),this.setState(e),this.elements.stop("freeze"),this.setState(i,"dissolve"),this.state.preparingToSetState?(this.notifications.add("setState",n,1),this.notifications.publish("preparingToStop"),this.state.preparingToStop=!0):n()}else n()}},{key:"createFigureElements",value:function(){this.elements=this.collections.collection({name:"rootCollection"}),this.animations=this.elements.animations,this.initElements()}},{key:"setElementsToCollection",value:function(t){this.elements=t,this.animations=this.elements.animations,this.initElements()}},{key:"clearContext",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;0===t?(this.webglLow.gl.clearColor(this.backgroundColor[0],this.backgroundColor[1],this.backgroundColor[2],this.backgroundColor[3]),this.webglLow.gl.clear(this.webglLow.gl.COLOR_BUFFER_BIT)):(this.webglOffscreen.gl.clearColor(0,0,0,0),this.webglOffscreen.gl.clear(this.webglLow.gl.COLOR_BUFFER_BIT)),this.elements.clear(t)}},{key:"drawNow",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;this.drawQueued=!0,this.draw(t)}},{key:"pause",value:function(){"pause"!==this.state.pause&&"preparingToPause"!==this.state.pause&&"preparingToUnpause"!==this.state.pause&&(this.state.pause="paused",this.pauseTime=this.timeKeeper.now()/1e3,this.clearDrawTimeout())}},{key:"unpause",value:function(){"unpaused"!==this.state.pause&&"preparingToPause"!==this.state.pause&&"preparingToUnpause"!==this.state.pause&&(this.state.pause="unpaused",this.isPaused=!1,this.elements.setTimeDelta(this.timeKeeper.now()/1e3-this.pauseTime),this.animateNextFrame(),this.notifications.publish("unpaused"))}},{key:"touchDown",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];t=ue(t),this.touchDownHandler(t,e,n),this.mockPreviousTouchPoint=t,null!=this.elements.elements[this.cursorElementName]&&this.showCursor("down",t)}},{key:"touchUp",value:function(){this.touchUpHandler(0<arguments.length&&void 0!==arguments[0]&&arguments[0]),null!=this.elements.elements[this.cursorElementName]&&this.showCursor("up")}},{key:"touchMove",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];t=ue(t),this.touchMoveHandler(this.mockPreviousTouchPoint,t,e),this.mockPreviousTouchPoint=t}},{key:"clearDrawTimeout",value:function(){this.timeKeeper.clearTimeout(this.nextDrawTimer),this.nextDrawTimer=null}},{key:"draw",value:function(t){var e,n,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;null!=this.elements.__frameRate_&&(n=new Dt,window.figureOneDebug.draw=[],window.figureOneDebug.setupDraw=[],window.figureOneDebug.misc=[]),this.clearDrawTimeout(),"paused"!==this.state.pause&&(-1===(e=t)&&(e=this.lastDrawTime),this.lastDrawTime=e,!0===this.scrolled&&(this.scrolled=!1,Math.abs(window.pageYOffset-this.oldScroll)>this.webglLow.gl.canvas.clientHeight/4&&(this.renderAllElementsToTiedCanvases(),this.scrollingFast=!0,this.scrollTimeoutId&&(clearTimeout(this.scrollTimeoutId),this.scrollTimeoutId=null),this.scrollTimeoutId=setTimeout(this.centerDrawingLens.bind(this,!0),100))),!1!==this.drawQueued&&(this.drawQueued=!1,null!=this.elements.__frameRate_&&n.stamp("m1"),this.clearContext(i),null!=this.elements.__frameRate_&&n.stamp("clearContext"),this.notifications.publish("beforeDraw"),null!=this.elements.__frameRate_&&n.stamp("beforeDraw"),null!=this.elements.__frameRate_&&null!=this.frameRate.information&&this.elements.__frameRate_.custom.updateText({text:this.frameRate.information}),this.elements.setupDraw(e,i),null!=this.elements.__frameRate_&&n.stamp("setupDraw"),this.elements.draw(e,[this.spaceTransforms.figureToGL],1,i),null!=this.elements.__frameRate_&&n.stamp("draw"),this.elements.isAnyElementMoving()&&this.animateNextFrame(!0,"is moving"),0<this.drawAnimationFrames&&(--this.drawAnimationFrames,this.animateNextFrame(!0,"queued frames")),this.notifications.publish("afterDraw"),null!=this.elements.__frameRate_&&(n.stamp("afterDraw"),t=n.deltas(),null!=this.elements.__frameRate_&&(e=(this.timeKeeper.now()-(this.timeKeeper.lastDrawTime||0))/1e3,i=t[0],n=t[4][1],t=t[5][1],this.frameRate.history.push([e,i,n,t]),this.frameRate.history.length===this.frameRate.num&&(i=this.frameRate.history.reduce((function(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2],t[3]+e[3]]}),[0,0,0,0]),n=this.frameRate.history.reduce((function(t,e){return[(e[0]>t[0]?e:t)[0],(e[1]>t[1]?e:t)[1],(e[2]>t[2]?e:t)[2],(e[3]>t[3]?e:t)[3]]}),[0,0,0,0]),t=this.frameRate.num,t=[d(1/(i[0]/t),0).toFixed(0).padStart(3),d(i[1]/t,1).toFixed(1).padStart(5),d(i[2]/t,1).toFixed(1).padStart(5),d(i[3]/t,1).toFixed(1).padStart(5)],n=[d(1/n[0],0).toFixed(0).padStart(3),d(n[1],1).toFixed(1).padStart(5),d(n[2],1).toFixed(1).padStart(5),d(n[3],1).toFixed(1).padStart(5)],this.frameRate.information=["Ave: ".concat(t[0]," fps, ").concat(t[1]," ms, (").concat(t[2],", ").concat(t[3],")"),"Max: ".concat(n[0]," fps, ").concat(n[1]," ms, (").concat(n[2],", ").concat(n[3],")")],this.frameRate.history=[]))),this.setDrawTimeout()))}},{key:"centerDrawingLens",value:function(){0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&(this.scrollingFast=!1);var t=window.innerHeight||0;null!=document.documentElement&&(t=Math.max(document.documentElement.clientHeight,window.innerHeight||0));var e=window.pageYOffset+t/2-this.webglLow.gl.canvas.clientHeight/2;t="".concat(e=e<0?0:e,"px"),this.webglLow.gl.canvas.style.top!==t&&(this.webglLow.gl.canvas.style.top="".concat(e,"px"),this.draw2DLow.canvas.style.top="".concat(e,"px"),this.updateHTMLElementTie()),this.oldScroll=window.pageYOffset}},{key:"setDrawTimeout",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;1e-8<(n=null==(n=n<0?this.elements.getNextAnimationFinishTime():n)?.1:n)&&(t=this.timeKeeper.now()/1e3,(null==this.nextDrawTimer&&0<n||null!=this.nextDrawTimer&&0<this.nextDrawTimerStart&&0<this.nextDrawTimerDuration&&this.nextDrawTimerStart+this.nextDrawTimerDuration>t+n+.001||this.nextDrawTimerStart+this.nextDrawTimerDuration<=t)&&(this.clearDrawTimeout(),this.nextDrawTimerStart=t,this.nextDrawTimerDuration=n,this.nextDrawTimer=this.timeKeeper.setTimeout((function(){e.nextDrawTimer=null,e.setupDraw(),e.animateNextFrame()}),1e3*n,"drawTimeout")))}},{key:"focusLost",value:function(){this.focused=!1,this.setDrawTimeout(.1)}},{key:"focusGained",value:function(){this.focused=!0}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3;this.notifications.publish("beforeDraw"),this.elements.setupDraw(t),this.focused?this.setDrawTimeout():this.setDrawTimeout(.1)}},{key:"animateNextFrame",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];this.fromWhere=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",this.drawQueued||(t&&(this.drawQueued=!0),this.timeKeeper.queueNextFrame(this.draw.bind(this)))}},{key:"isAnimating",value:function(){return this.elements.isAnimating()}},{key:"clientToPixel",value:function(t){var e=this.canvasLow.getBoundingClientRect();return new pe(t.x-e.left,t.y-e.top)}},{key:"pixelToClient",value:function(t){var e=this.canvasLow.getBoundingClientRect();return new pe(t.x+e.left,t.y+e.top)}},{key:"debugShowTouchBorders",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.setFirstTransform(),this.elements.getElements(t).forEach((function(t,r){t=t.getBorder("figure","touchBorder"),t=e.primitives.polyline(ct({},n,{points:t[0],close:!0})),e.add("__touchBorder_".concat(r+i),t)}))}},{key:"setManualFrames",value:function(){this.timeKeeper.setManualFrames()}},{key:"endManualFrames",value:function(){this.timeKeeper.endManualFrames()}},{key:"frame",value:function(t){this.timeKeeper.frame(t)}},{key:"addFrameRate",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.frameRate.num=t,e=this.add(ct({},{name:"_frameRate_",make:"primitives.textLines",text:["Ave:","Max:"],position:[this.limits.left,this.limits.bottom],xAlign:"left",yAlign:"bottom",font:{size:this.limits.width/30}},e)),window.figureOneDebug={cumTimes:[],draw:[],setupDraw:[],misc:[],history:[],animationManager:[]},e}}];return function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}(t.prototype,e),t}();var cf=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";sf(this,t),this.id=e,Array.isArray(n)?this.classes=n:0<n.length?this.classes=n.split(" "):this.classes=[]}return uf(t,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return function(t,e,n,i){return i=" ".repeat(3<arguments.length&&void 0!==i?i:0),t=t?' id="'.concat(t,'"'):"",e=e?" ".concat(e.join(" ")):"",e="".concat(i,"<div").concat(t,' class="equation_element').concat(e,'">\n'),(e+="".concat(n,"\n"))+"".concat(i,"</div>")}(this.id,this.classes,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",t)}}]),t}(),hf=function(){nf(e,cf);var t=of(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return sf(this,e),(r=t.call(this,i,r)).classes.push("equation_text"),r.text=n,r}return uf(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return ef(af(e.prototype),"render",this).call(this,t,"".concat(" ".repeat(t+2)).concat(this.text))}}]),e}(),ff=function(){nf(e,cf);var t=of(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];sf(this,e),r=t.call(this,i,r);var o=[];return n.forEach((function(t){null!==t&&o.push(t)})),r.content=o,r}return uf(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return ef(af(e.prototype),"render",this).call(this,t,this.content.map((function(e){return e.render(t+2)})).join("\n"))}}]),e}(),df=function(){nf(e,cf);var t=of(e);function e(n,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return sf(this,e),(o=t.call(this,r,o)).classes.push("fraction"),o.numerator=n,o.denominator=i,o}return uf(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),i="";return i+="".concat(n,'<div class="numerator">\n'),i+=this.numerator.render(t+4),i+="\n".concat(n,"</div>\n"),i+="".concat(n,'<div class="fraction_line"> </div>\n'),i+="".concat(n,'<div class="denominator">\n'),i+=this.denominator.render(t+4),i+="\n".concat(n,"</div>"),ef(af(e.prototype),"render",this).call(this,t,i)}}]),e}(),pf=function(){nf(e,cf);var t=of(e);function e(n,i,r){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"";return sf(this,e),(a=t.call(this,o,a)).classes.push("supersub"),a.superscript=i,a.subscript=r,a.content=n,a}return uf(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),i="";return i+="".concat(n,'<div class="supsub_content element">\n'),i+=this.content.render(t+2),i+="\n".concat(n,"</div>\n"),i+="".concat(n,'<div class="super_sub element">\n'),i+="".concat(n,'<div class="super_sub_super superscript_text element">\n'),null!==this.superscript&&(i+=this.superscript.render(t+4)),i+="\n".concat(n,"</div>\n"),i+="".concat(n,'<div class="super_sub_sub subscript_text element">\n'),null!==this.subscript&&(i+=this.subscript.render(t+4)),i+="\n".concat(n,"</div>"),i+="\n".concat(n,"</div>\n"),ef(af(e.prototype),"render",this).call(this,t,i)}}]),e}(),mf=function(){nf(e,pf);var t=of(e);function e(n,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";return sf(this,e),-1<(o=(r=t.call(this,n,null,i,r,o)).classes.indexOf("supersub"))&&r.classes.splice(o,1),r.classes.push("subscript"),r}return e}(),yf=function(){nf(e,pf);var t=of(e);function e(n,i){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";return sf(this,e),-1<(o=(r=t.call(this,n,i,null,r,o)).classes.indexOf("supersub"))&&r.classes.splice(o,1),r.classes.push("superscript"),r}return e}(),vf=function(){nf(e,cf);var t=of(e);function e(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return sf(this,e),(r=t.call(this,i,r)).content=n,r}return uf(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),i="";return i+="".concat(n,'<div class="square_root element">\n'),i+="".concat(n,' <div class="equation_element radical element">\n'),i+="".concat(n," &radic;\n"),i+="".concat(n," </div>\n"),i+=this.content.render(t+4),i+="\n".concat(n,"</div>"),ef(af(e.prototype),"render",this).call(this,t,i)}}]),e}();function gf(t){if(t instanceof ff)return t;if(t instanceof hf||t instanceof cf)return new ff([t]);if("string"==typeof t)return new ff([new hf(t)]);var e=[];return t.forEach((function(t){"string"==typeof t?e.push(new hf(t)):e.push(t)})),new ff(e)}const bf={tools:{math:t,g2:o,color:l,css:h,html:c,misc:e,lines:a,m2:r,morph:s},Figure:Do,Recorder:Xo,FunctionMap:G,GlobalFunctionMap:V,SlideNavigator:Vh,FigureElement:ns,FigureElementCollection:rs,FigureElementPrimitive:is,DrawContext2D:vs,WebGLInstance:si,DrawingObject:$o,VertexGeneric:ma,TextObject:Fa,FigureText:Ba,FigureFont:Ea,HTMLObject:ta,CollectionsAngle:nh,CollectionsLine:Kc,CollectionsPolyline:uh,EquationLabel:jc,EquationForm:Al,Equation:Cc,HTMLEquation:function(){nf(e,ff);var t=of(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];return sf(this,e),t.call(this,[],n,i)}return uf(e,[{key:"createEq",value:function(t){var e=this,n=[];t.forEach((function(t){"string"==typeof t?n.push(new hf(t)):n.push(t),e.content=n}))}},{key:"htmlElement",value:function(){var t=document.createElement("div");return t.setAttribute("id",this.id),t.innerHTML=this.render(),this.classes.forEach((function(e){e&&t.classList.add(e)})),t}},{key:"el",value:function(t){return new hf(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",2<arguments.length&&void 0!==arguments[2]?arguments[2]:[])}},{key:"supsub",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[];return new pf(gf(t),gf(e),gf(n),i,r)}},{key:"sub",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new mf(gf(t),gf(e),n,i)}},{key:"sup",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new yf(gf(t),gf(e),n,i)}},{key:"frac",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new df(gf(t),gf(e),n,i)}},{key:"sqrt",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return new vf(gf(t),e,n)}}]),e}(),Animation:u,Point:pe,Line:Se,Rect:fe,Transform:Ee,Translation:_e,Scale:Pe,Rotation:Oe,parsePoint:ue,LineBounds:Ge,TransformBounds:$e,RectBounds:Ve,RangeBounds:Ue,minAngleDiff:be,getTriangleCenter:tn,polarToRect:Re,rectToPolar:Fe,threePointAngle:We,threePointAngleMin:ze,clipAngle:ae,getPoint:ue,getPoints:ce,getScale:he,getLine:ke,getRect:de,getTransform:Be,round:d,range:A,randSign:k,randInt:O,rand:_,randElement:P,randElements:M,removeRandElement:E,TimeKeeper:za}})(),i.default})()}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Fig",[],e):"object"==typeof exports?exports.Fig=e():t.Fig=e()}(self,(function(){return(()=>{"use strict";var t={477:t=>{t.exports=function(t,e,n,r){var i,o=self||window;try{try{try{i=new o.Blob([t])}catch(a){(i=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(t),i=i.getBlob()}var a=o.URL||o.webkitURL,s=a.createObjectURL(i),l=new o[e](s,n);return a.revokeObjectURL(s),l}catch(a){return new o[e]("data:application/javascript,".concat(encodeURIComponent(t)),n)}}catch(a){if(!r)throw Error("Inline worker is not supported");return new o[e](r,n)}}}},e={};function n(r){var i=e[r];return void 0!==i||(i=e[r]={exports:{}},t[r](i,i.exports,n)),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&((t=e.currentScript?e.currentScript.src:t)||(e=e.getElementsByTagName("script")).length&&(t=e[e.length-1].src)),!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})();var r={};return(()=>{n.d(r,{default:()=>Zd});var t={};n.r(t),n.d(t,{clipMag:()=>y,clipValue:()=>v,decelerate:()=>g,easein:()=>T,easeinout:()=>x,easeout:()=>S,linear:()=>b,rand:()=>E,rand2D:()=>R,randElement:()=>M,randElements:()=>j,randInt:()=>P,randSign:()=>O,range:()=>_,removeRandElement:()=>C,round:()=>m,roundNum:()=>p,sinusoid:()=>A,sinusoidAbs:()=>k,triangle:()=>w});var e={};n.r(e),n.d(e,{Console:()=>it,Notification:()=>Ft,NotificationManager:()=>It,ObjectKeyPointer:()=>at,ObjectTracker:()=>Bt,PerformanceTimer:()=>zt,UniqueMap:()=>St,addToObject:()=>lt,assignObjectFromTo:()=>ct,classify:()=>ot,cleanUIDs:()=>gt,compressObject:()=>Tt,copyKeysFromTo:()=>wt,deleteKeys:()=>bt,diffObjToPaths:()=>Rt,diffPathsToObj:()=>jt,download:()=>Dt,duplicate:()=>ut,duplicateFromTo:()=>dt,extractFrom:()=>st,generateRandomString:()=>xt,generateUniqueColor:()=>yt,generateUniqueId:()=>mt,getElement:()=>function(t,e){return st(t,e,"_","_")},getFromObject:()=>function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:".";return 0===e.length||e===n?t:void 0!==(n=st(t,e,"",n))?n.value():void 0},getObjectDiff:()=>Pt,hash32:()=>Wt,isTouchDevice:()=>vt,joinObjects:()=>ft,joinObjectsWithOptions:()=>ht,loadRemote:()=>function(t,e){var n,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;document.getElementById(t)?null!=r&&r(t,e):((n=document.createElement("script")).type="text/javascript",n.src=e,n.id=t,document.body&&document.body.appendChild(n),n.onload=function(){null!=r&&r(t,e)})},loadRemoteCSS:()=>function(t,e){var n,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;document.getElementById(t)?null!=r&&r(t,e):((n=document.createElement("link")).rel="stylesheet",n.type="text/css",n.href=e,n.id=t,document.body&&document.body.appendChild(n),n.onload=function(){null!=r&&r(t,e)})},minify:()=>kt,objectToPaths:()=>Ot,pathsToObj:()=>Mt,refAndDiffToObject:()=>Ct,splitString:()=>Lt,uncompressObject:()=>At,unminify:()=>_t,updateObjFromPath:()=>Et});var i={};n.r(i),n.d(i,{basisMatrix:()=>ge,basisToBasisMatrix:()=>ve,copy:()=>function(t){return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]]},directionToAxisAngle:()=>oe,dup:()=>function(t){return t.slice()},identity:()=>Qt,inverse:()=>be,lookAt:()=>pe,mul:()=>Jt,orthographic:()=>fe,perspective:()=>de,rotate:()=>function(t,e,n,r){return Jt(t,ee(e,n,r))},rotationMatrixAxis:()=>re,rotationMatrixDirection:()=>ie,rotationMatrixUnitAxis:()=>ne,rotationMatrixVectorToVector:()=>function(t,e){var n=Gt(t,e),r=Yt(t,e);return re(n,e=Math.acos(r/(Xt(t)*Xt(e))))},rotationMatrixX:()=>function(t){var e=Math.cos(t);return[1,0,0,0,0,e,-(t=Math.sin(t)),0,0,t,e,0,0,0,0,1]},rotationMatrixXYZ:()=>ee,rotationMatrixY:()=>function(t){var e=Math.cos(t);return[e,0,t=Math.sin(t),0,0,1,0,0,-t,0,e,0,0,0,0,1]},rotationMatrixZ:()=>function(t){var e=Math.cos(t);return[e,-(t=Math.sin(t)),0,0,t,e,0,0,0,0,1,0,0,0,0,1]},scale:()=>function(t,e,n,r){return[t[0]*e,t[1]*n,t[2]*r,t[3],t[4]*e,t[5]*n,t[6]*r,t[7],t[8]*e,t[9]*n,t[10]*r,t[11],t[12]*e,t[13]*n,t[14]*r,t[15]]},scaleMatrix:()=>le,transform:()=>ue,transformVector:()=>he,transformVectorT:()=>ce,translate:()=>function(t,e,n,r){return[t[0],t[1],t[2],t[3]+t[0]*e+t[1]*n+t[2]*r,t[4],t[5],t[6],t[7]+t[4]*e+t[5]*n+t[6]*r,t[8],t[9],t[10],t[11]+t[8]*e+t[9]*n+t[10]*r,t[12],t[13],t[14],t[15]+t[12]*e+t[13]*n+t[14]*r]},translationMatrix:()=>te,transpose:()=>Zt,vectorToVectorToAxisAngle:()=>se});var o={};n.r(o),n.d(o,{getCurveNormals:()=>Fn,getFlatNormals:()=>Bn,getLines:()=>Rn,getSurfaceNormals:()=>Cn,getTriangles:()=>jn,surface:()=>In});var a={};n.r(a),n.d(a,{Bounds:()=>vn,Line:()=>Ie,LineBounds:()=>wn,Plane:()=>He,Point:()=>Oe,RangeBounds:()=>gn,Rect:()=>En,RectBounds:()=>bn,Transform:()=>Qe,angleFromVectors:()=>function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return t=an(t),e=an(e),n=(e=Ge(se(t.toArray(),e.toArray(),null==n?null:Ae(n).toArray()),2))[0],e=e[1],{axis:Ae(n),angle:e}},cartesianToSpherical:()=>Ut,clipAngle:()=>Ee,comparePoints:()=>ur,cone:()=>Wn,cube:()=>$n,cylinder:()=>qn,decelerateValue:()=>_n,decelerateVector:()=>On,deg:()=>function(t){return 180*t/Math.PI},directionToAxisAngle:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[0,0,1];return e=(t=Ge(oe(an(t).toArray(),Ae(e).toArray()),2))[0],t=t[1],{axis:Ae(e),angle:t}},getBorder:()=>vr,getBoundingBorder:()=>fr,getBoundingRect:()=>hr,getBounds:()=>xn,getDeltaAngle:()=>Ce,getDeltaAngle3D:()=>function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=new Oe(0,0,0);return n="number"==typeof n||null==n?[n,n,n]:n,r.x=Ce(t.x,e.x,n[0]),r.y=Ce(t.y,e.y,n[1]),r.z=Ce(t.z,e.z,n[2]),r},getLathePoints:()=>Ln,getLine:()=>Fe,getMaxTimeFromVelocity:()=>dr,getMoveTime:()=>pr,getNormal:()=>Ue,getPlane:()=>qe,getPoint:()=>Ae,getPoints:()=>ke,getPositionInRect:()=>gr,getRect:()=>Mn,getScale:()=>_e,getTransform:()=>rn,getTriangleCenter:()=>yr,isBuffer:()=>cr,isParsablePlane:()=>function(t){try{Ne(t)}catch(t){return!1}return!0},isParsablePoint:()=>Te,isParsableTransform:()=>tn,isTransformArrayZero:()=>function(t){function e(t){return-r<t&&t<r}function n(t){for(var n=0;n<t.length;n+=1)if(!e(t[n]))return!1;return!0}var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-5;return"number"==typeof t?e(t):Array.isArray(t)?n(t):n(t=Object.values(t).filter((function(t){return null!=t})))},line3:()=>Nn,minAngleDiff:()=>Pe,normAngle:()=>Me,normAngleTo90:()=>function(t){return(t=Me(t))>Math.PI/2&&t<Math.PI&&(t+=Math.PI),(t=t===Math.PI?0:t)>Math.PI&&t<3*Math.PI/2&&(t-=Math.PI),t},numbersToPoints:()=>Kn,parsePoint:()=>Se,pointsToNumbers:()=>Un,polarToRect:()=>Ke,polygon:()=>ir,polygonLine:()=>function(t){var e=(l=tr(rr(t),9))[0],n=l[1],r=l[2],i=l[3],o=l[4],a=l[5],s=l[6],l=(t=l[7],l[8]),u=nr(e,n,r,i,o,a,t),c=nr(l,n,r,i,o,a);if(null==s){for(var h=Array(2*n),f=0;f<n;f+=1)h[2*f]=c[f],h[2*f+1]=u[f];return h}for(var d=Array(6*n),p=0;p<n-1;p+=1)d[6*p+0]=c[p],d[6*p+1]=u[p],d[6*p+2]=u[p+1],d[6*p+3]=c[p],d[6*p+4]=u[p+1],d[6*p+5]=c[p+1];return d[6*n-6]=c[n-1],d[6*n-5]=u[n-1],d[6*n-4]=u[0],d[6*n-3]=c[n-1],d[6*n-2]=u[0],d[6*n-1]=c[0],Un(d,s)},prism:()=>Qn,quadBezierPoints:()=>mr,randomPoint:()=>function(t){return t=R(t.left,t.bottom,t.right,t.top),new Oe(t.x,t.y)},rectToPolar:()=>Ve,revolve:()=>zn,spaceToSpaceScale:()=>function(t,e){var n=e.x.width/t.x.width,r=e.y.height/t.y.height;return t=e.z.height/t.z.height,new Oe(n,r,t)},spaceToSpaceTransform:()=>lr,sphere:()=>Dn,sphericalToCartesian:()=>Kt,surface:()=>o,surfaceGrid:()=>br,threePointAngle:()=>je,threePointAngleMin:()=>Re,toDelta:()=>Le,toNumbers:()=>Vn,toPoints:()=>Gn});var s={};n.r(s),n.d(s,{copy:()=>function(t){return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]},identity:()=>function(){return[1,0,0,0,1,0,0,0,1]},inverse:()=>function(t){var e=1/(t[0]*(t[4]*t[8]-t[7]*t[5])-t[1]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*t[7]-t[4]*t[6]));return[(t[4]*t[8]-t[7]*t[5])*e,(t[2]*t[7]-t[1]*t[8])*e,(t[1]*t[5]-t[2]*t[4])*e,(t[5]*t[6]-t[3]*t[8])*e,(t[0]*t[8]-t[2]*t[6])*e,(t[3]*t[2]-t[0]*t[5])*e,(t[3]*t[7]-t[6]*t[4])*e,(t[6]*t[1]-t[0]*t[7])*e,(t[0]*t[4]-t[3]*t[1])*e]},mul:()=>wr,rotate:()=>function(t,e){var n=Math.cos(e);return e=Math.sin(e),[t[0]*n+t[1]*e,t[0]*-e+t[1]*n,t[2],t[3]*n+t[4]*e,t[3]*-e+t[4]*n,t[5],t[6]*n+t[7]*e,t[6]*-e+t[7]*n,t[8]]},rotationMatrix:()=>function(t){var e=Math.cos(t);return[e,-(t=Math.sin(t)),0,t,e,0,0,0,1]},scale:()=>function(t,e,n){return[t[0]*e,t[1]*n,t[2],t[3]*e,t[4]*n,t[5],t[6]*e,t[7]*n,t[8]]},scaleMatrix:()=>function(t,e){return[t,0,0,0,e,0,0,0,1]},t:()=>function(t){return[t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]]},transform:()=>function(t,e,n){return[t[0]*e+t[1]*n+t[2],t[3]*e+t[4]*n+t[5]]},translate:()=>function(t,e,n){return[t[0],t[1],t[2]+t[0]*e+t[1]*n,t[3],t[4],t[5]+t[3]*e+t[4]*n,t[6],t[7],t[8]+t[6]*e+t[7]*n]},translationMatrix:()=>function(t,e){return[1,0,t,0,1,e,0,0,1]}});var l={};n.r(l),n.d(l,{addArrows:()=>oi,joinLinesInPoint:()=>Jr,joinLinesInTangent:()=>Zr,lineSegmentsToPoints:()=>$r,makeFastPolyLine:()=>ai,makePolyLine:()=>ri,makePolyLineCorners:()=>ii});var u={};n.r(u),n.d(u,{circleCloudShapes:()=>function(t){for(var e=ft({},{radius:1,position:[0,0],num:10,size:.01,shape:hi.bind(this)},t),n=Ae(e.position),r=[],i=di(e.shape),o=0;o<e.num;o+=1){var a=E(0,2*Math.PI),s=E(E(0,e.radius/2),e.radius);r.push.apply(r,li(i([s*Math.cos(a)+n.x,s*Math.sin(a)+n.y],e.size)))}return r},getPixels:()=>mi,getPolygonCorners:()=>function(t){for(var e=ft({},{sides:4,rotation:0,radius:1,position:[0,0],direction:1},t),n=Ae(e.position),r=[],i=2*Math.PI/e.sides,o=0;o<e.sides;o+=1)r.push(new Oe(e.radius*Math.cos(e.direction*(i*o+e.rotation))+n.x,e.radius*Math.sin(e.direction*(i*o+e.rotation))+n.y));return r},imageToShapes:()=>function(t){var e,n,r,i,o=ht({except:"image"},{},{num:null,xAlign:"center",yAlign:"middle",align:"image",distribution:"random",filter:function(){return!0},position:[0,0],dither:0,width:null,height:null,excess:"repeatOpaqueOnly",shape:"square",makeColors:pi.bind(this)},t),a=(c=t.image).height,s=c.width,l=o.filter,u=di(o.shape),c=(t=mi((n=(e=c).width,r=e.height,(i=document.createElement("canvas")).width=n,i.height=r,(i=i.getContext("2d")).drawImage(e,0,0),i.getImageData(0,0,n,r).data),s,a,l)).min,h=(l=t.max,t.pixels),f=t.pixelColors,d=h.length;null!=o.num&&(d=o.num),s-=1,a-=1;var p=[0,0];"filteredImage"===o.align&&(s=l[0]-c[0],a=l[1]-c[1],p=[-c[0],c[1]]),l=o.width;var m=o.height;null==o.height&&null==o.width?l=(m=1)/a*s:null!=o.height&&null==o.width?l=o.height/a*s:null!=o.width&&null==o.height&&(m=o.width/s*a);var y=l/s,v=m/a,g=(c=Ae(o.position),s=o.xAlign,a=o.yAlign,new Oe(0,0));"left"===s?g.x=c.x:"right"===s?g.x=c.x-l:"center"===s?g.x=c.x-l/2:"number"==typeof s?g.x=c.x+l*s:null!=s&&"o"===s.slice(-1)[0]&&(g.x=c.x+parseFloat(s)),"top"===a?g.y=c.y-m:"bottom"===a?g.y=c.y:"middle"===a?g.y=c.y-m/2:"number"==typeof a?g.y=c.y-m*a:null!=a&&"o"===a.slice(-1)[0]&&(g.y=c.y-parseFloat(a));for(var b=[],w=[],x=Array(h.length),S=[],T=0;T<h.length;T+=1).99999999<=f[x[T]=T][3]&&S.push(T);for(var A=x.slice(),k=Array(A.length),_=0;_<k.length;_+=1)k[_]=[E(-o.dither,o.dither),E(-o.dither,o.dither)];for(var O=0;O<d;O+=1){var M=(A=0===A.length?"lastOpaque"===o.excess?Array(d-O).fill(S.slice(-1)[0]):("repeatOpaqueOnly"===o.excess?S:x).slice():A)[0];"random"===o.distribution?(M=A[j=P(0,A.length-1)],A.splice(j,1)):A.splice(0,1);var C=h[M],j=f[M];M=u(C=new Oe(g.x+C[0]*y+p[0]*y+k[M][0],g.y+m-C[1]*v+p[1]*v+k[M][1]),o.size||y),C=[],null!=o.makeColors&&(C=o.makeColors(j,M.length/2)),b.push.apply(b,li(M)),w.push.apply(w,li(C))}return[b,w]},pointsToShapes:()=>function(t){for(var e=ft({},{size:.01,shape:hi.bind(this),makeColors:null},t),n=di(e.shape),r=[],i=[],o=0;o<e.points.length;o+=1){var a=Ae(e.points[o]),s=n(a,e.size),l=[];null!=e.makeColors&&(l=e.makeColors(s.length/2,a)),r.push.apply(r,li(s)),i.push.apply(i,li(l))}return[r,i]},polygonCloudShapes:()=>function(t){for(var e=ft({},{sides:4,rotation:0,radius:1,position:[0,0],num:10,size:.01,shape:hi.bind(this)},t),n=Ae(e.position),r=[],i=e.radius*Math.cos(Math.PI/e.sides),o=di(e.makePoints),a=0;a<e.num;a+=1){var s=E(0,2*Math.PI),l=2*Math.PI/e.sides,u=Math.floor(s/l)*l;l=Math.abs(s-u-l/2),l=E(E(0,(l=i/Math.cos(l))/2),l),r.push.apply(r,li(o([l*Math.cos(s+e.rotation)+n.x,l*Math.sin(s+e.rotation)+n.y],e.size)))}return r},polyline:()=>function(t){var e,n=ht({except:"points"},{},{num:null,close:!1,width:.01,simple:!1},t),r=t.points.map(Ae);t=0,null==n.num?t=(e=r).length:e=(t=si(yi(r,t=n.num,n.close),1))[0];var i=si(ai(e,n.width,n.close),1)[0];n.close&&i.splice(-2,2),i=i.map((function(t){return t.round()}));for(var o=n.simple?Array(6*i.length*2):n.close?Array(12*i.length*2+6):Array(12*i.length*2),a=0,s=function(t,e,n,r,i,s){o[a]=t.x,o[a+1]=t.y,o[a+2]=e.x,o[a+3]=e.y,o[a+4]=n.x,o[a+5]=n.y,o[a+6]=r.x,o[a+7]=r.y,o[a+8]=i.x,o[a+9]=i.y,o[a+10]=s.x,o[a+11]=s.y,a+=12},l=0;l<i.length-2;l+=4){var u=[i[l],i[l+1],i[l+2],i[l+3]];s(u[0],u[1],u[2],u[1],u[3],u[2]),!n.simple&&l<i.length-4?s(u[2],u[3],i[l+4],u[2],u[3],i[l+5]):!n.simple&&n.close&&s(u[2],u[3],i[0],u[2],u[3],i[1])}return o},polylineToShapes:()=>function(t){for(var e=ft({},{close:!1,size:.01,shape:hi.bind(this),makeColors:null},t),n=di(e.shape),r=[],i=[],o=(t=si(yi(t=e.points.map(Ae),e.num,e.close),3))[0],a=t[1],s=t[2],l=0;l<o.length;l+=1){var u=o[l],c=n(u,e.size),h=[],f=l*s;null!=e.makeColors&&(h=e.makeColors(c.length/2,u,f,f/a)),r.push.apply(r,li(c)),i.push.apply(i,li(h))}return[r,i]},rectangleCloudShapes:()=>function(t){for(var e=ft({},{width:1,height:1,position:[0,0],num:10,size:.01,shape:hi.bind(this)},t),n=Ae(e.position),r=[],i=di(e.shape),o=0;o<e.num;o+=1){var a=E(-e.width/2,e.width/2)+n.x,s=E(-e.height/2,e.height/2)+n.y;r.push.apply(r,li(i([a,s],e.size)))}return r}});var c={};n.r(c),n.d(c,{HexToArray:()=>Qi,RGBToArray:()=>Zi,areColorsSame:()=>ro,areColorsWithinDelta:()=>io,colorArrayToRGB:()=>function(t){return"rgb(".concat(Math.floor(255*t[0]),",").concat(Math.floor(255*t[1]),",").concat(Math.floor(255*t[2]),")")},colorArrayToRGBA:()=>no,colorToInt:()=>eo,cssColorToArray:()=>to,getCSSColors:()=>Ji});var h={};n.r(h),n.d(h,{AnimationBuilder:()=>Ul,AnimationManager:()=>Il,AnimationStep:()=>ji,ColorAnimationStep:()=>Ro,CustomAnimationStep:()=>Na,DelayAnimationStep:()=>rs,DimAnimationStep:()=>Bo,DissolveInAnimationStep:()=>Go,DissolveOutAnimationStep:()=>Yo,OpacityAnimationStep:()=>Vo,ParallelAnimationStep:()=>fo,PositionAnimationStep:()=>Ui,PulseAnimationStep:()=>Aa,PulseTransformAnimationStep:()=>aa,RotationAnimationStep:()=>fa,ScaleAnimationStep:()=>ga,ScenarioAnimationStep:()=>So,SerialAnimationStep:()=>Xa,TransformAnimationStep:()=>ta,TriggerAnimationStep:()=>ja,UndimAnimationStep:()=>Fo,custom:()=>function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Fa(Na,e)},delay:()=>is,dim:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Ao(Bo,[t].concat(n))},dissolveIn:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Do(Go,[t].concat(n))},dissolveOut:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Do(Yo,[t].concat(n))},inParallel:()=>po,inSerial:()=>$a,trigger:()=>Ra,undim:()=>function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Ao(Fo,[t].concat(n))}});var f={};n.r(f),n.d(f,{actionWord:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:mt(),n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i="action_word";return r&&(i="".concat(i," interactive_word")),r=null,{replacementText:Zl(t,e,i="string"==typeof n?"".concat(n," ").concat(i):i,r=Array.isArray(n)?n:r).replacementText,id:e}},addClass:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return{replacementText:function(e){return Zl(e,"",t)}}},addId:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return{replacementText:function(e){return Zl(e,t)}}},applyModifiers:()=>eu,centerH:()=>$l,centerV:()=>Xl,centerVH:()=>function(){var t=Yl(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",0);return'<div style="display: table; height: 100%; text-align:center; width:100%;">\n <div style="display: table-cell; vertical-align: middle; height: 100%; width: 100%;">\n '.concat(t,"</div></div>")},click:()=>Ql,clickW:()=>function(t,e,n){return Ql(e,n,{color:3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,text:t})},highlight:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e="highlight_word";"string"==typeof t&&(e="".concat(t," ").concat(e));var n=null;return Array.isArray(t)&&(n=t),{replacementText:function(t){return Zl(t,"",e,n)}}},highlightWord:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n="highlight_word",r=null;return{replacementText:Zl(t,"",n="string"==typeof e?"".concat(e," ").concat(n):n,r=Array.isArray(e)?e:r).replacementText}},itemSelector:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[""],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n='<ul id="id__figureone_item_selector_'.concat(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,'" \n class=').concat(e,">");return t.forEach((function(t,e){n+='<li id="id__figureone_item_selector_'.concat(e,'">').concat(t,"</li>")})),n+="</ul>"},link:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n="action_word interactive_word",r=null,i=a={color:null,id:"figureone__id_".concat(mt()),interactive:!0,classes:"",text:null,newTab:!0};Array.isArray(e)?r=e:null!=e&&(i=ft(a,e));var o=i,a=o.color,s=o.id,l=(e=o.classes,o.text);null!=a&&(r=a),""!==e&&(n="".concat(n," ").concat(e));var u=i.newTab?' target="_blank"':"";return{replacementText:function(e){var i=s?' id="'.concat(s,'"'):"",o=r?' style="color:'.concat(no(r),';"'):"";return{replacementText:"<a href=".concat(t).concat(i,'class="').concat(n,'"').concat(o,' rel="noreferrer noopener"').concat(u,">").concat((l||e).trim(),"</a>")}},id:function(){return s}}},onClickId:()=>tu,setHTML:()=>ru,setOnClicks:()=>nu,style:()=>function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n="",r="",i="",o="",a="",s="",l="",u="",c="";"number"==typeof t?i="margin-top:".concat(t,"%"):(null!=t.left&&(n="margin-left:".concat(t.left,"%;")),null!=t.right&&(r="margin-right:".concat(t.right,"%;")),t.centerV&&(i="margin-top:0;"),null!=t.top&&(i="margin-top:".concat(t.top,"%;")),null!=t.line&&(o="margin-top:".concat(t.line,"%;")),null!=t.size&&(a="font-size:".concat(t.size,"em;")),t.className&&(s='class="'.concat(t.className,'"')),t.color&&(l="color:".concat(no(t.color),";")),t.listStyleType&&(u="list-style-type:".concat(t.listStyleType,";")),t.id&&(c='id="'.concat(t.id,'"')));var h='<p style="'.concat(n).concat(r).concat(o).concat(a).concat(l,'"').concat(s,">"),f='<p style="'.concat(n).concat(r).concat(i).concat(a).concat(l,'"').concat(s).concat(c,">"),d=(o='<li style="'.concat(n).concat(r).concat(o).concat(a).concat(l).concat(u,'"').concat(s,">"),u='<ul style="'.concat(n).concat(r).concat(i).concat(a).concat(l,'"').concat(s).concat(c,">"),c='<ol style="'.concat(n).concat(r).concat(i).concat(a).concat(l,'"').concat(s).concat(c,">"),null!=t.list?(d=Array.isArray(e)?e.join("</li>".concat(o)):e,"unordered"===t.list?"".concat(u).concat(o).concat(d,"</ul>"):"".concat(c).concat(o).concat(d,"</ol>")):(d=Array.isArray(e)?e.join("</p>".concat(h)):e,"".concat(f).concat(d,"</p>")));return t.centerH&&(d=$l(d)),t.centerV?Xl(d):d},toHTML:()=>Zl,unit:()=>Jl,withClass:()=>function(){var t=1<arguments.length?arguments[1]:void 0,e=Yl(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"");return'<div class="'.concat(t,'">').concat(e,"</div>")}});var d={};n.r(d),n.d(d,{getCSSColors:()=>Ji,getCSSVariables:()=>function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r={},i=t;if((i="string"==typeof t?document.getElementById(t):i)instanceof HTMLElement){var o=window.getComputedStyle(i);if(o)for(var a=o.length,s=0;s<a;s+=1){var l,u,c,h=o[s];""!==e&&!h.startsWith(e)||null!=(u=o.getPropertyValue(h))&&(u=u.trim(),l=parseFloat(u),Number.isNaN(l)||(u=l),n?r[c=Vi(h,e)]=u:(c=new RegExp(e,"g"),lt(r,c=h.replace(c,""),u,"-")))}}return r},getDefinedCSSVariables:()=>Gi,searchObject:()=>function t(e,n,r){var i=[];return Object.keys(e).forEach((function(o){var a,s="".concat(n,".").concat(o);o.includes(r)?i.push(s):"object"===Ki(e[o])?(a=t(e[o],s,r))&&(i=i.concat(a)):"string"==typeof e[o]&&e[o].includes(r)&&i.push(s)})),i}});var p=function(t){var e=Math.pow(10,1<arguments.length&&void 0!==arguments[1]?arguments[1]:5);return-0!=(t=Math.round(t*e)/e)||0===t&&1/t!=-1/0?t:0};function m(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5;return Array.isArray(t)?t.map((function(t){return m(t,e)})):"number"==typeof t?p(t,e):null!=t&&null!=t.round?t.round(e):t}function y(t,e,n){var r=t;return e=e,null===n?t:(-(e=(e=null===e?0:e)<0?-e:e)<=t&&t<=e&&(r=0),(n=n<0?-n:n)<t&&(r=n),t<-n?-n:r)}function v(t,e,n){return null!==n&&n<t?n:null!==e&&t<e?e:t}var g=function(t,e,n,r,i){var o=0,a=0;return 0===y(e,o=null!==i?i:o,e)?{p:t,v:0}:(i=a=null!==n?n:a,a<0&&(i=-i),0===(a=(a=e-(n=e/Math.abs(e))*i*r)/Math.abs(a)!=n?0:y(a,o,a))&&(o/Math.abs(o)!=n&&(o=-o),r=Math.abs((o-e)/i)),{p:t+e*r-.5*n*i*r*r,v:a})},b=function(t){return t};function w(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+2*(3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)/Math.PI*Math.asin(Math.sin(2*Math.PI*e*t+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0)))}var x=function(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(.5===t)return.5;var e=t;return(2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)}return Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))};function S(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(0===t)return 0;var e=t/2+.5;return 2*((2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)-.5)}return t=.5+t/2,2*(Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))-.5)}function T(t){if(1<arguments.length&&void 0!==arguments[1]&&arguments[1]){if(1===t)return 1;var e=t/2;return(2*e-Math.sqrt(-4*e*e+4*e))/(4*e-2)*2}return t/=2,Math.pow(t,2)/(Math.pow(t,2)+Math.pow(1-t,2))*2}function A(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+(3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)*Math.sin(t*e*2*Math.PI+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0))}function k(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+Math.abs((3<arguments.length&&void 0!==arguments[3]?arguments[3]:1)*Math.sin(t*e*2*Math.PI+(4<arguments.length&&void 0!==arguments[4]?arguments[4]:0)))}function _(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:8,i=[];if(t<e){if(n<=0)return[];for(var o=t;o<=e;o=m(o+n,r))i.push(o)}else{if(0<=n)return[];for(var a=t;e<=a;a=m(a+n,r))i.push(a)}return i}function O(){return.5<Math.random()?1:-1}function P(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=0;return i=null!=n?(e=t,Math.floor(Math.random()*Math.floor(n-e)+Math.floor(e))):Math.floor(Math.random()*Math.floor(t)),r&&(i*=O()),i}function E(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=0;return i=null!=n?(e=t,Math.random()*(n-e)+e):Math.random()*t,r&&(i*=O()),i}function M(t){return t[P(t.length)]}function C(t){var e=E(t.length);return t.splice(e,1)[0]}function j(t,e){for(var n=_(0,e.length-1,1),r=[],i=0;i<t;i+=1){var o=C(n);r.push(e[o])}return r}function R(t,e,n,r){return{x:E(t,n),y:E(e,r)}}function B(t){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function F(t,e,n){return(F="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=N(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function I(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&D(t,e)}function D(t,e){return(D=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function L(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=N(t);return z(this,e?(n=N(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function z(t,e){if(e&&("object"===B(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return W(t)}function W(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function N(t){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function q(t){return function(t){if(Array.isArray(t))return H(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return H(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?H(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function U(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function K(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function V(t,e,n){return e&&K(t.prototype,e),n&&K(t,n),t}var G=function(){function t(){U(this,t),this.map={}}return V(t,[{key:"add",value:function(t,e){null==this.map&&(this.map={}),this.map[t]={fn:e}}},{key:"exec",value:function(t){if(null==t)return null;for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if("string"==typeof t&&null!=this.map[t])return 0===r.length?this.map[t].fn():(e=this.map[t]).fn.apply(e,r);if("function"==typeof t)return t.apply(void 0,r);throw new Error("".concat(t," needs to be a function or a string"))}},{key:"execOnMaps",value:function(t,e){if(null==t)return null;for(var n=arguments.length,r=new Array(2<n?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if("string"==typeof t){for(var o=[this.map].concat(q(e)),a=0;a<o.length;a+=1){var s=o[a];if(null!=s[t])return 0===r.length?s[t].fn():(s=s[t]).fn.apply(s,r)}throw new Error("FunctionMap Error: '".concat(t,"' does not exist in map"))}if("function"==typeof t)return t.apply(void 0,r);throw new Error("FunctionMap Error: '".concat(t,"' needs to be a function or a string"))}}]),t}(),Y=function(){I(e,G);var t=L(e);function e(){var n;return U(this,e),e.instance||(n=t.call(this),e.instance=W(n),n.map={}),z(n,e.instance)}return e}(),X=function(){I(e,G);var t=L(e);function e(){var n;return U(this,e),(n=t.call(this)).global=new Y,n}return V(e,[{key:"exec",value:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return this.execOnMaps.apply(this,[t,[this.global.map]].concat(n))}},{key:"execOnMaps",value:function(t,n){for(var r,i=arguments.length,o=new Array(2<i?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];return(r=F(N(e.prototype),"execOnMaps",this)).call.apply(r,[this,t,[].concat(q(n),[this.global.map])].concat(o))}},{key:"add",value:function(t,n){return F(N(e.prototype),"add",this).call(this,t,n)}}]),e}();function $(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Z(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(t){return function(t){if(Array.isArray(t))return Q(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Z(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Z(t,e){if(t){if("string"==typeof t)return Q(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Q(t,e):void 0}}function Q(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function tt(t){return(tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function et(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function nt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function rt(t,e,n){return e&&nt(t.prototype,e),n&&nt(t,n),t}var it=function(){var t;(t=console).log.apply(t,arguments)},ot=function(t,e){return e="-"===(e=e||t)[0]||e.startsWith("".concat(t,"-"))?"".concat(t," ").concat(e):e,t=" ".concat(t,"-"),"".concat(e.split(" -").join(t))},at=function(){function t(e,n){et(this,t),this.object=e,this.key="",n in e&&(this.key=n)}return rt(t,[{key:"setValue",value:function(t){this.key&&(this.object[this.key]=t)}},{key:"execute",value:function(){if(this.key){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.object[this.key].apply(null,e)}}},{key:"value",value:function(){if(this.key)return this.object[this.key]}}]),t}();function st(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"_",i=[];if("string"!=typeof e)return Array.isArray(e)?e.forEach((function(e){void 0!==(e=st(t,e,n,r))&&i.push(e)})):Object.keys(e).forEach((function(r){n+r in t&&i.push({obj:new at(t,n+r),value:e[r]})})),i;if(n+e in t)return new at(t,n+e);var o=e.split(r).filter((function(t){return 0<t.length})),a="".concat(n).concat(o[0]);if(1<o.length){if(a in t)return st(t[a],o.slice(1).join(r),n,r)}else if(1===o.length&&a in t)return new at(t,a)}function lt(t,e,n){var r=e.split(3<arguments.length&&void 0!==arguments[3]?arguments[3]:".").filter((function(t){return 0<t.length})),i=t;r.forEach((function(t,e){e!==r.length-1?(Object.prototype.hasOwnProperty.call(i,t)||(i[t]={}),i=i[t]):i[t]=n}))}function ut(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if("number"==typeof t&&null!=e)return p(t,e);if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t||NaN===t||"function"==typeof t)return t;if("function"==typeof t._dup)return t._dup();if(Array.isArray(t)){var n=[];return t.forEach((function(t){return n.push(ut(t,e))})),n}var r={};return Object.keys(t).forEach((function(n){var i=ut(t[n],e);r[n]=i})),r}function ct(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"",o="string"==typeof n?[n]:n;Object.keys(t).forEach((function(n){var a,s,l=""!==i?"".concat(i,".").concat(n):n;-1===o.indexOf(l)&&("object"===tt(a=t[n])&&null!=a&&a._assignAsLinkOnly?e[n]=t[n]:"number"==typeof a||"boolean"==typeof a||"string"==typeof a||null==a||"function"==typeof a||"function"==typeof a._dup||Array.isArray(a)?void 0===a&&void 0!==e[n]||(e[n]=r?ut(a):a):("number"!=typeof(s=e[n])&&"boolean"!=typeof s&&"string"!=typeof s&&null!=s&&"function"!=typeof s&&!Array.isArray(s)||(e[n]={}),ct(a,e[n],o,r,l)))}))}function ht(t){var e=t.except,n=t.duplicate;null==e&&(e=[]),null==n&&(n=!1);for(var r=arguments.length<=1?0:arguments.length-1,i=arguments.length<=1?void 0:arguments[1],o=1;o<r;o+=1){var a=o+1<1||arguments.length<=o+1?void 0:arguments[o+1];null!=a&&ct(a,i,e,n,"")}return i}function ft(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ht.apply(void 0,[{}].concat(e))}function dt(t,e){ht({except:2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],duplicate:!0},e,t)}var pt=function(){function t(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(et(this,t),e)return t.instance||(t.instance=this).initialize(),t.instance;this.initialize()}return rt(t,[{key:"initialize",value:function(){this.seeds={},this.colorSeeds={}}},{key:"getId",value:function(t){null==this.seeds[t]&&(this.seeds[t]=0);var e,n="".concat(t).concat((e=9-(n=this.seeds[t]).toString().length+1,Array(+(0<e&&e)).join("0")+n));return this.seeds[t]+=1,n}},{key:"getColor",value:function(t){var e=[[255,0,0,255],[0,255,0,255],[0,0,255,255],[255,0,255,255],[0,255,255,255],[255,255,0,255],[100,0,0,255],[0,100,0,255],[0,0,100,255],[100,0,100,255],[0,100,100,255],[100,100,0,255]];null==this.colorSeeds[t]&&(this.colorSeeds[t]=0);var n=this.colorSeeds[t];if(n<e.length)return this.colorSeeds[t]+=1,e[n];var r=[n>>0&255,n>>8&255,n>>16&255,255];if(!(255!==r[0]&&0!==r[0]&&100!==r[0]||255!==r[1]&&0!==r[1]&&100!==r[1]||255!==r[2]&&0!==r[2]&&100!==r[2]||255!==r[3]&&0!==r[3]&&100!==r[3]))for(var i=0;i<e.length;i+=1)if(e[i][0]===r[0]&&e[i][1]===r[1]&&e[i][2]===r[2]&&e[i][3]===r[3])return this.colorSeeds[t]+=1,this.getColor(t);return this.colorSeeds[t]+=1,r}}]),t}();function mt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return(new pt).getId(t)}function yt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return(new pt).getColor(t)}function vt(){var t=" -webkit- -moz- -o- -ms- ".split(" ");return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)||(t=["(",t.join("touch-enabled),("),"heartz",")"].join(""),window.matchMedia(t).matches)}var gt=function t(e){var n="0000000000";if(null!=e){if("uid"in e){if(e.uid===n)return;e.uid=n}for(var r=Object.keys(e),i=0;i<r.length;i+=1){var o=r[i],a=e[o];"object"!==tt(a)||Array.isArray(a)||null==a||"function"==typeof a||"number"==typeof a||"boolean"==typeof a||"string"==typeof a||"figure"===o||t(a),"recorder"===o&&null!=e.recorder&&(e.recorder.figure=null)}}};function bt(t,e){e.forEach((function(e){void 0!==t[e]&&delete t[e]}))}function wt(t,e,n){n.forEach((function(n){void 0!==t[n]&&(e[n]=t[n])}))}function xt(){return(1e18*Math.random()).toString(36)}var St=function(){function t(){et(this,t),this.map={},this.index=1,this.inverseMap={},this.letters="0abcdefghijklmnopqrstuvwxz",this.undefinedCode=".a"}return rt(t,[{key:"reset",value:function(){this.index=1,this.map={}}},{key:"add",value:function(t){if(null!=this.map[t])return this.map[t];var e=this.getNextUniqueString();return this.map[t]=e}},{key:"getNextUniqueString",value:function(){if(0===this.index)return"a";for(var t=Math.floor(Math.log(this.index)/Math.log(this.letters.length)),e=this.index,n="",r=t;0<=r;--r){var i=Math.floor(e/Math.pow(this.letters.length,r));e-=i*Math.pow(this.letters.length,r),n="".concat(n).concat(this.letters[i])}return this.index+=1,n}},{key:"makeInverseMap",value:function(){var t=this;this.inverseMap={},Object.keys(this.map).forEach((function(e){var n=t.map[e];t.inverseMap[n]=e}))}},{key:"get",value:function(t){if(t!==this.undefinedCode)return null!=this.inverseMap[t]?this.inverseMap[t]:t}}]),t}();function Tt(t,e){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]&&arguments[5];if("string"==typeof t)return r&&o?e.get(t):r?e.add(t):t;if("number"==typeof t)return null===i||o?t:p(t,i);if("boolean"==typeof t||"function"==typeof t||null===t)return t;if(void 0===t)return e.undefinedCode;if(Array.isArray(t)){for(var a=0;a<t.length;a+=1)t[a]=Tt(t[a],e,n,r,i,o);return t}if("object"!==tt(t))return t;for(var s=Object.keys(t),l={},u=0;u<s.length;u+=1){var c,h=s[u];t[h]=Tt(t[h],e,n,r,i,o),n&&o?null!=(c=e.get(h))&&(l[c]=t[h]):n?l[e.add(h)]=t[h]:l[h]=t[h]}return l}function At(t,e){return Tt(t,e,!(2<arguments.length&&void 0!==arguments[2])||arguments[2],!(3<arguments.length&&void 0!==arguments[3])||arguments[3],null,!0)}function kt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:4,n=new St;return{minified:Tt(t,n,!0,!0,e),map:n}}function _t(t){var e,n=t.map;return n instanceof St||((e=new St).map=n.map,e.index=n.index,e.letters=n.letters,n=e),n.makeInverseMap(),At(t.minified,n,!0,!0)}function Ot(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return"string"==typeof t||"boolean"==typeof t||"function"==typeof t?n["".concat(e)]=t:"number"==typeof t?n["".concat(e)]=null!=r?p(t,r):t:null===t?n["".concat(e)]=null:void 0===t||(Array.isArray(t)?t.forEach((function(t,i){Ot(t,"".concat(e,"[").concat(i,"]"),n,r)})):Object.keys(t).forEach((function(i){Ot(t[i],"".concat(e,".").concat(i),n,r)}))),n}function Pt(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]&&arguments[4],o=t,a=Ot(o=0<e.length?Ct.apply(void 0,[t].concat(J(e))):o,"",{},r),s=Ot(n,"",{},r),l={},u={},c={};return Object.keys(a).forEach((function(t){void 0!==s[t]?a[t]!==s[t]&&(u[t]=i?[a[t],s[t]]:s[t]):c[t]=a[t]})),Object.keys(s).forEach((function(t){void 0===a[t]&&(l[t]=s[t])})),r={},0<Object.keys(u).length&&(r.diff=u),0<Object.keys(l).length&&(r.added=l),0<Object.keys(c).length&&(r.removed=c),r}function Et(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]&&arguments[3];if(0!==(o=t[0]).length){var i=o.match(/\[[^\]]*\]/g),o=o.replace(/\[.*/,"");if(1!==t.length||!r||i){if(i){var a=i.map((function(t){return parseInt(t.replace(/\[|\]/g,""),10)}));null!=e[o]&&Array.isArray(e[o])||(e[o]=[]);for(var s=e[o],l=0,u=0;u<a.length;u+=1){if(l=a[u],s.length<=l)for(var c=s.length;c<l-s.length+1;c+=1)s.push(void 0);u<a.length-1&&(Array.isArray(s[l])||(s[l]=[]),s=s[l])}return 1===t.length&&r?void(s[l]=void 0):1===t.length?void(s[l]=n):(null!=s[l]&&"object"===tt(s[l])||(s[l]={}),void Et(t.slice(1),s[l],n,r))}1!==t.length?(null==e[o]&&(e[o]={}),Et(t.slice(1),e[o],n,r)):e[o]=n}else delete e[o]}}function Mt(t){var e={};return Object.keys(t).forEach((function(n){var r=n.split(".").filter((function(t){return 0<t.length}));n=t[n],Array.isArray(n)?Et(r,e,n.slice(-1)[0]):Et(r,e,n)})),e}function Ct(t){for(var e=ut(t),n=function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];Object.keys(t).forEach((function(r){var i=r.split(".").filter((function(t){return 0<t.length}));r=t[r],Array.isArray(r)?Et(i,e,r.slice(-1)[0],n):Et(i,e,r,n)}))},r=arguments.length,i=new Array(1<r?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i.forEach((function(t){var e=t.added,r=t.removed;t=t.diff,null!=r&&n(r,!0),null!=e&&n(e),null!=t&&n(t)})),e}function jt(t){var e={};return t.diff&&0<Object.keys(t.diff).length&&(e.diff=Mt(t.diff)),t.added&&0<Object.keys(t.added).length&&(e.added=Mt(t.added)),t.removed&&0<Object.keys(t.removed).length&&(e.removed=Mt(t.removed)),e}function Rt(t){var e={};return t.diff&&0<Object.keys(t.diff).length&&(e.diff=Ot(t.diff)),t.added&&0<Object.keys(t.added).length&&(e.added=Ot(t.added)),t.removed&&0<Object.keys(t.removed).length&&(e.removed=Ot(t.removed)),e}var Bt=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;et(this,t),this.precision=e,this.reset()}return rt(t,[{key:"toObj",value:function(){var t=this,e={};Object.keys(this.references).forEach((function(n){e[n]={basedOn:t.references[n].basedOn,diff:jt(t.references[n].diff)}}));var n=this.diffs.map((function(t){return[t[0],t[1],jt(t[2]),t[3]]}));return{baseReference:ut(this.baseReference),diffs:n,references:e,precision:this.precision,lastReferenceName:this.lastReferenceName}}},{key:"setFromObj",value:function(t){var e={};Object.keys(t.references).forEach((function(n){e[n]={basedOn:t.references[n].basedOn,diff:Rt(t.references[n].diff)}})),this.references=e,this.baseReference=ut(t.baseReference),this.precision=t.precision,this.diffs=t.diffs.map((function(t){return[t[0],t[1],Rt(t[2]),t[3]]})),this.lastReferenceName=t.lastReferenceName}},{key:"reset",value:function(){this.baseReference=null,this.references={},this.diffs=[],this.lastReferenceName="__base"}},{key:"setBaseReference",value:function(t){this.baseReference=ut(t),this.lastReferenceName="__base"}},{key:"addReference",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"__base";null!=this.baseReference&&"__base"!==e||this.setBaseReference(t),"__base"!==e&&(this.references[e]={diff:this.getDiffToReference(t,n),basedOn:n},this.lastReferenceName=e)}},{key:"getReferenceChain",value:function(t,e){return"__base"===t||null==this.references[t]?e:this.getReferenceChain(this.references[t].basedOn,[this.references[t].diff].concat(J(e)))}},{key:"getReference",value:function(t){return t=this.getReferenceChain(t,[]),Ct.apply(void 0,[this.baseReference].concat(J(t)))}},{key:"getDiffToReference",value:function(t,e){return e=this.getReferenceChain(e,[]),Pt(this.baseReference,e,t,this.precision)}},{key:"getObjFromDiffAndReference",value:function(t,e){return e=this.getReferenceChain(e,[]),t=[].concat(J(e),[t]),Ct.apply(void 0,[this.baseReference].concat(J(t)))}},{key:"add",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(e),e=this.getDiffToReference(e,n),this.diffs.push([t,n,e,r])}},{key:"addWithWorker",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(e),this.startWorker(),null!=this.worker&&this.worker.postMessage([t,n,e,r])}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new Worker)}},{key:"getFromIndex",value:function(t){if(t>this.diffs.length||0===this.diffs.length)return null;t=(e=$(this.diffs[t],3))[1];var e=e[2];return this.getObjFromDiffAndReference(e,t)}}]),t}(),Ft=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new X;et(this,t),this.fnMap=e,this.subscribers={},this.nextId=0,this.order=[]}return rt(t,[{key:"add",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1;return this.subscribers["".concat(this.nextId)]={callback:t,num:e},this.order.push("".concat(this.nextId)),this.nextId+=1,this.nextId-1}},{key:"publish",value:function(t){for(var e=this,n=[],r=0;r<this.order.length;r+=1){var i=this.order[r],o=this.subscribers[i],a=o.callback,s=o.num;1===s&&n.push(i),o=0!==s,0<s&&(this.subscribers["".concat(i)].num=s-1),o&&this.fnMap.exec(a,t)}n.forEach((function(t){e.remove(t)}))}},{key:"remove",value:function(t){t="".concat(t),null!=this.subscribers[t]&&delete this.subscribers[t],-1<(t=this.order.indexOf(t))&&this.order.splice(t,1)}},{key:"_excludeStateKeys",value:function(){return["fnMap"]}}]),t}(),It=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new X;et(this,t),this.notifications={},this.fnMap=e}return rt(t,[{key:"add",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1;return null==this.notifications[t]&&(this.notifications[t]=new Ft(this.fnMap)),this.notifications[t].add(e,n)}},{key:"publish",value:function(t,e){null!=this.notifications[t]&&this.notifications[t].publish(e)}},{key:"remove",value:function(t,e){var n;null!=this.notifications[t]&&((n=this.notifications[t]).remove(e),0===n.order.length&&delete this.notifications[t])}},{key:"_excludeStateKeys",value:function(){return["fnMap"]}}]),t}();function Dt(t,e){var n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,".concat(encodeURIComponent(e))),n.setAttribute("download",t),n.style.display="none",null!=(t=document.body)&&(t.appendChild(n),n.click(),t.removeChild(n))}function Lt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"|",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=(t=t.split(""),[]),i=[],o=!1,a=!1,s=0,l=-1;return t.forEach((function(t){var u;i.push(t),0===s&&t===n&&!1===o?o=!0:t===n&&0===s&&o?a=!0:t===e[s]?s+=1:(s=0,o=!1),s===e.length&&(i=o?(t=i.slice(0,-e.length-n.length),u=i.slice(-e.length),[].concat(J(t),J(u))):((0<(u=i.slice(0,-e.length).join("")).length||0<r.length)&&r.push(u),0===u.length&&-1===l?l=0:-1===l&&(l=1),[]),o=!1,s=0),a&&(o=a=!1,i=i.slice(0,-1))})),0<i.length&&r.push(i.join("")),[r,l]}var zt=function(){function t(){et(this,t),this.reset()}return rt(t,[{key:"reset",value:function(){this.stamps=[[performance.now(),"init"]],this.index=1}},{key:"stamp",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"m".concat(this.index);this.stamps.push([performance.now(),t]),this.index+=1}},{key:"deltas",value:function(){var t,e=[0],n=0;return this.stamps.forEach((function(r,i){r=(o=$(r,2))[0];var o=o[1];0<i&&(i=r-t,e.push([o,Math.round(100*i)/100]),n+=i),t=r})),e[0]=Math.round(100*n)/100,e}},{key:"log",value:function(){null==window.figureOneDebug&&(window.figureOneDebug={misc:[]}),window.figureOneDebug.misc.push(this.deltas())}}]),t}();function Wt(t){var e=0;if(0===t.length)return e;for(var n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}function Nt(t,e){var n;return null!=(n=t?t.precision:n)?n:1<arguments.length&&void 0!==e?e:8}function qt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ht(t,e,n,r){return(1-r)*((1-r)*t+r*e)+r*((1-r)*e+r*n)}function Ut(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=Math.sqrt(t*t+e*e+n*n);return[r,Math.acos(n/r),Math.atan2(e,t)]}function Kt(t,e,n){return[t*Math.cos(n)*Math.sin(e),t*Math.sin(n)*Math.sin(e),t*Math.cos(e)]}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Gt(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Yt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Xt(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function $t(t){var e=Xt(t);return 1e-5<e?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function Jt(t,e){return[t[0]*e[0]+t[1]*e[4]+t[2]*e[8]+t[3]*e[12],t[0]*e[1]+t[1]*e[5]+t[2]*e[9]+t[3]*e[13],t[0]*e[2]+t[1]*e[6]+t[2]*e[10]+t[3]*e[14],t[0]*e[3]+t[1]*e[7]+t[2]*e[11]+t[3]*e[15],t[4]*e[0]+t[5]*e[4]+t[6]*e[8]+t[7]*e[12],t[4]*e[1]+t[5]*e[5]+t[6]*e[9]+t[7]*e[13],t[4]*e[2]+t[5]*e[6]+t[6]*e[10]+t[7]*e[14],t[4]*e[3]+t[5]*e[7]+t[6]*e[11]+t[7]*e[15],t[8]*e[0]+t[9]*e[4]+t[10]*e[8]+t[11]*e[12],t[8]*e[1]+t[9]*e[5]+t[10]*e[9]+t[11]*e[13],t[8]*e[2]+t[9]*e[6]+t[10]*e[10]+t[11]*e[14],t[8]*e[3]+t[9]*e[7]+t[10]*e[11]+t[11]*e[15],t[12]*e[0]+t[13]*e[4]+t[14]*e[8]+t[15]*e[12],t[12]*e[1]+t[13]*e[5]+t[14]*e[9]+t[15]*e[13],t[12]*e[2]+t[13]*e[6]+t[14]*e[10]+t[15]*e[14],t[12]*e[3]+t[13]*e[7]+t[14]*e[11]+t[15]*e[15]]}function Zt(t){return[t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]}function Qt(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function te(t,e,n){return[1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1]}function ee(t,e,n){var r=Math.cos(t),i=Math.sin(t),o=Math.cos(e);return t=Math.sin(e),[(e=Math.cos(n))*o,e*t*i-(n=Math.sin(n))*r,e*t*r+n*i,0,n*o,n*t*i+e*r,n*t*r-e*i,0,-t,o*i,o*r,0,0,0,0,1]}function ne(t,e){var n=Math.cos(e),r=Math.sin(e),i=(o=3,function(t){if(Array.isArray(t))return t}(i=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(i,o)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vt(t,e):void 0}}(i,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[0];return e=i[1],t=i[2],[o*o*(i=1-n)+n,o*e*i-t*r,o*t*i+e*r,0,e*o*i+t*r,e*e*i+n,e*t*i-o*r,0,t*o*i-e*r,t*e*i+o*r,t*t*i+n,0,0,0,0,1]}function re(t,e){return ne($t(t),e)}function ie(t){if(.999999<Math.abs(t[0])/Xt(t))return re([0,0,1],0<t[0]?0:Math.PI);var e=Gt([1,0,0],t),n=Yt([1,0,0],t);return re(e,Math.acos(n/Xt(t)))}function oe(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[0,0,1];if(.999999<Math.abs(t[0])/Xt(t))return[e,0<t[0]?0:Math.PI];var n=Gt([1,0,0],t);return e=Yt([1,0,0],t),[n,Math.acos(e/Xt(t))]}function ae(t,e,n){for(var r=2<arguments.length&&void 0!==n?n:1e-6,i=0;i<t.length;i+=1)if(Math.abs(t[i]-e[i])>r)return;return 1}function se(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=Gt(t,e);if(ae(r,[0,0,0],1e-6)){var i=$t(t),o=$t(e);return null!=n?r=n:ae(r=Gt(t,[1,0,0]),[0,0,0],1e-6)&&(r=Gt(t,[0,1,0])),ae(i,o,1e-6)?[r,0]:[r,Math.PI]}return o=Yt(t,e),[r,Math.acos(o/(Xt(t)*Xt(e)))]}function le(t,e,n){return[t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1]}function ue(t,e,n,r){return[t[0]*e+t[1]*n+t[2]*r+t[3],t[4]*e+t[5]*n+t[6]*r+t[7],t[8]*e+t[9]*n+t[10]*r+t[11]]}function ce(t,e){for(var n=[0,0,0,0],r=0;r<4;r+=1)for(var i=n[r]=0;i<4;i+=1)n[r]+=e[i]*t[4*i+r];return n}function he(t,e){for(var n=[0,0,0,0],r=0;r<4;r+=1)for(var i=n[r]=0;i<4;i+=1)n[r]+=e[i]*t[4*r+i];return n}function fe(t,e,n,r,i,o){return[2/(e-t),0,0,(t+e)/(t-e),0,2/(r-n),0,(n+r)/(n-r),0,0,2/(i-o),(i+o)/(i-o),0,0,0,1]}function de(t,e,n,r){var i=Math.tan(.5*Math.PI-.5*t);return[i/e,0,0,0,0,i,0,0,0,0,(n+r)*(t=1/(n-r)),n*r*t*2,0,0,-1,0]}function pe(t,e,n){var r=$t([t[0]-e[0],t[1]-e[1],t[2]-e[2]]);return e=$t(Gt(n,r)),n=$t(Gt(r,e)),[e[0],n[0],r[0],t[0],e[1],n[1],r[1],t[1],e[2],n[2],r[2],t[2],0,0,0,1]}function me(t){var e=1/(t[0]*(t[4]*t[8]-t[7]*t[5])-t[1]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*t[7]-t[4]*t[6]));return[(t[4]*t[8]-t[7]*t[5])*e,(t[2]*t[7]-t[1]*t[8])*e,(t[1]*t[5]-t[2]*t[4])*e,(t[5]*t[6]-t[3]*t[8])*e,(t[0]*t[8]-t[2]*t[6])*e,(t[3]*t[2]-t[0]*t[5])*e,(t[3]*t[7]-t[6]*t[4])*e,(t[6]*t[1]-t[0]*t[7])*e,(t[0]*t[4]-t[3]*t[1])*e]}function ye(t){return[t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1]}function ve(t,e){return t=[t[0][0],t[1][0],t[2][0],t[0][1],t[1][1],t[2][1],t[0][2],t[1][2],t[2][2]],e=[e[0][0],e[1][0],e[2][0],e[0][1],e[1][1],e[2][1],e[0][2],e[1][2],e[2][2]],ye([(t=me(t))[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]])}function ge(t,e,n){return ye([t[0],e[0],n[0],t[1],e[1],n[1],t[2],e[2],n[2]])}function be(t){return function(t){var e;if(9===t.length)return e=3,me(t);if(16===t.length){if(0===t[3]&&0===t[7]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15])return ye(me([t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]]));e=4}else e=Math.sqrt(t.length);for(var n=2*e,r=new Array(e).fill(0).map((function(){return new Array(n).fill(0)})),i=0,o=0;o<e;o+=1){for(var a=0;a<n/2;a+=1)r[o][a]=t[i],i+=1;for(var s=n/2;s<n;s+=1)r[o][s]=o===s-n/2?1:0}for(var l=0,u=0;l<e&&u<n;){for(var c=l,h=l;h<e;h+=1)c<Math.abs(r[h][u])&&(c=h);if(0===r[c][u])u+=1;else{var f=r[l].slice();r[l]=r[c].slice(),r[c]=f;for(var d=l+1;d<e;d+=1){var p=r[d][u]/r[l][u];r[d][u]=0;for(var m=u+1;m<n;m+=1)r[d][m]-=r[l][m]*p}l+=1,u+=1}}for(var y=e-1;0<=y;--y){for(var v=e-1;y<v;--v)for(var g=r[y][v]/r[v][v],b=y;b<n;b+=1)r[y][b]-=g*r[v][b];for(var w=1/r[y][y],x=y;x<n;x+=1)r[y][x]*=w}if(3===e)return[r[0][3],r[0][4],r[0][5],r[1][3],r[1][4],r[1][5],r[2][3],r[2][4],r[2][5]];if(4===e)return[r[0][4],r[0][5],r[0][6],r[0][7],r[1][4],r[1][5],r[1][6],r[1][7],r[2][4],r[2][5],r[2][6],r[2][7],r[3][4],r[3][5],r[3][6],r[3][7]];i=0;for(var S=Array(e*e),T=0;T<e;T+=1)for(var A=e;A<2*e;A+=1)S[i]=r[T][A],i+=1;return S}(t)}function we(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return xe(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xe(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Se(t){if(t instanceof Oe)return t;if(null==t)throw new Error("FigureOne could not parse point with no input: '".concat(t,"'"));var e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(n){throw new Error("FigureOne could not parse point from string: '".concat(e,"'"))}if(Array.isArray(e))try{if(3===e.length&&"number"==typeof e[0])return new Oe(e[0],e[1],e[2]);if(2===e.length&&"number"==typeof e[0])return new Oe(e[0],e[1],0);throw new Error("FigureOne could not parse point from array: '".concat(JSON.stringify(t),"'"))}catch(n){throw new Error("FigureOne could not parse point from array: '".concat(JSON.stringify(t),"'"))}if(null==e.f1Type)throw new Error("FigureOne could not parse point: ".concat(t));if("p"===e.f1Type&&null!=e.state&&Array.isArray([e.state])){if(3===e.state.length){var n=(i=we(e.state,3))[0],r=i[1],i=i[2];return new Oe(n,r,i)}if(2===e.state.length)return e=(i=we(e.state,2))[0],i=i[1],new Oe(e,i)}throw new Error("FigureOne could not parse point from state: ".concat(t))}function Te(t){try{Se(t)}catch(t){return!1}return!0}function Ae(t){return null==(t=Se(t))?new Oe(0,0):t}function ke(t){return Array.isArray(t)&&(2!==t.length&&3!==t.length||"number"!=typeof t[0])?t.map(Ae):[Ae(t)]}function _e(t){return"number"==typeof t?new Oe(t,t,t):Array.isArray(t)&&2===t.length?new Oe(t[0],t[1],1):Ae(t)}var Oe=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;if(function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this._type="point",Array.isArray(e))try{var i=we(e,2),o=i[0],a=i[1],s=0;3===e.length&&(s=we(e,3)[2]),this.x=o,this.y=a,this.z=s}catch(n){if(3!==e.length)throw new Error("FigureOne Point creation failed - array definition must have length of 3: ".concat(JSON.stringify(e)))}else this.x=e,this.y=n,this.z=r}var e=[{key:"toArray",value:function(){return 2===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:3)?[this.x,this.y]:[this.x,this.y,this.z]}},{key:"toPolar",value:function(){return{mag:Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)),angle:Math.atan2(this.y,this.x)}}},{key:"toSpherical",value:function(){var t=we(Ut(this.x,this.y,this.z),3);return{mag:t[0],theta:t[1],phi:t[2]}}},{key:"_state",value:function(){var t=Nt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{precision:8});return{f1Type:"p",state:[p(this.x,t),p(this.y,t),p(this.z,t)]}}},{key:"_dup",value:function(){return new this.constructor(this.x,this.y,this.z)}},{key:"scale",value:function(t){return new this.constructor(this.x*t,this.y*t,this.z*t)}},{key:"mul",value:function(e){return e=Ae(e),new t(this.x*e.x,this.y*e.y,this.z*e.z)}},{key:"sub",value:function(t){return"number"==typeof t?new this.constructor(this.x-t,this.y-(1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),this.z-(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)):new this.constructor(this.x-t.x,this.y-t.y,this.z-t.z)}},{key:"add",value:function(t){return"number"==typeof t?new this.constructor(this.x+t,this.y+(1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),this.z+(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)):new this.constructor(this.x+t.x,this.y+t.y,this.z+t.z)}},{key:"distance",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z):(t=Ae(t),Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)+Math.pow(this.z-t.z,2)))}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"dotProduct",value:function(t){return t=Ae(t),qt([this.x,this.y,this.z],[t.x,t.y,t.z])}},{key:"crossProduct",value:function(e){return e=Ae(e),new t(this.y*e.z-this.z*e.y,-(this.x*e.z-this.z*e.x),this.x*e.y-this.y*e.x)}},{key:"angleTo",value:function(t){var e=Ae(t),n=e.length();return t=this.length(),0===n||0===t?0:((t=this.dotProduct(e)/n/t)<-1?t=-1:1<t&&(t=1),Math.acos(t))}},{key:"projectOn",value:function(t){return this.length()*Math.cos(this.angleTo(t))}},{key:"componentAlong",value:function(t){var e=this.projectOn(t);return Ae(t).normalize().scale(e)}},{key:"isZero",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return 0===m(this.x,t)&&0===m(this.y,t)&&0===m(this.z,t)}},{key:"round",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new this.constructor(p(this.x,t),p(this.y,t),p(this.z,t))}},{key:"clip",value:function(t,e){t="number"==typeof t||null==t?r=n=t:(n=t.x,r=t.y,t.z),e="number"==typeof e||null==e?o=i=e:(i=e.x,o=e.y,e.z);var n,r,i=v(this.x,n,i),o=v(this.y,r,o);return e=v(this.z,t,e),new this.constructor(i,o,e)}},{key:"transformBy",value:function(t){return t=ue(t,this.x,this.y,this.z),new this.constructor(t[0],t[1],t[2])}},{key:"quadraticBezier",value:function(t,e,n){var r=Ht(this.x,t.x,e.x,n),i=Ht(this.y,t.y,e.y,n);return n=Ht(this.z,t.z,e.z,n),new this.constructor(r,i,n)}},{key:"rotate",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new t(0,0,0),r=Ae(2<arguments.length&&void 0!==arguments[2]?arguments[2]:new t(0,0,1));return n=Ae(n),this.sub(n).transformBy(re(r.toArray(),e)).add(n)}},{key:"normalize",value:function(){var e=this.length();return new t(this.x/e,this.y/e,this.z/e)}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=this;return t=Ae(t),n?this.isWithinDelta(t,e):("number"==typeof e&&(r=this.round(e),t=t.round(e)),r.x===t.x&&r.y===t.y&&r.z===t.z)}},{key:"isWithinDelta",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-7,n=Math.abs(this.x-t.x),r=Math.abs(this.y-t.y);return t=Math.abs(this.z-t.z),!(e<n||e<r||e<t)}},{key:"isNotEqualTo",value:function(t){return!this.isEqualTo(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,2<arguments.length&&void 0!==arguments[2]&&arguments[2])}},{key:"isNotWithinDelta",value:function(t){return!this.isWithinDelta(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-7)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Pe(t,e){return t===e?0:Math.atan2(Math.sin(t-e),Math.cos(t-e))}function Ee(t,e){return null===e||(t%=2*Math.PI,"0to360"===e&&(t<0&&(t+=2*Math.PI),t>=2*Math.PI&&(t-=2*Math.PI)),"-180to180"===e&&(t<-Math.PI&&(t+=2*Math.PI),t>=Math.PI&&(t-=2*Math.PI)),"-360to0"===e&&(0<t&&(t-=2*Math.PI),t<=2*-Math.PI&&(t+=2*Math.PI))),t}function Me(t){return Ee(t,"0to360")}function Ce(t,e){var n=Me(t);return t=Me(e),e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n===t?0:0===(e=2===e?t<n?-1:1:e)?Pe(t,n):1===e&&t<n?2*Math.PI-n+t:-1===e&&n<t?-n-(2*Math.PI-t):t-n}function je(t,e,n){return t=t.sub(e),e=n.sub(e),t=t.toPolar().angle,e=e.toPolar().angle,Ee(e-=t,"0to360")}function Re(t,e,n){return t=Ee(Math.atan2(t.y-e.y,t.x-e.x),"0to360"),(t=Ee(Math.atan2(n.y-e.y,n.x-e.x),"0to360")-t)>Math.PI?t=-(2*Math.PI-t):t<-Math.PI&&(t=2*Math.PI+t),t}function Be(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Fe(t){return function(t){if(t instanceof Ie)return t;if(null==t)throw new Error("FigureOne could not parse line with no input: '".concat(t,"'"));var e=t;if("string"==typeof e)try{e=JSON.parse(e)}catch(t){throw new Error("FigureOne could not parse line from string: '".concat(e,"'"))}if(Array.isArray(e)){if(3===e.length)return new Ie(e[0],e[1],e[2]);if(2===e.length)return new Ie(e[0],e[1]);throw new Error("FigureOne could not parse line from array: '".concat(JSON.stringify(t),"'"))}if(null!=e.f1Type){if("l"===e.f1Type&&null!=e.state&&Array.isArray([e.state])&&3===e.state.length){var n=(a=3,(o=function(t){if(Array.isArray(t))return t}(i=e.state)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(i,a)||function(t,e){if(t){if("string"==typeof t)return Be(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Be(t,e):void 0}}(i,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),r=o[1],i=o[2];return new Ie(Ae(n),Ae(r),i)}throw new Error("FigureOne could not parse line from state: ".concat(JSON.stringify(t)))}var o=(a=e).p1,a=(n=a.p2,r=a.length,i=a.direction,a.ends);if(null==o)throw new Error("FigureOne could not parse line: ".concat(JSON.stringify(t)));if(null!=n)return new Ie(o,n,a);if(null!=r&&null!=i)return new Ie({p1:o,direction:i,length:r,ends:a});if(null!=e.phi&&null!=e.theta&&null!=e.length)return new Ie({p1:o,phi:e.phi,theta:e.theta,ends:a,length:r});if(null!=e.angle&&null!=e.length)return new Ie({p1:o,angle:e.angle,ends:a,length:r});throw new Error("FigureOne could not parse line from object definition: ".concat(JSON.stringify(t)))}(t)}var Ie=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[0,0],r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e instanceof Oe||Array.isArray(e)||"string"==typeof e?(this.p1=Ae(e),this.p2=Ae(n),this.ends=r):(e=ft({},{p1:new Oe(0,0,0),mag:1,theta:0,phi:0,ends:2},e),this.p1=Ae(e.p1),this.ends=e.ends,null!=e.p2?this.p2=Ae(e.p2):null!=e.direction?this.p2=Ae(e.direction).normalize().scale(e.length).add(this.p1):null!=e.angle?this.p2=this.p1.add(e.length*Math.cos(e.angle),e.length*Math.sin(e.angle),0):this.p2=this.p1.add(new Oe(Kt(e.length,e.theta,e.phi))))}var e=[{key:"_state",value:function(t){return t=Nt(t),{f1Type:"l",state:[[p(this.p1.x,t),p(this.p1.y,t),p(this.p1.z,t)],[p(this.p2.x,t),p(this.p2.y,t),p(this.p2.z,t)],this.ends]}}},{key:"theta",value:function(){return this.p2.sub(this.p1).toSpherical().theta}},{key:"phi",value:function(){return this.p2.sub(this.p1).toSpherical().phi}},{key:"_dup",value:function(){return new t(this.p1,this.p2,this.ends)}},{key:"setP1",value:function(t){this.p1=Ae(t)}},{key:"setP2",value:function(t){this.p2=Ae(t)}},{key:"unitVector",value:function(){return this.p2.sub(this.p1).normalize()}},{key:"vector",value:function(){return this.p2.sub(this.p1)}},{key:"getPoint",value:function(){return 2===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1)?this.p2:this.p1}},{key:"reverse",value:function(){return new t(this.p2,this.p1,this.ends)}},{key:"angle",value:function(){return Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new t(this.p1.round(e),this.p2.round(e),this.ends)}},{key:"length",value:function(){var t=this.p2.sub(this.p1);return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)}},{key:"midPoint",value:function(){return this.pointAtPercent(.5)}},{key:"pointAtPercent",value:function(t){var e=this.length(),n=this.p2.sub(this.p1).normalize();return this.p1.add(n.scale(e*t))}},{key:"pointAtLength",value:function(t){return this.pointAtPercent(t/this.length())}},{key:"hasPointAlong",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;if(this.p1.isEqualTo(t,e))return!0;var n=this.unitVector();return t=Ae(t).sub(this.p1).normalize(),1===(e=p(t.dotProduct(n),e))||-1===e}},{key:"hasPointOn",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Ae(t);if(0===this.ends)return this.hasPointAlong(n,e);if(this.p1.isEqualTo(n,e))return!0;var r=this.unitVector();return n=(t=n.sub(this.p1)).normalize(),1===p(n.dotProduct(r),e)&&(p(t.distance(),e)<=p(this.length(),e)||1===this.ends)}},{key:"distanceToPoint",value:function(t){var e=this.unitVector(),n=Ae(t);return t=this.p1,n.sub(t).sub(e.scale(n.sub(t).dotProduct(e))).distance()}},{key:"isParallelTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Fe(t);return t=this.unitVector(),n=n.unitVector(),!!t.crossProduct(n).isZero(e)}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=this;return t=Fe(t),!(r.ends!==t.ends||(2===r.ends?r.p1.isNotEqualTo(t.p1,e,n)&&r.p1.isNotEqualTo(t.p2,e,n)||r.p2.isNotEqualTo(t.p1,e,n)&&r.p2.isNotEqualTo(t.p2,e,n):1===r.ends?r.p1.isNotEqualTo(t.p1,e,n)||!r.hasPointOn(t.p2,e):!r.hasPointOn(t.p1,e)||!r.hasPointOn(t.p2,e)))}},{key:"hasLineWithin",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return Fe(t).isWithinLine(this,e)}},{key:"isAlongLine",value:function(t){return this.isCollinearTo(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8)}},{key:"isCollinearTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Fe(t),r=this.unitVector();return t=n.unitVector(),(1===(r=p(t.dotProduct(r),e))||-1===r)&&this.hasPointAlong(n.p1,e)}},{key:"isWithinLine",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,r=this.round(n),i=Fe(t).round(n);return!!r.isAlongLine(i,n)&&(0===i.ends||(r=function(){return i.hasPointOn(e.p1,n)&&i.hasPointOn(e.p2,n)},!(this.ends<i.ends)&&(this.ends,r())))}},{key:"offset",value:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];return"string"==typeof e?this.offset2D(e,n):(e=Ae(e),n=null==n?e.distance():n,e=e.normalize().scale(n),!1===r?new t(this.p1.add(e),this.p2.add(e),this.ends):(r=this.unitVector(),e=e.crossProduct(r),n=r.crossProduct(e).normalize().scale(n),new t(this.p1.add(n),this.p2.add(n),this.ends)))}},{key:"offset2D",value:function(e,n){var r=this.angle();r>=Math.PI&&(r-=Math.PI),r<0&&(r+=Math.PI);var i=r-Math.PI/2;return"positive"===e?i=Ee(this.angle(),"0to360")+Math.PI/2:"negative"===e?i=Ee(this.angle(),"0to360")-Math.PI/2:r<Math.PI/2?"left"!==e&&"top"!==e||(i=r+Math.PI/2):"left"!==e&&"bottom"!==e||(i=r+Math.PI/2),new t(new Oe(this.p1.x+n*Math.cos(i),this.p1.y+n*Math.sin(i),0),new Oe(this.p2.x+n*Math.cos(i),this.p2.y+n*Math.sin(i),0),this.ends)}},{key:"distanceToLine",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Fe(t),r=this.unitVector(),i=n.unitVector();return t=n.p1.sub(this.p1),(i=r.crossProduct(i)).isZero(e)?r.crossProduct(n.p1.sub(this.p1)).distance()/r.distance():t.dotProduct(i)/i.distance()}},{key:"pointProjection",value:function(t){var e=Ae(t).sub(this.p1);return t=this.vector(),this.pointAtPercent(e.dotProduct(t)/t.dotProduct(t))}},{key:"intersectsWith",value:function(e){var n,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,i=Fe(e),o=this,a=o.isAlongLine(i,r);if(o.isParallelTo(i)&&!a)return{intersect:void 0,collinear:a,onLines:!1};if(!a&&0===o.distanceToLine(i,r)){var s=this.p1,l=i.p1,u=this.unitVector(),c=i.unitVector(),h=l.sub(s),f=(e=c.crossProduct(h),c.crossProduct(u));return h=e.distance(),c=f.distance(),0===h?{intersect:s,collinear:a,onLines:i.hasPointOn(s)}:0===c?{intersect:l,collinear:a,onLines:o.hasPointOn(l)}:(c=u.scale(h/c),f=e.normalize().isEqualTo(f.normalize(),r)?s.add(c):s.sub(c),o.hasPointOn(f,r)&&i.hasPointOn(f,r)?{intersect:f,collinear:a,onLines:!0}:{collinear:!1,onLines:!1,intersect:f})}return a?(s=i.hasPointOn(o.p1,r),c=i.hasPointOn(o.p2,r),f=o.hasPointOn(i.p1,r),a=o.hasPointOn(i.p2,r),f||a||c||s?{intersect:o.p1._dup(),collinear:!0,onLines:!0}:(r=o.p1.distance(i.p1),f=o.p1.distance(i.p2),a=o.p2.distance(i.p1),c=o.p2.distance(i.p2),(s=Math.min(a,c,r,f))===r?n=new t(o.p1,i.p1).midPoint():s===f?n=new t(o.p1,i.p2).midPoint():s===a?n=new t(o.p2,i.p1).midPoint():s===c&&(n=new t(o.p2,i.p2).midPoint()),{intersect:n,collinear:!0,onLines:!1})):{intersect:void 0,collinear:a,onLines:!1}}},{key:"clipPoint",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t=Ae(t),this.hasPointOn(t,e)?t._dup():(t=this.pointProjection(t),this.hasPointOn(t,e)?t:(t.distance(this.p1)<=t.distance(this.p2)?this.p1:this.p2)._dup())}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function De(t,e,n,r,i){var o=0<arguments.length&&void 0!==t?t:"linear",a=1<arguments.length?e:void 0;return t=2<arguments.length?n:void 0,e=3<arguments.length?r:void 0,n=4<arguments.length?i:void 0,"linear"===o?a.add((r=t).x*(i=e),r.y*i,r.z*i):"curved"===o||"curve"===o?function(t,e,r,i){var o,a,s,l,u=n;null==(h=n.controlPoint)&&(o=Math.PI/2,null!=u.angle&&(o=u.angle),c=0,null!=u.offset&&(c=u.offset),null==u.direction&&(u.direction="positive"),a=1,null!=u.magnitude&&(a=u.magnitude),s=Ee((l=new Ie(t,t.add(e))).angle(),"0to360"),i=t.add(new Oe(e.x*c,e.y*c)),(c=s)>=Math.PI&&(c-=Math.PI),c=s+o,"positive"===(u=u.direction)?c=s+o:"negative"===u?c=s-o:"up"===u?c=s<=Math.PI/2||s>=Math.PI/2*3?s+o:s-o:"down"===u?c=s<=Math.PI/2||s>=Math.PI/2*3?s-o:s+o:"left"===u?c=s<=Math.PI?s+o:s-o:"right"===u&&(c=s<=Math.PI?s-o:s+o),l=a*l.length(),h=new Oe(i.x+l*Math.cos(c),i.y+l*Math.sin(c)));var c=t,h=Ae(h);return t=t.add(e),e=Ht(c.x,h.x,t.x,r),r=Ht(c.y,h.y,t.y,r),new Oe(e,r)}(a,t,e):new Oe(0,0)}function Le(t,e,n){return De(3<arguments.length&&void 0!==arguments[3]?arguments[3]:"linear",t,e,n,4<arguments.length&&void 0!==arguments[4]?arguments[4]:{magnitude:.5,offset:.5,controlPoint:null})}function ze(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function We(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ne(t){if(t instanceof He)return t;if(null==t)throw new Error("FigureOne could not parse plane with no input: '".concat(t,"'"));var e;if("string"==typeof(n=t))try{n=JSON.parse(n)}catch(t){throw new Error("FigureOne could not parse plane from string: '".concat(n,"'"))}if(Array.isArray(n)&&2===n.length)return new He(n[0],n[1]);if(Array.isArray(n)&&3===n.length)return new He(n[0],n[1],n[2]);if(null==n.f1Type)throw new Error("FigureOne could not parse point: ".concat(JSON.stringify(t)));if("pl"===n.f1Type&&null!=n.state&&Array.isArray(n.state)){var n=(r=2,(r=function(t){if(Array.isArray(t))return t}(e=n.state)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(e,r)||function(t,e){if(t){if("string"==typeof t)return We(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?We(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),r=r[1];return new He(n,r)}throw new Error("FigureOne could not parse point from state: ".concat(JSON.stringify(t)))}function qe(t){return Ne(t)}var He=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[[0,0,0],[0,0,1]],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),null==n&&null==r)return Ne(e);null==r?(this.p=Ae(e),this.n=Ae(n).normalize()):(this.p=Ae(e),n=Ae(n),this.n=n.sub(this.p).crossProduct(Ae(r).sub(this.p)).normalize())}var e=t,n=[{key:"xy",value:function(){return new t([0,0,0],[0,0,1])}},{key:"xz",value:function(){return new t([0,0,0],[0,1,0])}},{key:"yz",value:function(){return new t([0,0,0],[1,0,0])}}],r=[{key:"_dup",value:function(){return new t(this.p,this.n)}},{key:"_state",value:function(t){return t=Nt(t),{f1Type:"pl",state:[[m(this.p.x,t),m(this.p.y,t),m(this.p.z,t)],[m(this.n.x,t),m(this.n.y,t),m(this.n.z,t)]]}}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;return new t(this.p.round(e),this.n.round(e))}},{key:"hasPointOn",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return 0===m(qt(Ae(t).sub(this.p).toArray(),this.n.toArray()),e)}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:8;return t=qe(t),!(!this.hasPointOn(t.p,n)||!this.isParallelTo(t,n)||e&&this.n.isNotEqualTo(t.n,n))}},{key:"isParallelTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t=qe(t),1===(e=m(this.n.dotProduct(t.n),e))||-1===e}},{key:"intersectsWith",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=qe(t);if(this.isParallelTo(n,e))return null;var r,i,o=this.n.crossProduct(n.n).normalize(),a=Math.abs(o.x),s=Math.abs(o.y);return t=Math.abs(o.z),e=s<a?t<a?1:3:t<s?2:3,a=this.n,t=n.n,s=-a.dotProduct(this.p),n=-t.dotProduct(n.p),a=1==e?(r=0,i=(n*a.z-s*t.z)/o.x,(s*t.y-n*a.y)/o.x):2==e?(r=(s*t.z-n*a.z)/o.y,i=0,(n*a.x-s*t.x)/o.y):(r=(n*a.y-s*t.y)/o.z,i=(s*t.x-n*a.x)/o.z,0),a=new Oe(r,i,a),new Ie({p1:a,direction:o,length:1,ends:0})}},{key:"isParallelToLine",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t=Fe(t),0===m(this.n.dotProduct(t.vector()),e)}},{key:"lineIntersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Fe(t);if(this.isParallelToLine(n,e))return null;var r=this.p;return t=n.p1,n=(e=n.p2).sub(t),t=this.n,t=r.sub(e).dotProduct(t)/n.dotProduct(t),n.scale(t).add(e)}},{key:"hasLineOn",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;return t=Fe(t),!!this.isParallelToLine(t,e)&&!!this.hasPointOn(t.p1,e)}},{key:"pointProjection",value:function(t){var e=this.p,n=this.n;return(t=Ae(t)).sub(n.scale(n.dotProduct(t.sub(e))))}},{key:"distanceToPoint",value:function(t){return this.pointProjection(t).distance(t)}},{key:"reflect",value:function(t){return t=Ae(t),this.n.scale(-2*this.n.dotProduct(t)).add(t).normalize()}}];return ze(e.prototype,r),ze(e,n),t}();function Ue(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return n=(t=1===(t=ke(t)).length&&null!=e&&null!=n?[t[0],Ae(e),Ae(n)]:t)[1].sub(t[0]),t=t[2].sub(t[0]),n.crossProduct(t).normalize()}function Ke(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return null===n?new Oe(t*Math.cos(e),t*Math.sin(e)):new Oe(t*Math.cos(e)*Math.sin(n),t*Math.sin(e)*Math.sin(n),t*Math.cos(n))}function Ve(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return 0===(t=(e="number"==typeof t?new Oe(t,e,n):t).distance())?{mag:0,angle:0,phi:0,theta:0,r:0}:((e=Math.atan2(e.y,e.x))<0&&(e+=2*Math.PI),{mag:t,angle:e,phi:e,theta:Math.acos(n/t),r:t})}function Ge(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Xe(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ye(t){return function(t){if(Array.isArray(t))return $e(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Xe(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Xe(t,e){if(t){if("string"==typeof t)return $e(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$e(t,e):void 0}}function $e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Je(t,e){var n=1<arguments.length&&void 0!==e&&e,r=t.i,i=t.j,o=t.k,a=t.x,s=t.y,l=t.z,u=t.right,c=t.top;if(e=t.normal,null!=a&&(u=a),null!=(u=null!=r?r:u)&&(u=Ae(u)),null!=s&&(c=s),null!=(c=null!=i?i:c)&&(c=Ae(c)),null!=l&&(e=l),null!=(e=null!=o?o:e)&&(e=Ae(e)),null==c&&null!=u&&null!=e?c=e.crossProduct(u).normalize():null!=c&&null==u&&null!=e?u=c.crossProduct(e).normalize():null!=c&&null!=u&&null==e&&(e=u.crossProduct(c).normalize()),null==c||null==u||null==e)throw new Error("Parsing basis fail - need at least two orthogonal basis vectors. Input: ".concat(JSON.stringify(t)));return n&&(u=u.normalize(),c=c.normalize(),e=e.normalize()),[].concat(Ye(u.toArray()),Ye(c.toArray()),Ye(e.toArray()))}function Ze(t,e){var n=Array(t.length);n[0]=t[0];for(var r=1;r<t.length;r+=1)n[r]=e(r);return n}var Qe=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.def=[],this.def=e instanceof t?e.def.slice():en(e),this._type="transform",this.calcAndSetMatrix()}var e=[{key:"_state",value:function(){for(var t=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{precision:8}).precision,e=[],n=0;n<this.def.length;n+=1){for(var r=[],i=0;i<this.def[n].length;i+=1)0===i?r.push(this.def[n][0]):r.push(p(this.def[n][i],t));e.push(r)}return{f1Type:"tf",state:e}}},{key:"hasComponent",value:function(t){for(var e=0;e<this.def.length;e+=1)if(this.def[e][0]===t)return!0;return!1}},{key:"setComponent",value:function(t,e){return this.def[t]=e,this.calcAndSetMatrix(),this}},{key:"addComponent",value:function(t){return this.def.push(t),this.calcAndSetMatrix(),this}},{key:"translate",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return"number"!=typeof n?(e=(t=Ge(Ae(n).toArray(),3))[0],r=t[1],i=t[2]):e=n,this.addComponent(["t",e,r,i])}},{key:"rotate",value:function(t){var e="number"==typeof(e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"z")?[e,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:0]:"x"===e?[1,0,0]:"y"===e?[0,1,0]:"z"===e?[0,0,1]:Ae(e).toArray();return this.addComponent(["r",t].concat(Ye(e)))}},{key:"direction",value:function(t){var e,n,r;return t="number"==typeof t?(n=t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0):(n=(e=Ae(t)).x,r=e.y,e.z),this.addComponent(["d",n,r,t])}},{key:"basis",value:function(t){return t=Je(t),this.addComponent(["b"].concat(Ye(t)))}},{key:"basisToBasis",value:function(t,e){return t=Je(t),e=Je(e),this.addComponent(["bb"].concat(Ye(t),Ye(e)))}},{key:"custom",value:function(t){if(16!==t.length)throw new Error("Transform custom matrices must be 16 elements (".concat(t.length," input): ").concat(JSON.stringify(t)));return this.addComponent(["c"].concat(Ye(t)))}},{key:"scale",value:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;return"number"==typeof t?(e=t,null==n&&(i=r=t)):(e=(t=Ge(_e(t).toArray(),3))[0],r=t[1],i=t[2]),this.addComponent(["s",e,r,i])}},{key:"calcMatrix",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.def.length-1,n=e,r=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],i=n=e<0?this.def.length+e:n;t<=i;--i){var o=(u=Ge(this.def[i],5))[0],a=u[1],s=u[2],l=u[3],u=u[4];"t"===o&&null!=a&&null!=s?null==l||0===a&&0===s&&0===l||(r=Jt(r,te(a,s,l))):"s"!==o||1===a&&1===s&&1===l?"d"!==o||1===a&&0===s&&0===l?"r"===o&&0!==a?r=Jt(r,re([s,l,u],a)):"b"===o?r=Jt(r,ge(this.def[i].slice(1,4),this.def[i].slice(4,7),this.def[i].slice(7))):"c"===o?r=Jt(r,this.def[i].slice(1)):"bb"===o&&19===this.def[i].length&&(r=Jt(r,ve([this.def[i].slice(1,4),this.def[i].slice(4,7),this.def[i].slice(7,10)],[this.def[i].slice(10,13),this.def[i].slice(13,16),this.def[i].slice(16)]))):r=Jt(r,ie([a,s,l])):r=Jt(r,le(a,s,l))}return r}},{key:"calcAndSetMatrix",value:function(){this.mat=this.calcMatrix()}},{key:"getComponentIndex",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=0,r=Array.isArray(t)?t:[t],i=0;i<this.def.length;i+=1)for(var o=0;o<r.length;o+=1)if(this.def[i][0]===r[o]){if(n===e)return i;n+=1}throw new Error("Cannot get type '".concat(JSON.stringify(t),"-").concat(e,"' from transform '").concat(JSON.stringify(this.def),"'"))}},{key:"clipRotation",value:function(t){for(var e=0;e<this.def.length;e+=1){var n,r,i,o,a=this.def[e];"r"===a[0]&&(n=(o=Ge(a,5))[0],r=o[1],i=o[2],a=o[3],o=o[4],"r"===n&&(this.def[e]=["r",Ee(r,t),i,a,o]))}this.calcAndSetMatrix()}},{key:"updateTranslation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.updateComponent(["t"].concat(Ye(Ae(t).toArray())),e)}},{key:"updateComponent",value:function(t,e){for(var n=0,r=0;r<this.def.length;r+=1)if(t[0][0]===this.def[r][0][0]){if(n===e)return this.def[r]=t.slice(),this.calcAndSetMatrix(),this;n+=1}throw new Error("Cannot update '".concat(JSON.stringify(t),"-").concat(e,"' in transform: ").concat(JSON.stringify(this.def)))}},{key:"toDelta",value:function(t,e){for(var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"linear",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=this._dup(),a=0;a<this.def.length;a+=1)!function(a){var s,l=n.def[a],u=t.def[a];l[0]===u[0]&&"t"!==l[0]&&l.length===u.length?o.def[a]=[l[0]].concat(Ye(u.slice(1).map((function(t,n){return t*e+l[n+1]})))):"t"===l[0]&&"t"===u[0]&&(s=new Oe(l[1],l[2],l[3]),u=new Oe(u[1],u[2],u[3]),u=De(r,s,u,e,i),o.def[a]=["t",u.x,u.y,u.z])}(a);return o.calcAndSetMatrix(),o}},{key:"t",value:function(){var t=this.getComponentIndex("t",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0),e=(n=Ge(this.def[t],4))[1],n=(t=n[2],n[3]);return new Oe(e,t,n)}},{key:"s",value:function(){var t=this.getComponentIndex("s",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0),e=(n=Ge(this.def[t],4))[1],n=(t=n[2],n[3]);return new Oe(e,t,n)}},{key:"r",value:function(){var t=this.getComponentIndex("r",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0);return this.def[t][1]}},{key:"ra",value:function(){var t=this.getComponentIndex("r",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0);return Ae(this.def[t].slice(2))}},{key:"d",value:function(){return this.def[this.getComponentIndex("d",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)].slice(1)}},{key:"c",value:function(){return this.def[this.getComponentIndex("c",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)].slice(1)}},{key:"b",value:function(){return this.def[this.getComponentIndex("b",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)].slice(1)}},{key:"bb",value:function(){return this.def[this.getComponentIndex("bb",0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)].slice(1)}},{key:"updateScale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.updateComponent(["s"].concat(Ye(_e(t).toArray())),e)}},{key:"updateRotation",value:function(t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=null==(n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)?this.def[this.getComponentIndex("r",e)].slice(2):Ae(n).toArray();return this.updateComponent(["r",t].concat(Ye(n)),e)}},{key:"updateDirection",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.updateComponent(["d"].concat(Ye(Ae(t).toArray())),e)}},{key:"updateCustom",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.updateComponent(["c"].concat(Ye(t)),e)}},{key:"updateBasis",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.updateComponent(["b"].concat(Ye(Je(t))),e)}},{key:"updateBasisToBasis",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return this.updateComponent(["bb"].concat(Ye(Je(t)),Ye(Je(e))),n)}},{key:"m",value:function(){return this.mat}},{key:"matrix",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return t?m(this.mat,t):this.mat}},{key:"isEqualShapeTo",value:function(t){var e=rn(t);if(e.def.length!==this.def.length)return!1;for(var n=0;n<this.def.length;n+=1)if(this.def[n][0]!==e.def[n][0])return!1;return!0}},{key:"isEqualTo",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=rn(t);if(n.def.length!==this.def.length)return!1;for(var r=0;r<this.def.length;r+=1){var i=this.def[r],o=n.def[r];if(i[0]!==o[0])return!1;for(var a=1;a<i.length;a+=1)if(p(i[a],e)!==p(o[a],e))return!1}return!0}},{key:"isWithinDelta",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-8,n=rn(t);if(n.def.length!==this.def.length)return!1;for(var r=0;r<this.def.length;r+=1){var i=this.def[r],o=n.def[r];if(i[0]!==o[0])return!1;for(var a=1;a<i.length;a+=1)if(Math.abs(i[a]-o[a])>e)return!1}return!0}},{key:"sub",value:function(){var e=this,n=rn(0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t);if(!this.isEqualShapeTo(n))throw new Error("Cannot subtract transforms of different shape: '".concat(JSON.stringify(this.def),"', '").concat(JSON.stringify(n.def),"'"));for(var r=[],i=0;i<this.def.length;i+=1)!function(t){var i=e.def[t],o=n.def[t];r.push([i[0]].concat(Ye(i.slice(1).map((function(t,e){return t-o[e+1]})))))}(i);return new t(r)}},{key:"add",value:function(){var e=this,n=rn(0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t);if(!this.isEqualShapeTo(n))throw new Error("Cannot add transforms of different shape: '".concat(JSON.stringify(this.def),"', '").concat(JSON.stringify(n.def),"'"));for(var r=[],i=0;i<this.def.length;i+=1)!function(t){var i=e.def[t],o=n.def[t];r.push([i[0]].concat(Ye(i.slice(1).map((function(t,e){return t+o[e+1]})))))}(i);return new t(r)}},{key:"mul",value:function(){var e=this,n=rn(0<arguments.length&&void 0!==arguments[0]?arguments[0]:new t);if(!this.isEqualShapeTo(n))throw new Error("Cannot multiply transforms of different shape: '".concat(JSON.stringify(this.def),"', '").concat(JSON.stringify(n.def),"'"));for(var r=[],i=0;i<this.def.length;i+=1)!function(t){var i=e.def[t],o=n.def[t];r.push([i[0]].concat(Ye(i.slice(1).map((function(t,e){return t*o[e+1]})))))}(i);return new t(r)}},{key:"transform",value:function(e){var n=new t([]);return e=rn(e),n.def=e.def.map((function(t){return t.slice()})).concat(this.def.map((function(t){return t.slice()}))),n.mat=Jt(this.matrix(),e.matrix()),n}},{key:"transformBy",value:function(e){var n=new t([]);return e=rn(e),n.def=this.def.map((function(t){return t.slice()})).concat(e.def.map((function(t){return t.slice()}))),n.mat=Jt(e.matrix(),this.matrix()),n}},{key:"round",value:function(){for(var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,r=[],i=0;i<this.def.length;i+=1)!function(t){r.push(Ze(e.def[t],(function(r){return p(e.def[t][r],n)})))}(i);return new t(r)}},{key:"clipMag",value:function(e,n){for(var r=this,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],o=on(e,this),a=on(n,this),s=[],l=0;l<this.def.length;l+=1)!function(t){var e=r.def[t],n=Ge(e,4),l=n[0],u=n[1],c=n[2],h=n[3];"t"===l&&i?(u=(n=Ve(u,c,h)).r,c=n.phi,h=n.theta,u=(n=y(u,o[t],a[t]))*Math.cos(c)*Math.sin(h),c=n*Math.sin(c)*Math.sin(h),h=n*Math.cos(h),s.push(["t",u,c,h])):"c"!==l&&s.push(Ze(e,(function(n){return y(e[n],o[t],a[t])})))}(l);return new t(s)}},{key:"constant",value:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=[],r=0;r<this.def.length;r+=1)n.push(Ze(this.def[r],(function(){return e})));return new t(n)}},{key:"zero",value:function(){return this.constant(0)}},{key:"isZero",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0;e<this.def.length;e+=1){var n=(o=Ge(this.def[e],4))[0],r=o[1],i=o[2],o=o[3];if("t"===n||"s"===n||"d"===n){if(Math.abs(r)>t||Math.abs(i)>t||Math.abs(o)>t)return!1}else if("r"===n&&Ee(r,"0to360")>t)return!1}return!0}},{key:"_dup",value:function(){var e=new t;return e.mat=this.mat.slice(),e.def=this.def.map((function(t){return t.slice()})),e}},{key:"velocity",value:function(e,n,r,i){var o=[];if(!this.isEqualShapeTo(e))throw new Error("Cannot calculate velocity for transform - shapes are different: ".concat(JSON.stringify(e.def),", ").concat(JSON.stringify(this.def)));for(var a=this.sub(e),s=0;s<a.def.length;s+=1)!function(t){var e=a.def[t];o.push(Ze(e,(function(t){return e[t]/n})))}(s);return new t(o).clipMag(r,i)}},{key:"identity",value:function(){for(var e=[],n=0;n<this.def.length;n+=1){var r=Ge(this.def[n],1)[0];"t"===r?e.push([r,0,0,0]):"s"===r?e.push([r,1,1,1]):"r"===r?e.push([r,0,0,0,1]):"d"===r?e.push([r,0,0,0]):"b"===r?e.push(["b",1,0,0,0,1,0,0,0,1]):"bb"===r?e.push(["bb",1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0,1]):"c"===r&&e.push(["c",1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return new t(e)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function tn(t){if(t instanceof Qe)return!0;if(Array.isArray(t)&&Array.isArray(t[0])&&("r"===t[0][0]||"s"===t[0][0]||"t"===t[0][0]||"c"===t[0][0]||"b"===t[0][0]||"d"===t[0][0]||"bb"===t[0][0]))return!0;if(Array.isArray(t)&&("r"===t[0]||"s"===t[0]||"t"===t[0]||"c"===t[0]||"b"===t[0]||"bb"===t[0]||"d"===t[0]))return!0;if(null!=t.f1Type&&"tf"===t.f1Type)return!0;if("string"!=typeof t)return!1;var e;try{e=JSON.parse(t)}catch(t){return!1}return tn(e)}function en(t){if(t instanceof Qe)return t.def.slice();if(null==t)throw new Error("FigureOne could not parse transform with no input: '".concat(JSON.stringify(t),"'"));var e=t;if("string"==typeof e){if(""===e)return[];try{e=JSON.parse(e)}catch(e){throw new Error("FigureOne could not parse transform with no input: '".concat(JSON.stringify(t),"'"))}}if(Array.isArray(e)){if(0===e.length)return[];Array.isArray(e[0])||(e=[e]);for(var n=[],r=0;r<e.length;r+=1)"b"===e[r][0]&&"number"!=typeof e[r][1]?n.push(["b"].concat(Ye(Je(e[r][1])))):"bb"===e[r][0]&&"number"!=typeof e[r][1]?n.push(["bb"].concat(Ye(Je(e[r][1])),Ye(Je(e[r][2])))):"r"===e[r][0]&&2===e[r].length?n.push(["r",e[r][1],0,0,1]):"s"===e[r][0]&&2===e[r].length?n.push(["s",e[r][1],e[r][1],e[r][1]]):"s"===e[r][0]&&3===e[r].length?n.push(["s",e[r][1],e[r][2],1]):"t"===e[r][0]&&3===e[r].length?n.push(["t",e[r][1],e[r][2],0]):n.push(e[r].slice());return n}var i=e.f1Type,o=e.state;if(null!=i&&"tf"===i&&null!=o&&Array.isArray(o))return e.state;throw new Error("FigureOne could not parse transform: '".concat(JSON.stringify(t),"'"))}function nn(t){if(t instanceof Qe)return t;if(null==t)throw new Error("FigureOne could not parse transform with no input: '".concat(JSON.stringify(t),"'"));return t=en(t),new Qe(t)}function rn(t){return null==(t=nn(t))?new Qe:t}function on(t,e){if(Array.isArray(t))return t;var n=[];if("number"==typeof t){for(var r=0;r<e.def.length;r+=1)n.push(t);return n}for(var i=0;i<e.def.length;i+=1){var o,a,s=e.def[i][0];"t"===s?(o=0,null!=t.position&&(o=t.position),null!=t.translation&&(o=t.translation),n.push(o)):"s"===s?(a=0,null!=t.scale&&(a=t.scale),n.push(a)):"r"===s[0]?(a=0,null!=t.rotation&&(a=t.rotation),n.push(a)):"c"===s[0]&&(s=0,null!=t.custom&&(s=t.custom),n.push(s))}return n}function an(t){return Array.isArray(t)&&"string"==typeof t[0]?Ae(t.slice(1)):Ae(t)}function sn(t){return(sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ln(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return un(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?un(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function un(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function cn(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&hn(t,e)}function hn(t,e){return(hn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function fn(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=dn(t);return function(t,e){if(e&&("object"===sn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=dn(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function dn(t){return(dn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function pn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function yn(t,e,n){return e&&mn(t.prototype,e),n&&mn(t,n),t}var vn=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8;pn(this,t),this.boundary=e,this.precision=n}return yn(t,[{key:"_dup",value:function(){return new t}},{key:"_state",value:function(t){return{f1Type:"bounds",state:[]}}},{key:"contains",value:function(t){return!0}},{key:"intersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return"number"==typeof t?{intersect:t,distance:0,reflection:e+Math.PI}:{intersect:Ae(t),distance:0,reflection:e+Math.PI}}},{key:"clip",value:function(t){return"number"==typeof t?t:Ae(t)}},{key:"isDefined",value:function(){return!1}}]),t}(),gn=function(){cn(e,vn);var t=fn(e);function e(n){pn(this,e);var r=ft({},{precision:8,min:null,max:null},n);return n={min:r.min,max:r.max},t.call(this,n,r.precision)}return yn(e,[{key:"isDefined",value:function(){return null!=this.boundary.min||null!=this.boundary.max}},{key:"_dup",value:function(){return new e({precision:this.precision,min:this.boundary.min,max:this.boundary.max})}},{key:"_state",value:function(t){return t=Nt(t),{f1Type:"rangeBounds",state:[this.precision,null!=this.boundary.min?p(this.boundary.min,t):null,null!=this.boundary.max?p(this.boundary.max,t):null]}}},{key:"contains",value:function(t){return"number"!=typeof t?(t=Ae(t),!!(this.contains(t.x)&&this.contains(t.y)&&this.contains(t.z))):(t=p(t,this.precision),(null==this.boundary.min||t>=p(this.boundary.min,this.precision))&&(null==this.boundary.max||t<=p(this.boundary.max,this.precision)))}},{key:"intersect",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=(r=this.boundary).min,r=r.max;if("number"!=typeof t)throw new Error("FigureOne RangeBounds.intersect only accepts 'number' parameter for value. Provide: ".concat(JSON.stringify(t)));return t=this.clip(t),1===e?null==r?{intersect:null,distance:0,reflection:e}:{intersect:r,distance:Math.abs(t-r),reflection:-1}:null==n?{intersect:null,distance:0,reflection:e}:{intersect:n,distance:Math.abs(t-n),reflection:1}}},{key:"clip",value:function(t){if("number"==typeof t)return v(t,this.boundary.min,this.boundary.max);var e=Ae(t);return(t=e._dup()).x=v(e.x,this.boundary.min,this.boundary.max),t.y=v(e.y,this.boundary.min,this.boundary.max),t.z=v(e.z,this.boundary.min,this.boundary.max),t}}]),e}(),bn=function(){cn(e,vn);var t=fn(e);function e(n){pn(this,e);var r,i,o,a=ft({},{position:[0,0,0],normal:[0,0,1],left:-1,right:-1,top:1,bottom:1,precision:8},n),s=Ae(a.position);null!=a.rightDirection&&null!=a.topDirection?(i=Ae(a.rightDirection).normalize(),o=Ae(a.topDirection).normalize(),r=new He(s,i.crossProduct(o))):null!=a.rightDirection?(i=Ae(a.rightDirection).normalize(),o=(r=new He(s,a.normal)).n.crossProduct(i).normalize()):null!=a.topDirection?(o=Ae(a.topDirection).normalize(),r=new He(s,a.normal),i=o.crossProduct(r.n).normalize()):(i=Ae([1,0,0]),o=(r=new He(s,a.normal)).n.crossProduct(i).normalize()),a.left,a.right,a.top;var l=a.bottom,u=null,c=(n=null,u=s.add(i.scale(a.left)),n=s.add(i.scale(a.right)),u.add(o.scale(a.top))),h=u.add(o.scale(a.bottom)),f=n.add(o.scale(a.top));return s=n.add(o.scale(a.bottom)),u=new Ie(s,f),n=new Ie(h,c),f=new Ie(c,f),l=new Ie(h,s),(l=t.call(this,{left:n,right:u,top:f,bottom:l},a.precision)).plane=r,l.topDirection=o,l.rightDirection=i,l.left=a.left,l.right=a.right,l.bottom=a.bottom,l.top=a.top,l}return yn(e,[{key:"isDefined",value:function(){return null!=this.boundary.left||null!=this.boundary.right||null!=this.boundary.top||null!=this.boundary.bottom}},{key:"_dup",value:function(){return new e({precision:this.precision,left:this.left,right:this.right,bottom:this.bottom,top:this.top,position:this.plane.p,topDirection:this.topDirection,rightDirection:this.rightDirection})}},{key:"round",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,e=this._dup();e.left=m(e.left,t),e.right=m(e.left,t),e.bottom=m(e.left,t),e.top=m(e.left,t),e.boundary.left=e.boundary.left.round(t),e.boundary.right=e.boundary.right.round(t),e.boundary.top=e.boundary.top.round(t),e.boundary.bottom=e.boundary.bottom.round(t),e.plane=e.plane.round(t),e.rightDirection=e.rightDirection.round(t),e.topDirection=e.topDirection.round(t)}},{key:"_state",value:function(t){return t=Nt(t),{f1Type:"rectBounds",state:[this.precision,p(this.left,t),p(this.right,t),p(this.bottom,t),p(this.top,t),this.plane.p.toArray(),this.topDirection.toArray(),this.rightDirection.toArray()]}}},{key:"contains",value:function(t){if(!1===(!(1<arguments.length&&void 0!==arguments[1])||arguments[1])&&!this.plane.hasPointOn(t))return!1;var e=this.plane.pointProjection(t).round(this.precision).sub(this.plane.p);return t=e.projectOn(this.rightDirection),!((e=e.projectOn(this.topDirection))>this.top||e<this.bottom||t>this.right||t<this.left)}},{key:"clip",value:function(t){var e=this.plane.pointProjection(Ae(t)).round(this.precision);return e.isEqualTo(this.plane.p)?e._dup():((e=(t=e.sub(this.plane.p)).projectOn(this.rightDirection))>this.right?e=this.right:e<this.left&&(e=this.left),(t=t.projectOn(this.topDirection))>this.top?t=this.top:t<this.bottom&&(t=this.bottom),this.plane.p.add(this.rightDirection.scale(e)).add(this.topDirection.scale(t)))}},{key:"getBoundIntersect",value:function(t,e,n,r,i){var o,a,s=e.length(),l=Math.acos(e.dotProduct(i)/s/i.length());return(l=s*Math.cos(l))<0&&(o=r,a=i),0<l&&(o=n,a=i.scale(-1)),null==o?null:(e=new Ie({p1:t,p2:t.add(e),ends:1}),null==(e=o.intersectsWith(e)).intersect||e.collinear||!o.hasPointOn(e.intersect,this.precision)?null:{intersect:e.intersect,distance:e.intersect.distance(t),normal:a})}},{key:"intersect",value:function(t,e){var n,r,i=this.clip(Ae(t)).round(this.precision),o=this.plane.pointProjection(this.plane.p.add(Ae(e).normalize())).sub(this.plane.p),a=(s=this.boundary).left,s=(t=s.right,e=s.top,s.bottom);if(a=this.getBoundIntersect(i,o,t,a,this.rightDirection),s=this.getBoundIntersect(i,o,e,s,this.topDirection),null==a&&null==s)return{intersect:null,distance:0,reflection:o};if(null!=a&&null==s)n=a.intersect,r=a.distance,l=a.normal;else if(null!=s&&null==a)n=s.intersect,r=s.distance,l=s.normal;else if(a.distance>s.distance)n=s.intersect,r=s.distance,l=s.normal;else{if(!(s.distance>a.distance))return{intersect:a.intersect,distance:a.distance,reflection:o.scale(-1)};n=a.intersect,r=a.distance,l=a.normal}o=o;var l=l;return{distance:r,intersect:n,reflection:l.scale(-2*l.dotProduct(o)).add(o).normalize()}}}]),e}(),wn=function(){cn(e,vn);var t=fn(e);function e(n){pn(this,e);var r=ft({},{precision:8},n);return n=null!=r.line?Fe(r.line):Fe(r),t.call(this,n,r.precision)}return yn(e,[{key:"isDefined",value:function(){return!0}},{key:"_dup",value:function(){return new e({precision:this.precision,line:this.boundary})}},{key:"_state",value:function(t){return t=Nt(t),{f1Type:"lineBounds",state:[this.precision,[p(this.boundary.p1.x,t),p(this.boundary.p1.y,t),p(this.boundary.p1.z,t)],[p(this.boundary.p2.x,t),p(this.boundary.p2.y,t),p(this.boundary.p2.z,t)],this.boundary.ends]}}},{key:"contains",value:function(t){if("number"==typeof t)throw new Error("LineBounds.contains only accepts a point: ".concat(t));return t=Ae(t),this.boundary.hasPointOn(t,this.precision)}},{key:"clip",value:function(t){if("number"==typeof t)throw new Error("LineBounds.clip only accepts a point: ".concat(t));return t=Ae(t),this.boundary.clipPoint(t,this.precision)}},{key:"intersect",value:function(t,e){if("number"==typeof t)throw new Error("LineBounds.clip only accepts a point: ".concat(t));var n=this.boundary.clipPoint(t),r=this.boundary.unitVector(),i=Ae(e).componentAlong(r).normalize();if(0===this.boundary.ends)return{intersect:null,distance:0,reflection:i};var o=this.boundary;if(t=this.boundary.p1._dup(),e=this.boundary.p2._dup(),0<(r=i.projectOn(r)))return 2===o.ends?{intersect:e,distance:n.distance(e),reflection:i.scale(-1)}:{intersect:null,distance:0,reflection:i};if(r<0)return{intersect:t,distance:n.distance(t),reflection:i.scale(-1)};throw new Error("LineBounds.intersect error - could not find intersect")}}]),e}();function xn(t){if(null==t)return new vn;if(t instanceof vn)return t;if(void 0!==t.min||void 0!==t.max)return new gn(t);if(void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom||void 0!==t.position||void 0!==t.normal||void 0!==t.rightDirection||void 0!==t.topDirection)return new bn(t);if(void 0!==t.line||void 0!==t.p1||void 0!==t.p2||void 0!==t.angle||void 0!==t.mag||void 0!==t.ends)return new wn(t);if(void 0!==t.f1Type&&null!=t.state){var e=t.f1Type,n=t.state;if(null!=e&&"rangeBounds"===e&&null!=n&&Array.isArray([n])&&3===n.length){var r=(l=ln(n,3))[0],i=l[1],o=l[2];return new gn({precision:r,min:i,max:o})}if(null!=e&&"rectBounds"===e&&null!=n&&Array.isArray([n])&&8===n.length){var a=(c=ln(n,8))[0],s=c[1],l=c[2],u=(r=c[3],i=c[4],o=c[5],c[6]),c=c[7];return new bn({precision:a,left:s,bottom:r,right:l,top:i,position:o,topDirection:u,rightDirection:c})}if(null!=e&&"lineBounds"===e&&null!=n&&Array.isArray([n])&&4===n.length)return c=(u=ln(n,4))[0],e=u[1],n=u[2],u=u[3],new wn({precision:c,p1:e,p2:n,ends:u})}throw new Error("Cannot parse bounds ".concat(JSON.stringify(t)))}function Sn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Tn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Tn(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function An(t,e,n,r){return t=Math.abs(t),r=Math.abs(t)-r,[t*(e=null==e||e>Math.abs(r/n)?Math.abs(r/n):e)-.5*n*Math.pow(e,2),e]}function kn(t,e,n){var r=Math.abs(t);return n=.5*(t=-r/Math.abs(r)*n),e=-e,[n=(-r+Math.sqrt(Math.pow(r,2)-4*n*e))/(2*n),r+t*n]}function _n(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:8;if(null===r&&0===m(n,s)&&(0===o||null==i||!i.isDefined()))return{velocity:e,value:t,duration:null};if(Math.abs(e)<=a)return{velocity:0,value:t,duration:0};var l=null!=i?i.clip(t):t,u=Math.max(n,1e-7),c=m(e/Math.abs(e),1),h=(t=(h=Sn(An(e,r,u,a),2))[0],n=h[1],l+c*t);if(null==i||i.contains(h)){if(null==r)return{duration:n,value:h,velocity:0};var f=Math.abs(e)-u*n;return{value:h,velocity:(f=m(f,s)<=m(a,s)?0:f)*c,duration:n}}if(f=1-o,null!=(l=i.intersect(l,c)).distance&&l.distance>t)throw new Error("Error in calculating intersect");return c=l.intersect,t=l.reflection,l=(e=Sn(kn(e,l.distance,u),2))[0],e=e[1],1===o?{velocity:new Oe(0,0),value:c,duration:l}:(t*=e*f,null!=r?_n(c,t,u,n-l,i,o,a,s):{duration:l+(s=_n(c,t,u,r,i,o,a,s)).duration,value:s.value,velocity:0})}function On(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:8;if(null==r&&0===m(n,s)&&(0===o||null==i||!i.isDefined()))return{velocity:e,position:t,duration:null};var l=e;i instanceof wn?l=i.boundary.pointProjection(i.boundary.p1.add(l)).sub(i.boundary.p1):i instanceof bn&&(l=i.plane.pointProjection(i.plane.p.add(l)).sub(i.plane.p));var u=l.length(),c=l.normalize();if(u<=a)return{velocity:new Oe(0,0,0),position:t,duration:0};var h=t._dup();if(null!=i&&(h=i.clip(t)),t=(l=Sn(An(u,r,e=Math.max(n,1e-7),a),2))[0],n=l[1],l=h.add(c.scale(t)),null==i||i.contains(l)){if(null==r)return{duration:n,position:l,velocity:new Oe(0,0,0)};var f=u-e*n;return m(f,s)<=m(a,s)&&(f=0),{position:l,velocity:c.scale(f),duration:n}}if(f=1-o,0!==(h=i.intersect(h,c)).distance&&h.distance>t||null==h.intersect)throw new Error("Error in calculating intersect1");return c=h.intersect,t=h.distance,h=h.reflection,t=(u=Sn(kn(u,t,e),2))[0],u=u[1],1===o?{velocity:new Oe(0,0,0),position:c,duration:t}:(f=h.scale(u*f),null!=r?On(c,f,e,n-t,i,o,a,s):{duration:t+(s=On(c,f,e,r,i,o,a,s)).duration,position:s.position,velocity:new Oe(0,0)})}function Pn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var En=function(){function t(e,n,r,i){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.left=e,this.width=r,this.height=i,this.bottom=n,this.top=n+i,this.right=e+r}var e=[{key:"_dup",value:function(){return new t(this.left,this.bottom,this.width,this.height)}},{key:"_state",value:function(t){return t=Nt(t),{f1Type:"rect",state:[p(this.left,t),p(this.bottom,t),p(this.width,t),p(this.height,t)]}}},{key:"isPointInside",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=Ae(t).round(e),r=p(this.top,e),i=p(this.bottom,e);return t=p(this.left,e),e=p(this.right,e),!(n.x<t||n.x>e||n.y<i||n.y>r)}},{key:"round",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8,n=new t(p(this.left,e),p(this.bottom,e),p(this.width,e),p(this.height,e));return n.width=p(n.width,e),n.height=p(n.height,e),n.top=p(n.top,e),n.right=p(n.right,e),n}},{key:"intersectsWith",value:function(t){var e=Ae(t),n=this.center();return t=new Ie(n,e),e=new Ie({p1:n,length:this.width+this.height,angle:t.angle()}),n=new Ie([this.left,this.bottom],[this.left,this.top]),(t=e.intersectsWith(n)).onLines?t.intersect:(n=new Ie([this.left,this.top],[this.right,this.top]),(t=e.intersectsWith(n)).onLines?t.intersect:(n=new Ie([this.right,this.top],[this.right,this.bottom]),(t=e.intersectsWith(n)).onLines?t.intersect:(n=new Ie([this.left,this.bottom],[this.right,this.bottom]),(t=e.intersectsWith(n)).onLines?t.intersect:null)))}},{key:"intersectsWithLine",value:function(t){var e=Fe(t),n=new Ie([this.left,this.bottom],[this.left,this.top]),r=new Ie([this.left,this.top],[this.right,this.top]),i=new Ie([this.right,this.top],[this.right,this.bottom]),o=new Ie([this.left,this.bottom],[this.right,this.bottom]);return t=[],(n=e.intersectsWith(n)).onLines&&t.push(n.intersect),(r=e.intersectsWith(r)).onLines&&t.push(r.intersect),(o=e.intersectsWith(o)).onLines&&t.push(o.intersect),(i=e.intersectsWith(i)).onLines&&t.push(i.intersect),t}},{key:"center",value:function(){return new Oe(this.left+this.width/2,this.bottom+this.height/2)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Mn(t){return null==(t=function(t,e){if(t instanceof En)return t;var n=e;if(null==n&&(n=null),null==t)return n;var r=t;if("string"==typeof r)try{r=JSON.parse(r)}catch(t){return n}if(Array.isArray(r)&&4===r.length)return new En(r[0],r[1],r[2],r[3]);var i,o=r;return e=o.f1Type,t=o.state,null!=e&&"rect"===e&&null!=t&&Array.isArray([t])&&4===t.length?(o=(r=function(t){if(Array.isArray(t))return t}(i=t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,r,i=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(i.push(n.value),4!==i.length);o=!0);}catch(t){a=!0,r=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw r}}return i}}(i)||function(t){if(t){if("string"==typeof t)return Pn(t,4);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Pn(t,4):void 0}}(i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],e=r[1],t=r[2],r=r[3],new En(o,e,t,r)):n}(t))?new En(0,0,1,1):t}function Cn(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<e-1;i+=1){for(var o=[],a=0;a<n-1;a+=1){var s=t[i][a],l=t[i][a+1],u=t[i+1][a],c=t[i+1][a+1];s.isEqualTo(l)||c.isEqualTo(l)?o.push(Ue(s,u,c)):o.push(Ue(s,c,l))}r.push(o)}return r}function jn(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<e-1;i+=1)for(var o=0;o<n-1;o+=1){var a=t[i][o],s=t[i][o+1],l=t[i+1][o],u=t[i+1][o+1];a.isEqualTo(s)||u.isEqualTo(s)||r.push(a,u,s),l.isEqualTo(u)||l.isEqualTo(a)||r.push(a,l,u)}return r}function Rn(t){if(0===t.length)return[];for(var e=t.length,n=t[0].length,r=[],i=0;i<e-1;i+=1)for(var o=0;o<n-1;o+=1){var a=t[i][o],s=t[i][o+1],l=t[i+1][o],u=t[i+1][o+1];r.push(a,s),r.push(a,l),o===n-2&&r.push(s,u),i===e-2&&r.push(l,u)}return r}function Bn(t,e){for(var n=e.length,r=e[0].length,i=[],o=0;o<n-1;o+=1)for(var a=0;a<r-1;a+=1){var s=t[o][a],l=e[o][a],u=e[o][a+1],c=e[o+1][a],h=e[o+1][a+1];l.isEqualTo(u)||h.isEqualTo(u)||i.push(s,s,s),c.isEqualTo(h)||c.isEqualTo(l)||i.push(s,s,s)}return i}function Fn(t,e,n,r,i){for(var o,a,s,l,u,c=e.length,h=e[0].length,f=[],d=0;d<c-1;d+=1)for(var p=0;p<h-1;p+=1){s=new Oe(0,0,0),S=new Oe(0,0,0),w=new Oe(0,0,0),l=new Oe(0,0,0),g=t[d][p],o=new Oe(0,0,0),x=new Oe(0,0,0),a=new Oe(0,0,0),b=new Oe(0,0,0),u=0<d?d-1:i?t.length-1:null,m=0<p?p-1:r?t[0].length-1:null,null!=u&&(a=t[u][p]),null!=m&&(o=t[d][m]),null!=(y=d<c-2?d+1:i?0:null)&&(s=t[y][p]),null!=(v=p<h-2?p+1:r?0:null)&&(l=t[d][v]),null!=u&&null!=m&&(b=t[u][m]),null!=u&&null!=v&&(x=t[u][v]),null!=y&&null!=m&&(w=t[y][m]),null!=y&&null!=v&&(S=t[y][v]);var m=g,y=g,v=g,g=g;"curveColumns"!==n&&"curve"!==n||(m=m.add(a),y=y.add(a),v=v.add(s),g=g.add(s)),"curveRows"!==n&&"curve"!==n||(m=m.add(o),v=v.add(o),y=y.add(l),g=g.add(l)),"curve"===n&&(m=m.add(b),v=v.add(w),y=y.add(x),g=g.add(S)),m=m.normalize(),y=y.normalize(),v=v.normalize(),g=g.normalize();var b=e[d][p],w=e[d][p+1],x=e[d+1][p],S=e[d+1][p+1];b.isEqualTo(w)||S.isEqualTo(w)||f.push(m,g,y),x.isEqualTo(S)||x.isEqualTo(b)||f.push(m,v,g)}return f}function In(t){var e,n=(l=ft({normals:"flat",lines:!1,closeColumns:!1,closeRows:!1,invertNormals:!1},t)).transform,r=l.lines,i=l.closeRows,o=l.closeColumns,a=l.normals,s=l.points,l=(t=l.invertNormals,s.map(ke));if(null!=n&&(e=rn(n).matrix(),l=s.map((function(t){return t.map((function(t){return Ae(t).transformBy(e)}))}))),r)return[Rn(l),[]];s=jn(l);var u=r=Cn(l);if(u="flat"!==a?Fn(r,l,a,o,i):Bn(r,l),t)for(var c=0;c<u.length;c+=1)u[c]=u[c].scale(-1);return[s,u]}function Dn(t){for(var e=ft({sides:10,radius:1,normals:"flat",output:"points",center:[0,0,0]},t),n=e.sides,r=e.radius,i=e.normals,o=e.transform,a=Ae(e.center),s=t=Math.PI/n,l=t,u=[],c=[],h=[],f=[],d=0;d<2*Math.PI+1e-4;d+=l){for(var p=[],m=[],y=0;y<Math.PI+1e-4;y+=s)p.push(Ae(Kt(r,y,d)).add(a)),m.push(Ae(Kt(1,y,d)));u.push(p),c.push(m)}if(null!=o)for(var v,g=Zt(be(v=rn(o).matrix())),b=0;b<u.length;b+=1)for(var w=c[b],x=0;x<u[0].length;x+=1)u[b][x]=u[b][x].transformBy(v),w[x]=w[x].transformBy(g);if(e.lines)return[Rn(u)];for(var S=0;S<2*n;S+=1)for(var T,A=0;A<n;A+=1)h.push(u[S][A]),h.push(u[S][A+1]),h.push(u[S+1][A+1]),h.push(u[S][A]),h.push(u[S+1][A+1]),h.push(u[S+1][A]),"curve"===i?(f.push(c[S][A]),f.push(c[S][A+1]),f.push(c[S+1][A+1]),f.push(c[S][A]),f.push(c[S+1][A+1]),f.push(c[S+1][A])):(T=Ae(Kt(1,A*s+s/2,S*l+l/2)),null!=g&&(T=T.transformBy(g)),f.push(T),f.push(T),f.push(T),f.push(T),f.push(T),f.push(T));return[h,f]}function Ln(t){var e,n=[],r=t.profile,i=t.sides,o=t.rotation,a=t.matrix,s=t.transform;null!=s&&(e=rn(s).matrix());for(var l=2*Math.PI/i,u=0;u<i+1;u+=1){for(var c=[],h=0;h<r.length;h+=1){var f=new Oe(r[h].x,r[h].y*Math.cos(l*u+o),r[h].y*Math.sin(l*u+o));0!==a&&(f=f.transformBy(a)),e&&(f=f.transformBy(e)),c.push(f.add(t.position))}n.push(c)}return n}function zn(t){var e=ft({sides:10,normals:"curved",ends:!0,position:[0,0,0],axis:[1,0,0],rotation:0},t);e.position=Ae(e.position),null==e.profile?e.profile=ke([[0,.1,0],[1,.2,0]]):e.profile=ke(e.profile);var n=e.sides,r=e.profile,i=e.rotation;return t=(new Qe).direction(e.axis).matrix(),n={sides:n,profile:r,normals:e.normals,matrix:t,position:e.position,rotation:i,transform:e.transform},"curveProfile"===(t="curveRadial"===(t=e.normals)?"curveColumns":t)&&(t="curveRows"),i=Ln(n),e.lines?[Rn(i)]:(n=Cn(i),[e=jn(i),r="flat"===t?Bn(n,i):Fn(n,i,t,r[0].isEqualTo(r[r.length-1]),!0)])}function Wn(t){var e=ft({sides:10,radius:.1,normals:"flat",rotation:0,length:1,lines:!1},t),n=e.rotation,r=e.sides,i=e.radius,o=e.normals,a=e.length,s=e.transform;return t=e.lines,a=null==e.line?new Ie([0,0,0],[a,0,0]):Fe(e.line),(e=[]).push([0,0],[0,i],[a.length(),0]),zn({sides:r,rotation:n,normals:"curve"===o?"curveRadial":"flat",axis:a.unitVector().toArray(),position:a.p1,profile:e,transform:s,lines:t})}function Nn(t){var e=ft({p1:[0,0,0],sides:10,width:.01,normals:"curve",rotation:0,lines:!1},t),n=e.rotation,r=e.sides,i=e.normals,o=e.p1,a=e.width,s=e.transform,l=e.lines,u=e.arrow,c=e.p2;return null!=(t=u)&&("boolean"==typeof t?t=t?{ends:"end",width:2.5*a,length:2.5*a*3}:null:(null==t.ends&&(t.ends="end"),null==t.width&&(t.width=2.5*a),null==t.length&&(t.length=3*t.width))),null==c&&(c=Ae(o).add(1,0,0)),u=0,o=(e=new Ie(o,c)).length(),null!=t&&("start"!==t.ends&&"all"!==t.ends||(u=t.length),"end"!==t.ends&&"all"!==t.ends||(o=e.length()-t.length)),(c=[]).push([0,0]),null==t||"start"!==t.ends&&"all"!==t.ends||c.push([u,t.width]),c.push([u,a]),c.push([o,a]),null==t||"end"!==t.ends&&"all"!==t.ends||c.push([o,t.width]),c.push([e.length(),0]),zn({sides:r,rotation:n,normals:"curve"===i?"curveRadial":"flat",axis:e.unitVector(),position:e.p1,profile:c,transform:s,lines:l})}function qn(t){var e=(l=ft({sides:10,radius:.1,normals:"flat",ends:!0,rotation:0,length:1,lines:!1},t)).ends,n=l.rotation,r=l.sides,i=l.radius,o=l.normals,a=l.length,s=l.transform,l=(t=l.lines,a=null==l.line?new Ie([0,0,0],[a,0,0]):Fe(l.line),[]);return!0!==e&&1!==e||l.push([0,0]),l.push([0,i],[a.length(),i]),!0!==e&&2!==e||l.push([a.length(),0]),zn({sides:r,rotation:n,normals:"curve"===o?"curveRadial":"flat",axis:a.unitVector().toArray(),position:a.p1,profile:l,transform:s,lines:t})}function Hn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Un(t){if(2===(1<arguments.length&&void 0!==arguments[1]?arguments[1]:3))return function(t){for(var e=Array(2*t.length),n=0;n<t.length;n+=1)e[2*n]=t[n].x,e[2*n+1]=t[n].y;return e}(t);for(var e=Array(3*t.length),n=0;n<t.length;n+=1)e[3*n]=t[n].x,e[3*n+1]=t[n].y,e[3*n+2]=t[n].z;return e}function Kn(t){if(2===(1<arguments.length&&void 0!==arguments[1]?arguments[1]:3))return function(t){for(var e=Array(t.length/2),n=0;n<e.length;n+=1)e[n]=new Oe(t[2*n],t[2*n+1]);return e}(t);for(var e=Array(t.length/3),n=0;n<e.length;n+=1)e[n]=new Oe(t[3*n],t[3*n+1],t[3*n+2]);return e}function Vn(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:3;if(0===t.length)return[];if("number"==typeof t[0])return t;if(Array.isArray(t[0])){for(var r=[],i=0;i<t.length;i+=1)r.push.apply(r,function(t){if(Array.isArray(t))return Hn(t)}(e=t)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return Hn(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Hn(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return r}return Un(t,n)}function Gn(t){return 0===t.length?[]:"number"!=typeof t[0]?t:Kn(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:3)}function Yn(t){return function(t){if(Array.isArray(t))return Xn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Xn(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Xn(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Xn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function $n(t){var e=(c=ft({side:1},t)).side,n=c.center,r=c.transform;if(c.lines)return[function(t,e,n){var r=t/2;if(t=Gn([-r,-r,r,r,-r,r,r,-r,r,r,r,r,r,r,r,-r,r,r,-r,r,r,-r,-r,r,-r,-r,r,-r,-r,-r,-r,r,r,-r,r,-r,r,r,r,r,r,-r,r,-r,r,r,-r,-r,-r,-r,-r,r,-r,-r,r,-r,-r,r,r,-r,r,r,-r,-r,r,-r,-r,r,-r,-r,-r,-r]),null==e&&null==n)return t;r=new Qe,null!=e&&(r=r.translate(e));var i=(r=null!=n?new Qe([].concat(Yn(r.def),Yn(rn(n).def))):r).matrix();return t.map((function(t){return t.transformBy(i)}))}(e,n,r)];var o,a,s,l=Gn([-(h=e/2),-h,h,h,-h,h,h,h,h,-h,-h,h,h,h,h,-h,h,h,h,-h,h,h,-h,-h,h,h,-h,h,-h,h,h,h,-h,h,h,h,h,h,h,h,h,-h,-h,h,-h,h,h,h,-h,h,-h,-h,h,h,-h,-h,-h,h,h,-h,h,-h,-h,-h,-h,-h,-h,h,-h,h,h,-h,-h,-h,h,-h,h,-h,-h,-h,-h,-h,-h,h,-h,h,h,-h,h,-h,h,-h,h,-h,-h,-h,h,-h,-h,h,-h,h,-h,-h,h,-h,-h,-h]);if(t=Gn([0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0]),null==n&&null==r)return[l,t];null!=r&&(a=Zt(be(o=rn(r).matrix()))),null!=n&&(s=Ae(n));var u=[],c=[1,0,0],h=(e=[-1,0,0],[0,1,0]);t=[0,-1,0],r=[0,0,1],n=[0,0,-1],null!=a&&(c=ue.apply(i,[a].concat(Yn(c))),e=ue.apply(i,[a].concat(Yn(e))),h=ue.apply(i,[a].concat(Yn(h))),t=ue.apply(i,[a].concat(Yn(t))),r=ue.apply(i,[a].concat(Yn(r))),n=ue.apply(i,[a].concat(Yn(n))));for(var f=0;f<36;f+=1){var d=l[f];null!=s&&(d=d.add(s)),null!=o&&(d=d.transformBy(o)),u.push(d)}return[u,[Ae(r),Ae(r),Ae(r),Ae(r),Ae(r),Ae(r),Ae(c),Ae(c),Ae(c),Ae(c),Ae(c),Ae(c),Ae(h),Ae(h),Ae(h),Ae(h),Ae(h),Ae(h),Ae(n),Ae(n),Ae(n),Ae(n),Ae(n),Ae(n),Ae(e),Ae(e),Ae(e),Ae(e),Ae(e),Ae(e),Ae(t),Ae(t),Ae(t),Ae(t),Ae(t),Ae(t)]]}function Jn(t){return function(t){if(Array.isArray(t))return Zn(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Zn(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Zn(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Qn(t){var e=(i=ft({},{length:1,options:t},t)).base,n=i.length,r=i.transform,i=(t=i.lines,i.baseTriangles);if(t)return[function(t,n){for(var r=[],i=ke(e),o=0;o<i.length-1;o+=1)r.push(i[o],i[o+1]);r.push(i[i.length-1],i[0]);for(var a=r.map((function(e){return e.add(0,0,t)})),s=[],l=0;l<r.length;l+=2)s.push(r[l],a[l]);if(null==n)return[].concat(r,s,Jn(a));var u=rn(n).matrix();return[].concat(r,s,Jn(a)).map((function(t){return t.transformBy(u)}))}(n,r)];var o=ke(e),a=o.map((function(t){return t.add(0,0,n)})),s=[];if(null!=i)s=ke(i);else for(var l=2;l<o.length;l+=1)s.push(o[0],o[l],o[l-1]);e=s.map((function(t){return t.add(0,0,n)}));for(var u=[],c=0;c<o.length-1;c+=1)u.push(a[c],o[c],o[c+1]),u.push(a[c],o[c+1],a[c+1]);i=o.length-1,u.push(a[i],o[i],o[0]),u.push(a[i],o[0],a[0]),e=[].concat(Jn(s),u,Jn(e));for(var h=[],f=0;f<s.length;f+=1)h.push(new Oe(0,0,-1));for(var d=0;d<u.length-2;d+=3){var p=Ue(u[d],u[d+1],u[d+2]);h.push(p._dup(),p._dup(),p._dup())}for(var m,y=0;y<s.length;y+=1)h.push(new Oe(0,0,1));return null!=r&&(m=rn(r).matrix(),e=e.map((function(t){return t.transformBy(m)})),h=h.map((function(t){return t.transformBy(m)}))),[e,h]}function tr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return er(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?er(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function er(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function nr(t,e,n,r,i,o,a){for(var s=5<arguments.length&&void 0!==o?o:null,l=(a=6<arguments.length&&void 0!==a&&a,Array(e+(a?1:0))),u=2*Math.PI/e,c=0;c<e;c+=1){var h=n+c*u*r;l[c]=new Oe(t*Math.cos(h)+i.x,t*Math.sin(h)+i.y)}if(null!=s)for(var f=0;f<e;f+=1)l[f]=l[f].transformBy(s);return a&&(l[e]=l[0]._dup()),l}function rr(t){var e,n=ft({sides:4,radius:1,rotation:0,direction:1,center:[0,0,0],close:!1},t);t=Ae(n.center),null!=n.transform&&(r=n.transform,e=Array.isArray(r)&&16===r.length&&"number"==typeof r[0]?r:nn(r).matrix());var r=n.innerRadius;return null==n.innerRadius&&(r=.5*n.radius),[n.radius,n.sides,n.rotation,n.direction,t,e,n.tris,n.close,r]}function ir(t){var e=tr(rr(t),8),n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=(t=e[6],nr(n,r,i,o,a,s,e[7]));if(null==t)return l;for(var u=Array(3*r),c=0;c<r-1;c+=1)u[3*c]=a,u[3*c+1]=l[c],u[3*c+2]=l[c+1];return u[3*r-3]=a,u[3*r-2]=l[r-1],u[3*r-1]=l[0],Un(u,t)}function or(t){return(or="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ar(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return sr(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sr(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function lr(t,e){var n=e.x.span/t.x.span,r=e.y.span/t.y.span,i=e.z.span/t.z.span;return(new Qe).scale(n,r,i).translate(e.x.min-t.x.min*n,e.y.min-t.y.min*r,e.z.min-t.z.min*i)}function ur(t,e,n,r){var i=new Oe(0,0),o=new Oe(0,0);return r?(i.x=t.x,i.y=t.y,o.x=t.x,o.y=t.y):(i.x=(t.x<e.x?t:e).x,i.y=(t.y<e.y?t:e).y,o.x=(t.x>n.x?t:n).x,o.y=(t.y>n.y?t:n).y),{min:i,max:o}}function cr(t){if("number"==typeof t)return!0;if(Array.isArray(t))return(4===t.length||2===t.length)&&"number"==typeof t[0];if("object"!==or(t))return!1;var e=Object.keys(t);if(4<e.length)return!1;for(var n=0;n<e.length;n+=1){var r=e[n];if("left"!==r&&"right"!==r&&"top"!==r&&"bottom"!==r)return!1}return!0}function hr(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=!0,r={min:new Oe(0,0),max:new Oe(0,0)};t.forEach((function(t){Array.isArray(t)?t.forEach((function(t){r=ur(t,r.min,r.max,n),n=!1})):r=ur(t,r.min,r.max,n),n=!1}));var i,o,a=("number"==typeof e?l=s=a=i=e:Array.isArray(e)?2===e.length?(a=i=(o=ar(e,2))[0],l=s=o[1]):(i=(o=ar(e,4))[0],l=o[1],a=o[2],s=o[3]):(i=(e=ft({left:0,right:0,top:0,bottom:0},e)).left,a=e.right,s=e.top,l=e.bottom),{left:i,right:a,top:s,bottom:l}),s=a.left,l=a.bottom;return new En(r.min.x-s,r.min.y-l,r.max.x-r.min.x+a.right+s,r.max.y-r.min.y+a.top+l)}function fr(t){return t=hr(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),[new Oe(t.left,t.bottom),new Oe(t.right,t.bottom),new Oe(t.right,t.top),new Oe(t.left,t.top)]}function dr(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,i=e.sub(t),o=0,a="number"==typeof n?t._dup().constant(n):n;return i.def.forEach((function(n,i){if("t"===n[0]||"s"===n[0]){var s=a.def[i];if("t"===s[0]||"s"===s[0])for(var l,u=1;u<4;u+=1)0!==s[u]&&(l=Math.abs(n[u]/s[u]),o=o<l?l:o)}var c=t.def[i],h=e.def[i];if("r"===n[0]&&"r"===c[0]&&"r"===h[0])for(var f=1;f<4;f+=1){var d=Ce(c[f],h[f],r),p=a.def[i][f];0!==p&&(p=Math.abs(d/p),o=o<p?p:o)}})),o}function pr(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new Oe(.25,.25),i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new Oe(0,0,2*Math.PI/6),o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:new Oe(1,1),a=(t=t instanceof Qe?[t]:t,e instanceof Qe?[e]:e);if(a.length!==t.length)return 0;var s=0;return t.forEach((function(t,e){e=a[e];for(var l=t._dup(),u=0;u<l.def.length;u+=1){var c=l.def[u];"t"===c[0]?(c[1]=r.x,c[2]=r.y,c[3]=r.z):"r"===c[0]?(c[1]=i.x,c[2]=i.y,c[3]=i.z):(c[1]=o.x,c[2]=o.y,c[3]=o.z)}e=dr(t,e,l,n),s<e&&(s=e)})),s}function mr(t,e,n,r){var i=1/r;if(0===r||1===r||2===r)return[t,e,n];for(var o=[],a=0;a<r+1;a+=1){var s=0+a*i;o.push(new Oe(Math.pow(1-s,2)*t.x+2*(1-s)*s*e.x+s*s*n.x,Math.pow(1-s,2)*t.y+2*(1-s)*s*e.y+s*s*n.y))}return o}function yr(t,e,n){var r=Ae(t);return t=Ae(e),e=Ae(n),n=(r.x+t.x+e.x)/3,e=(r.y+t.y+e.y)/3,new Oe(n,e)}function vr(t){return"string"==typeof t||"number"==typeof t||cr(t)?t:Te(t[0])?[t.map(Ae)]:t.map((function(t){return t.map(Ae)}))}function gr(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=Mn(t);return t=new Oe(r.left,r.bottom),"center"===e?t.x+=r.width/2:"right"===e?t.x=r.right:"number"==typeof e?t.x+=r.width*e:e.startsWith("o")&&(t.x+=parseFloat(e.slice(1))),"middle"===n?t.y+=r.height/2:"top"===n?t.y=r.top:"number"==typeof n?t.y+=r.height*n:n.startsWith("o")&&(t.y+=parseFloat(n.slice(1))),t}function br(t){var e=[];if(Array.isArray(t.x)&&Array.isArray(t.y)){if("function"!=typeof t.z)throw new Error("surfaceGrid must have two components as ranges, and the third as a function");for(var n=t.x[0];n<=t.x[1];n+=t.x[2]){for(var r=[],i=t.y[0];i<=t.y[1];i+=t.y[2])r.push(new Oe(n,i,t.z(n,i)));e.push(r)}return e}if(Array.isArray(t.x)&&Array.isArray(t.z)){if("function"!=typeof t.y)throw new Error("surfaceGrid must have two components as ranges, and the third as a function");for(var o=t.x[0];o<=t.x[1];o+=t.x[2]){for(var a=[],s=t.z[0];s<=t.z[1];s+=t.z[2])a.push(new Oe(o,t.y(o,s),s));e.push(a)}return e}if(Array.isArray(t.y)&&Array.isArray(t.z)){if("function"!=typeof t.x)throw new Error("surfaceGrid must have two components as ranges, and the third as a function");for(var l=t.y[0];l<=t.y[1];l+=t.y[2]){for(var u=[],c=t.z[0];c<=t.z[1];c+=t.z[2])u.push(new Oe(t.x(l,c),l,c));e.push(u)}return e}throw new Error("surfaceGrid must have two components as ranges, and the third as a function")}function wr(t,e){return[t[0]*e[0]+t[1]*e[3]+t[2]*e[6],t[0]*e[1]+t[1]*e[4]+t[2]*e[7],t[0]*e[2]+t[1]*e[5]+t[2]*e[8],t[3]*e[0]+t[4]*e[3]+t[5]*e[6],t[3]*e[1]+t[4]*e[4]+t[5]*e[7],t[3]*e[2]+t[4]*e[5]+t[5]*e[8],t[6]*e[0]+t[7]*e[3]+t[8]*e[6],t[6]*e[1]+t[7]*e[4]+t[8]*e[7],t[6]*e[2]+t[7]*e[5]+t[8]*e[8]]}function xr(t){return function(t){if(Array.isArray(t))return Sr(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Sr(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Sr(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Sr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Tr(t,e,n,r,i,o){var a=new Ie(e,t),s=new Ie(e,n),l="fromVertex"===i?(l=o,Math.min(l,a.length()/2*.99,s.length()/2*.99)):"radius"===i?(n=Math.abs(Re(t,e,n))/2,l=o/Math.tan(n),Math.min(l,a.length()/2*.99,s.length()/2*.99)):Math.min(a.length(),s.length());return function(t,e,n,r){if(r<1)return[t._dup(),e._dup(),n._dup()];if(1===r)return[t._dup(),n._dup()];var i=t._dup(),o=n._dup(),a=[];if((f=Re(i,e,o))===Math.PI){a.push(t._dup());for(var s=0;s<r-2;s+=1)a.push(e._dup());return a.push(n._dup()),a}var l=!1;0===f&&(l=!0,f=1e-5);var u=f/Math.abs(f),c=new Ie(e,i),h=Math.abs(f/2),f=(t=Math.PI/2,n=Math.PI-h-t,c.length()),d=(f=Math.sin(t)/Math.sin(n)*f,new Oe(e.x+f*Math.cos(h*u+c.angle()),e.y+f*Math.sin(h*u+c.angle()))),p=2*n/r*u*-1,m=(u=new Ie(d,i)).angle(),y=u.length();if(a.push(i),l)for(var v=c.angle()+Math.PI/2,g=Math.PI/r,b=0;b<=r;b+=1)a.push(new Oe(d.x+1e-4*Math.cos(v+g*b),d.y+1e-4*Math.sin(v+g*b)));else for(var w=0;w<r-1;w+=1){var x=m+(w+1)*p;a.push(new Oe(d.x+y*Math.cos(x),d.y+y*Math.sin(x)))}return a.push(o),a}(a.pointAtPercent(l/a.length()),e,s.pointAtPercent(l/s.length()),r)}function Ar(t,e,n,r,i){var o=4<arguments.length&&void 0!==i&&i,a=new Ie(e,t),s=new Ie(e,n),l=a.pointAtPercent(r/a.length());return i=s.pointAtPercent(r/s.length()),!1===o&&(r>a.length()&&(l=t._dup()),r>s.length()&&(i=n._dup())),[l,e._dup(),i]}function kr(t){return function(t){if(Array.isArray(t))return Pr(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Or(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Or(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Or(t,e){if(t){if("string"==typeof t)return Pr(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pr(t,e):void 0}}function Pr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Er(t,e,n){for(var r=2<arguments.length&&void 0!==n?n:8,i=e>t.sum?p(e%t.sum,r):e,o=0;o<t.definition.length;o+=1){if(i<t.cum[o])return[o,p(t.cum[o]-i,r)];if(i===t.cum[o])return o+1<t.definition.length?[o+1,p(t.cum[o+1]-i,r)]:[0,p(t.cum[0],r)]}return[0,0]}function Mr(t){var e=t.radius,n=t.rotation,r=t.offset,i=t.sides,o=t.sidesToDraw,a=t.direction,s=t.innerRadius,l=2*Math.PI/i,u=1;null!=s&&(l/=2,u=2);var c=[];if(0===o)return[];for(var h=0;h<o*u;h+=u)c.push(new Oe(e*Math.cos(l*h*a+n)+r.x,e*Math.sin(l*h*a+n)+r.y)),null!=s&&c.push(new Oe(s*Math.cos(l*(h+1)*a+n)+r.x,s*Math.sin(l*(h+1)*a+n)+r.y));return o<i&&c.push(new Oe(e*Math.cos(l*o*u*a+n)+r.x,e*Math.sin(l*o*u*a+n)+r.y)),c}function Cr(t,e,n,r){for(var i=[],o=1;o<e.length;o+=1)i.push(t._dup()),i.push(e[o]._dup()),i.push(e[o-1]._dup());return n===r&&(i.push(t._dup()),i.push(e[0]._dup()),i.push(e[e.length-1]._dup())),i}function jr(t){return function(t){if(Array.isArray(t))return Fr(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Br(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Br(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Br(t,e){if(t){if("string"==typeof t)return Fr(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fr(t,e):void 0}}function Fr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ir(t,e,n){return[new Oe(-t-n,-e/2-n),new Oe(n,-e/2-n),new Oe(n,e/2+n),new Oe(-t-n,e/2+n)]}function Dr(t){return t.map((function(t){return t._dup()}))}function Lr(t){var e=new Ie({p1:[-t.length,t.tailWidth/2],length:1,angle:0}),n=new Ie([-t.length,0],[0,t.width/2]),r=e.intersectsWith(n).intersect||new Oe(-t.length,t.tailWidth/2),i=0;"number"==typeof t.tail&&(i=t.tail),i=Math.max(r.x,i);var o=-t.length;return 0<i&&(o=-(t.length-i),n=new Ie([o,0],[0,t.width/2]),r=e.intersectsWith(n).intersect||new Oe(-t.length+i,t.tailWidth/2)),n=-t.length,[r,o,n=i<0?-t.length-i>=r.x?r.x:-t.length-i:n]}function zr(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(-t.barb,e);var n=-t.length;0<e&&(n=-(t.length-e));var r=-t.length;e<0&&(r=-e<t.barb?-t.length-e:n+t.barb),!1===t.tail&&(r=n+t.barb);var i=new Ie({p1:[r,t.tailWidth/2],length:1,angle:0});return e=new Ie([n+t.barb,0],[n,t.width/2]),e=(i=i.intersectsWith(e)).intersect||new Oe(r,t.tailWidth/2),[e=!1===i.onLines?new Oe(n+t.barb,t.tailWidth/2):e,n,r]}function Wr(t){var e=0;"number"==typeof t.tail&&(e=t.tail);var n=Math.atan(t.width/2/t.length),r=Math.PI-n-Math.PI/2,i=t.tailWidth*Math.cos(r),o=-t.length,a=-t.length;0<e&&(o=-(t.length-e));var s=new Ie([o+i,t.width/2],[0,0]),l=s.offset("bottom",t.tailWidth),u=new Ie({p1:[o,t.tailWidth/2],length:1,angle:0});return n=s.intersectsWith(u).intersect||new Oe(o,t.tailWidth/2),(r=l.intersectsWith(u).intersect||new Oe(o,t.tailWidth/2)).x<-t.length&&(r=new Oe(-t.length,t.tailWidth/2)),u=(i=l.intersectsWith(new Ie({p1:[-t.length,0],length:1,angle:0})))?i.intersect.x:-t.length,i.onLines&&!1!==t.tail||(a=-t.length),i=!1,e<0&&(-t.length-e>r.x?(a=r.x,i=!0):a=-t.length-e),!1===t.tail&&(a=u),[new Oe(n.x,t.tailWidth/2),o,a,u,s.p1,l.p1,i,r]}function Nr(t){var e,n,r,i,o=t.head,a=t.length;return"circle"===o||"polygon"===o?(n=0,"number"==typeof(e=t).tail&&(n=Math.max(0,e.tail)),"mid"===e.align?(e.tail,[e.radius,e.radius,2*e.radius+n]):"boolean"==typeof e.tail?[2*e.radius,2*e.radius,2*e.radius]:[n=2*e.radius+n,n,n]):"line"===o?(n=Rr(Wr(e=t),3)[2],[e.length,-n,e.length]):"reverseTriangle"===o?(r=Rr(Lr(i=t),3)[2],[i.length,-r,i.length]):"triangle"===o?[t.length,t.length,t.length]:"barb"===o?(i=Rr(zr(r=t),3)[2],[r.length,-i,r.length]):"rectangle"===o||"bar"===o?"mid"===t.align?[t.length/2,t.length/2,t.length]:[t.length,t.length,t.length]:[a,a,a]}function qr(t){var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x=ft({},t);null!=x.drawPosition&&(x.drawPosition=Ae(x.drawPosition)),0<x.tailWidth&&x.width<x.tailWidth&&(x.width=.001*x.tailWidth);var S,T,A,k="barb"===x.head?(u=(S=x).length,f=S.drawBorderBuffer,e=S.tailWidth,c=S.barb,n=S.width,t=S.tail,T=(r=Rr(zr(S),3))[0],S=r[1],r=r[2],T=!1===t||T.x>=S+c?[new Oe(-u+c,0),new Oe(-u,-n/2),new Oe(0,0),new Oe(-u,n/2)]:[new Oe(r,-e/2),new Oe(T.x,-e/2),new Oe(S,-n/2),new Oe(0,0),new Oe(S,n/2),new Oe(T.x,e/2),new Oe(r,e/2)],r=[new Oe(r,e/2),new Oe(r,-e/2)],S=(c=Rr([e=T,e=0<f?Ir(u,n,f):e,r],3))[0],T=c[1],c[2]):"rectangle"===x.head||"bar"===x.head?(S=(w=Rr((m=(p=x).length,y=p.drawBorderBuffer,v=p.tailWidth,g=p.width,b=p.tail,t=(w=Rr(function(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=-t.length;return 0<e&&(n=-(t.length-e)),e=-t.length,[new Oe(e,t.tailWidth/2),n,e]}(p),3))[0],p=w[1],w=w[2],p=!1===b||t.x>=p?[new Oe(-m,-g/2),new Oe(0,-g/2),new Oe(0,g/2),new Oe(-m,g/2)]:[new Oe(w,-v/2),new Oe(p,-v/2),new Oe(p,-g/2),new Oe(0,-g/2),new Oe(0,g/2),new Oe(p,g/2),new Oe(p,v/2),new Oe(w,v/2)],w=[new Oe(w,v/2),new Oe(w,-v/2)],[v=p,v=0<y?Ir(m,g,y):v,w]),3))[0],T=w[1],w[2]):"line"===x.head?(i=(u=x).length,a=u.drawBorderBuffer,l=u.tailWidth,o=u.width,n=u.tail,e=(f=Rr(Wr(u),8))[0],s=f[2],r=f[3],c=f[4],w=f[5],u=f[6],f=f[7],w=!1===n||e.x<=s?[new Oe(c.x,-c.y),new Oe(0,0),new Oe(c.x,c.y),new Oe(w.x,w.y),new Oe(r,0),new Oe(w.x,-w.y)]:u?[new Oe(c.x,-c.y),new Oe(0,0),new Oe(c.x,c.y),new Oe(w.x,w.y),new Oe(f.x,f.y),new Oe(f.x,-f.y),new Oe(w.x,-w.y)]:[new Oe(c.x,-c.y),new Oe(0,0),new Oe(c.x,c.y),new Oe(w.x,w.y),new Oe(f.x,f.y),new Oe(s,l/2),new Oe(s,-l/2),new Oe(f.x,-f.y),new Oe(w.x,-w.y)],s=[new Oe(s,l/2),new Oe(s,-l/2)],S=(i=Rr([l=w,l=0<a?Ir(i,o,a):l,s],3))[0],T=i[1],i[2]):"polygon"===x.head||"circle"===x.head?(S=(h=Rr((c=(u=x).drawBorderBuffer,h=u.tailWidth,f=u.radius,d=u.tail,w=function(t){if(!1===t.tail)return Mr({radius:t.radius,sides:t.sides,sidesToDraw:t.sides,rotation:0,offset:new Oe(-t.radius,0),direction:1});var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=Math.PI-Math.asin(t.tailWidth/2/t.radius),r=Math.PI+Math.asin(t.tailWidth/2/t.radius),i=2*Math.PI/t.sides,o=Math.floor(n/i),a=Math.floor(r/i),s=Mr({radius:t.radius,sides:t.sides,sidesToDraw:t.sides,rotation:0,offset:new Oe(-t.radius,0),direction:1}),l=new Ie(s[o],s[o+1]);return n=new Ie(s[a],s[a+1]),r=new Ie({p1:[-t.radius,t.tailWidth/2],length:1,angle:0}),i=new Ie({p1:[-t.radius,-t.tailWidth/2],length:1,angle:0}),l=r.intersectsWith(l).intersect||new Oe(-t.radius,t.tailWidth/2),n=i.intersectsWith(n).intersect||new Oe(-t.radius,-t.tailWidth/2),[l,new Oe(2*-t.radius-e,t.tailWidth/2),new Oe(2*-t.radius-e,-t.tailWidth/2),n].concat(jr(s.slice(a+1)),jr(s.slice(0,o+1)))}(u),u=0,d=!1===d?[new Oe(2*-f,h/2),new Oe(2*-f,-h/2)]:("number"==typeof d&&(u=Math.max(d,0)),[new Oe(2*-f-u,h/2),new Oe(2*-f-u,-h/2)]),[h=w,h=0<c?Ir(2*f+u,2*f,c):h,d]),3))[0],T=h[1],h[2]):"reverseTriangle"===x.head?(a=(o=x).length,l=o.drawBorderBuffer,O=o.tailWidth,s=o.width,i=o.tail,h=(k=Rr(Lr(o),3))[0],o=k[1],k=k[2],h=!1===i||k>=h.x?[new Oe(0,-s/2),new Oe(0,s/2),new Oe(-a,0)]:o<k?(i=new Ie([k,-O/2],[k,0]),o=new Ie([-a,0],[0,s/2]),o=i.intersectsWith(o).intersect||new Oe(k,-O/2),[new Oe(0,-s/2),new Oe(0,s/2),new Oe(h.x,O/2),new Oe(k,O/2),new Oe(o.x,o.y),new Oe(-a,0),new Oe(o.x,-o.y),new Oe(k,-O/2),new Oe(h.x,-O/2)]):[new Oe(0,-s/2),new Oe(0,s/2),new Oe(h.x,O/2),new Oe(-a,O/2),new Oe(-a,-O/2),new Oe(h.x,-O/2)],k=[new Oe(k,O/2),new Oe(k,-O/2)],S=(O=Rr([O=h,O=0<l?Ir(a,s,l):O,k],3))[0],T=O[1],O[2]):(S=(_=Rr((i=(d=x).length,o=d.drawBorderBuffer,h=d.tailWidth,a=d.width,s=d.tail,l=(_=Rr(function(t){var e=0;"number"==typeof t.tail&&(e=t.tail),e=Math.max(0,e);var n=-t.length;return 0<e&&(n=-(t.length-e)),e=-t.length,[new Oe(e,t.tailWidth/2),n,e]}(d),3))[0],d=_[1],_=_[2],d=!1===s||l.x>=d?[new Oe(-i,-a/2),new Oe(0,0),new Oe(-i,a/2)]:[new Oe(_,-h/2),new Oe(d,-h/2),new Oe(d,-a/2),new Oe(0,0),new Oe(d,a/2),new Oe(d,h/2),new Oe(_,h/2)],_=[new Oe(_,h/2),new Oe(_,-h/2)],[h=d,h=0<o?Ir(i,a,o):h,_]),3))[0],T=_[1],_[2]),_=(O=Rr(Nr(x),3))[1],O=O[2];return[(k=Rr((A=("start"===x.align?(new Qe).translate(O,0):"tip"===x.align?new Qe:"mid"===x.align?(new Qe).translate(O/2,0):(new Qe).translate(_,0)).rotate(x.angle).translate(x.drawPosition).matrix(),[S.map((function(t){return t.transformBy(A)})),T.map((function(t){return t.transformBy(A)})),k.map((function(t){return t.transformBy(A)}))]),3))[0],[k[1]],k[2]]}function Hr(t,e){return"triangle"===e.head?3===(n=t).length?Dr(n):Dr([n[4],n[2],n[3],n[6],n[0],n[1],n[6],n[1],n[5]]):"reverseTriangle"===e.head?3===(n=t).length?Dr(n):9===n.length?Dr([n[0],n[1],n[2],n[0],n[2],n[8],n[8],n[2],n[3],n[8],n[3],n[7],n[6],n[4],n[5]]):Dr([n[0],n[1],n[2],n[0],n[2],n[5],n[2],n[3],n[4],n[5],n[2],n[4]]):"barb"===e.head?4===(r=t).length?Dr([r[0],r[1],r[2],r[0],r[2],r[3]]):Dr([r[0],r[1],r[5],r[0],r[5],r[6],r[2],r[3],r[1],r[5],r[1],r[3],r[5],r[3],r[4]]):"rectangle"===e.head||"bar"===e.head?4===(r=t).length?Dr([r[0],r[1],r[2],r[0],r[2],r[3]]):Dr([r[0],r[1],r[6],r[0],r[6],r[7],r[2],r[3],r[4],r[2],r[4],r[5]]):"polygon"===e.head||"circle"===e.head?function(t){for(var e=[],n=1;n<t.length;n+=1)e.push(t[0]),e.push(t[n-1]),e.push(t[n]);return e}(t):6===t.length?Dr([t[0]._dup(),t[1]._dup(),t[5]._dup(),t[5]._dup(),t[1]._dup(),t[4]._dup(),t[4]._dup(),t[1]._dup(),t[3]._dup(),t[3]._dup(),t[1]._dup(),t[2]._dup()]):7===t.length?Dr([t[3]._dup(),t[1]._dup(),t[2]._dup(),t[3]._dup(),t[4]._dup(),t[1]._dup(),t[0]._dup(),t[1]._dup(),t[6]._dup(),t[6]._dup(),t[1]._dup(),t[5]._dup(),t[5]._dup(),t[1]._dup(),t[4]._dup()]):Dr([t[0]._dup(),t[1]._dup(),t[8]._dup(),t[8]._dup(),t[1]._dup(),t[7]._dup(),t[7]._dup(),t[1]._dup(),t[4]._dup(),t[4]._dup(),t[1]._dup(),t[2]._dup(),t[3]._dup(),t[4]._dup(),t[2]._dup(),t[5]._dup(),t[7]._dup(),t[4]._dup(),t[6]._dup(),t[7]._dup(),t[5]._dup()]);var n,r}function Ur(t){var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y={align:"tip",tail:!1,angle:0,drawPosition:new Oe(0,0),scale:1};return"triangle"===t.head||null==t.head?ft({},y,t,(n=(e=t).length,r=e.width,i=e.tailWidth,e=null==(e=e.scale)?1:e,{width:r=null==r?null!=i?6*i*e:null!=n?n:1:r,length:n=null==n?r:n,tailWidth:i=null==i?r/6/e:i}),{head:"triangle"}):"polygon"===t.head||"circle"===t.head?ft({},y,t,(i=(s=t).radius,a=s.tailWidth,o=null==(o=s.scale)?1:o,{radius:i=null==i?null!=a?3*a*o:1:i,tailWidth:a=null==a?i/3/o:a,sides:s=null==(s=s.sides)?30:s})):"barb"===t.head?ft({},y,t,(a=(o=t).length,s=o.width,u=o.tailWidth,l=o.barb,o=null==(o=o.scale)?1:o,null==s&&(s=null!=u?6*u*o:null!=a?a:null!=l?6*l*o:1),null==u&&(u=s/6/o),{width:s,length:a=null==a?s:a,barb:l=null==l?u*o:l,tailWidth:u})):"reverseTriangle"===t.head?ft({},y,t,(l=(c=t).length,u=c.width,h=c.tailWidth,c=null==(c=c.scale)?1:c,{width:u=null==u?null!=h?6*h*c:null!=l?l:1:u,length:l=null==l?u:l,tailWidth:h=null==h?u/6/c:h})):"bar"===t.head?ft({},y,t,(c=(f=t).length,h=f.width,d=f.tailWidth,f=null==(f=f.scale)?1:f,{width:h=null==h?null!=d?6*d*f:null!=c?6*c:1:h,length:c=null==c?h/6:c,tailWidth:d=null==d?h/6/f:d})):"line"===t.head?ft({},y,t,(f=(p=t).length,d=p.width,m=p.tailWidth,p=null==(p=p.scale)?1:p,{width:d=null==d?null!=m?6*m*p:null!=f?f:1:d,length:f=null==f?d:f,tailWidth:m=null==m?d/6/p:m})):ft({},y,t,(m=(p=t).length,y=p.width,t=p.tailWidth,p=null==(p=p.scale)?1:p,{width:y=null==y?null!=t?6*t*p:null!=m?m:1:y,length:m=null==m?y:m,tailWidth:t=null==t?y/6/p:t}))}function Kr(t,e,n){var r=2<arguments.length&&void 0!==n&&n;if(null!=t){var i="string"==typeof t?{start:t,end:t}:t,o=ht({except:["end","start"]},{},i),a={};return t=function(t){var n;"string"==typeof i[t]&&(i[t]={head:i[t]}),0<Object.keys(o).length&&(null==i[t]?i[t]=ft({},o):i[t]=ft({},o,i[t])),(null!=i[t]||null==i.start&&null==i.end)&&(n={},null!=e&&(n.tailWidth=e),r&&(n.tail=!0),n=ht({except:["end","start"]},n,i[t]),a[t]=ft(Ur(n),n),a[t].drawPosition=Ae(a[t].drawPosition))},t("start"),t("end"),0<Object.keys(a).length?a:void 0}}function Vr(t){return function(t){if(Array.isArray(t))return Xr(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Yr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Yr(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yr(t,e){if(t){if("string"==typeof t)return Xr(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xr(t,e):void 0}}function Xr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function $r(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"line",r=3<arguments.length?arguments[3]:void 0,i=4<arguments.length?arguments[4]:void 0,o=[],a=[],s=[];t.forEach((function(n,l){var u,c=n[0],h=n.slice(-1)[0];if(e)for(var f=0;f<n.length;f+=1)o.push(n[f].p1._dup()),o.push(n[f].p2._dup());else o.push(h.p1._dup()),o.push(h.p2._dup()),o.push(c.p1._dup()),o.push(c.p1._dup()),o.push(h.p2._dup()),o.push(c.p2._dup());0!==l&&!a[a.length-1].isNotEqualTo(h.p1)||a.push(h.p1._dup()),(!1===i||l<t.length-1||l===t.length-1&&a[0].isNotEqualTo(h.p2))&&a.push(h.p2._dup()),0!==l&&!s[s.length-1].isNotEqualTo(c.p1)||s.push(c.p1._dup()),(!1===i||l<t.length-1||l===t.length-1&&s[0].isNotEqualTo(c.p2))&&s.push(c.p2._dup()),"fill"!==r&&"auto"!==r||(l<t.length-1?u=t[l+1]:i&&(u=Gr(t,1)[0]),null!=u&&(l=u[0],u=u.slice(-1)[0],e?(l.p1.isNotEqualTo(c.p2,10)&&(o.push(c.p2._dup()),o.push(l.p1._dup())),u.p1.isNotEqualTo(h.p2,10)&&(o.push(h.p2._dup()),o.push(u.p1._dup()))):(l.p1.isNotEqualTo(c.p2,10)&&(o.push(c.p2._dup()),o.push(h.p2._dup()),o.push(l.p1._dup())),u.p1.isNotEqualTo(h.p2,10)&&(o.push(h.p2._dup()),o.push(u.p1._dup()),o.push(c.p2._dup())))))}));var l=[[]];return"positive"===n?l=[a]:"negative"===n?l=[s]:"line"===n?l=!1===i?[[].concat(s,Vr(a.reverse()))]:[[].concat(s,[s[0],a[0]],Vr(a.reverse()))]:Array.isArray(n)&&(l=n),[o,l]}function Jr(t,e,n){var r=t.intersectsWith(e);!r.onLines&&"fill"===n||null==r.intersect||(t.setP2(r.intersect._dup()),e.setP1(r.intersect._dup()))}function Zr(t,e,n,r,i){e=Re(t.p1,t.p2,e.p2),t=new Ie({p1:t.p2,length:1,angle:t.angle()+e/2+Math.PI/2}),e=n.intersectsWith(t),t=r.intersectsWith(t),"fill"!==i&&(null!=e.intersect&&n.setP2(e.intersect),null!=t.intersect&&r.setP1(t.intersect))}function Qr(t,e,n,r,i){var o=(a=n.intersectsWith(r)).onLines,a=a.intersect;if(o&&null!=a)return n.setP2(a),r.setP1(a),0;i||(null!=(e=n.intersectsWith(e)).intersect&&e.onLines&&n.setP2(e.intersect),null!=(e=r.intersectsWith(t)).intersect&&e.onLines&&r.setP1(e.intersect))}function ti(t,e,n,r){var i=(o=n.intersectsWith(r)).onLines,o=o.intersect;if(i&&null!=o)return n.setP2(o),r.setP1(o),0;null!=(o=n.intersectsWith(e)).intersect&&e.hasPointOn(o.intersect,8)&&n.setP2(o.intersect),null!=(o=r.intersectsWith(t)).intersect&&t.hasPointOn(o.intersect,8)&&r.setP1(o.intersect)}function ei(t,e,n,r,i,o,a,s,l,u){e=1<arguments.length&&void 0!==e?e:.01,n=2<arguments.length?n:void 0,r=3<arguments.length?r:void 0;var c=4<arguments.length&&void 0!==i&&i,h=5<arguments.length?o:void 0,f=(a=6<arguments.length&&void 0!==a?a:Math.PI/7,7<arguments.length&&void 0!==s&&s),d=8<arguments.length&&void 0!==l?l:2,p=(u=9<arguments.length&&void 0!==u?u:"line",r=Gr(function(t,e,n,r,i,o,a){for(var s=6<arguments.length&&void 0!==a?a:2,l=[],u=function(t,e){return new Ie(t,e)},c=0;c<t.length-1;c+=1)l.push(u(t[c],t[c+1]));n&&1<t.length&&l.push(u(t[t.length-1],t[0]));for(var h=[],f="negative",d="positive",p=[],m=function(t,e,n,a,s){var l=a,u=a,c=Math.PI;null!=t&&(c=je(t.p1,e.p1,e.p2),f=Re(t.p1,e.p1,e.p2),h=e.distanceToPoint(t.p1),h=Math.min(h,Math.tan(Math.abs(f))*e.length()),c<Math.PI/2?l=Math.min(l,h):c>Math.PI/2*3&&(u=Math.min(u,h)));var h,f=Math.PI;null!=n&&(f=je(e.p1,e.p2,n.p2),h=Re(e.p1,e.p2,n.p2),n=e.distanceToPoint(n.p2),h=Math.min(n,Math.tan(Math.abs(h))*e.length()),f<Math.PI/2?l=Math.min(l,h):f>Math.PI/2*3&&(u=Math.min(u,h))),a="negative"===i?"auto"===r&&(o||c<Math.PI||f<Math.PI)?e.offset("negative",l):e.offset("negative",a):"positive"===i&&"auto"===r&&(o||c>Math.PI||f>Math.PI)?e.offset("positive",u):e.offset("positive",a),p[s].push(a)},y=e/(s-1),v=0;v<l.length;v+=1){var g,b=0<v?l[v-1]:null,w=l[v],x=v<l.length-1?l[v+1]:null;n&&0===v&&(b=l[l.length-1]),n&&v===l.length-1&&(x=l[0]),p.push([]),h.push([]),"negative"===i||"positive"===i||1===s?(p[v].push(w._dup()),h[v].push("mid")):(g="number"==typeof i?w.offset("negative",i*e):w.offset("negative",e/2),p[v].push(g),h[v].push(f));for(var S=1;S<s;S+=1)"negative"===i?(m(b,w,x,S*y,v),h[v].push(f)):"positive"===i?(m(b,w,x,S*y,v),h[v].push(d)):"number"==typeof i?(m(b,w,x,-i*e+S*y,v),h[v].push(0<-i*e+S*y?d:f)):(m(b,w,x,-e/2+S*y,v),h[v].push(0<-e/2+S*y?d:f));"negative"===i&&(p[v].reverse(),h[v].reverse())}return[l,p,h]}(t,e,c,h,n,r,d),3),r[0]),m=r[1],y=r[2],v="number"==typeof n?"mid":n;if(0===p.length)return[[],[]];function g(t,e,n){var r=p[t],i=p[e],o=m[t][n],a=m[e][n];e=je(r.p1,r.p2,i.p2),n=y[t][n],0<e&&e<b?"mid"===n?Zr(r,i,o,a,h):"negative"===n?Qr(r,i,o,a,f):"positive"===n&&Zr(r,i,o,a,h):b<=e&&e<=Math.PI/2?"mid"===n?Jr(o,a,h):"negative"===n?Qr(r,i,o,a,f):"positive"===n&&Jr(o,a,h):Math.PI/2<=e&&e<Math.PI?"mid"===n||"number"==typeof v?Jr(o,a,h):"negative"===n?ti(r,i,o,a):"positive"===n&&Jr(o,a,h):e===Math.PI?"negative"!==n&&"positive"!==n||Jr(o,a,h):Math.PI<e&&e<Math.PI/2*3?"mid"===n?(Jr(o,a,h),Jr(o,a,h)):"negative"===n?Jr(o,a,h):"positive"===n&&ti(r,i,o,a):Math.PI/2*3<=e&&e<=2*Math.PI-b?"mid"===n||"negative"===n?Jr(o,a,h):"positive"===n&&Qr(r,i,o,a,f):2*Math.PI-b<e&&e<2*Math.PI?"mid"===n||"negative"===n?Zr(r,i,o,a,h):"positive"===n&&Qr(r,i,o,a,f):Math.PI}var b=null==a?0:a;if("none"!==h)for(var w=0;w<d;w+=1){for(var x=0;x<m.length-1;x+=1)g(x,x+1,w);c&&g(m.length-1,0,w)}return u=(a=Gr($r(m,f,u,h,c),2))[0],a=a[1],[[].concat(Vr(u),[]),a]}function ni(t,e,n){var r=new Oe(-t.x,-t.y),i=(s=new Ie(n.p1.add(r),n.p2.add(r))).p1.x,o=s.p1.y,a=(u=s.p2.x)-i,s=(t=(l=s.p2.y)-o,Math.sqrt(a*a+t*t)),l=(i=i*l-u*o,e),u=(o=(i*t+(u=function(t){return t<0?-1:1})(t)*a*Math.sqrt(l*l*s*s-i*i))/(s*s),e=(i*t-u(t)*a*Math.sqrt(l*l*s*s-i*i))/(s*s),(-i*a+Math.abs(t)*Math.sqrt(l*l*s*s-i*i))/(s*s));return i=(-i*a-Math.abs(t)*Math.sqrt(l*l*s*s-i*i))/(s*s),s=[],isNaN(o)||isNaN(u)||(u=new Oe(o,u).sub(r),n.hasPointOn(u)&&s.push(u)),isNaN(e)||isNaN(i)||(r=new Oe(e,i).sub(r),n.hasPointOn(r)&&s.push(r)),s}function ri(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"mid",o=4<arguments.length?arguments[4]:void 0,a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:.1,s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:10,l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:Math.PI/7,u=8<arguments.length&&void 0!==arguments[8]?arguments[8]:[],c=9<arguments.length&&void 0!==arguments[9]&&arguments[9],h=10<arguments.length&&void 0!==arguments[10]?arguments[10]:2,f=11<arguments.length&&void 0!==arguments[11]?arguments[11]:"line",d=12<arguments.length&&void 0!==arguments[12]?arguments[12]:0,m=13<arguments.length&&void 0!==arguments[13]?arguments[13]:null,y=14<arguments.length&&void 0!==arguments[14]?arguments[14]:8,v=[],g=t,b=Kr(m,n,!0);!1===r&&null!=m&&(g=function(t,e){var n=e.start,r=e.end;if(e=[],null!=n){for(var i=t[0],o=0,a=Gr(Nr(n),2)[1],s=!1;o<t.length-1&&!1===s;)a<i.distance(t[o+=1])&&(s=!0);!s||null!=(n=Gr(ni(i,a,new Ie(t[o-1],t[o])),1)[0])&&(e=[n].concat(Vr(t.slice(o))))}else e=t;if(null!=r){for(var l=t[t.length-1],u=t.length-1,c=Gr(Nr(r),2)[1],h=!1;0<u&&!1===h;)c<l.distance(t[--u])&&(h=!0);!h||null!=(r=Gr(ni(l,c,new Ie(t[u+1],t[u])),1)[0])&&(e=[].concat(Vr(e.slice(0,u+1)),[r]))}return e}(t,b)),"auto"===o?(v=g.map((function(t){return t._dup()})),e="auto"):"radius"===o?(v=function(t,e,n,r,i){var o=[];e?o=Tr(t[t.length-1],t[0],t[1],r,n,i):o.push(t[0]);for(var a=1;a<t.length-1;a+=1){var s=Tr(t[a-1],t[a],t[a+1],r,n,i);o=[].concat(xr(o),xr(s))}return e?o=[].concat(xr(o),xr(Tr(t[t.length-2],t[t.length-1],t[0],r,n,i))):o.push(t[t.length-1]._dup()),o}(g,r,"fromVertex",s,a),e="fill"):(e=o,v=g.map((function(t){return t._dup()})));var w,x=function(t,e,n){if("mid"===n||"negative"===n||"positive"===n||"number"==typeof n)return n;for(var r=0,i=e?t.length:t.length-2,o=function(t,e,n){(n=je(t,e,n))<Math.PI&&(r+=1),n===Math.PI&&--i},a=1;a<t.length-1;a+=1)o(t[a-1],t[a],t[a+1]);return e&&(o(t[t.length-1],t[0],t[1]),o(t[t.length-2],t[t.length-1],t[0])),i/2<=r?"inside"===n?"negative":"positive":"inside"===n?"positive":"negative"}(v,r,i),S=[],T=!0;1<u.length&&(k=(A=Gr(function(t,e,n,r){var i=2<arguments.length&&void 0!==n&&n,o=3<arguments.length&&void 0!==r?r:8;n=e,r=0,e.length%2==1&&(n=e.slice(1),r=_r(e,1)[0]);for(var a,s=[],l=(a=[],n=(e=n).reduce((function(t,e){return a.push(t+e),t+e}),0),{definition:e,sum:n,cum:a}),u=r,c=!1,h=!0,f=function(t,e){var n=function(t,e,n,r,i){for(var o=4<arguments.length&&void 0!==i?i:8,a=[],s=0,l=(r=_r(Er(t,r,o),2))[0],u=(r=r[1],!0),c=new Ie(e,n),h=p(c.length(),o),f=p(r,o),d=l;s<h;){var m,y=l%2==0;u=y,y?(m=c.pointAtPercent(s/h),y=p(s+f,o)<=h?c.pointAtPercent((s+f)/h):n._dup(),s+=f,a.push([m,y])):s+=f,s=p(s,o),l=((d=l)+1)%t.definition.length,f=p(t.definition[l],o)}return{points:a,continues:h<s&&d%2==0,onLine:u}}(l,t,e,u,o);h=n.onLine;var r=n.points;n=n.continues,s=c&&null!=r[0]?(s[s.length-1]=[].concat(kr(s[s.length-1]),kr(r[0].slice(1))),[].concat(kr(s),kr(r.slice(1)))):[].concat(kr(s),kr(r)),c=n,u=p(u+t.distance(e),o)},d=0;d<t.length-1;d+=1)f(t[d],t[d+1]);return i&&(f(t[t.length-1],t[0]),r=_r(Er(l,r),1)[0],c&&r%2==0&&1<s.length&&(s[0]=[].concat(kr(s[s.length-1]),kr(s[0].slice(1))))),[s,h]}(v,u,r,y),2))[0],T=A[1],w=!1,1===k.length&&(w=r),k.forEach((function(t){t=Gr(ei(t,n,x,"inside"===i,w,e,l,c,h,f),1)[0],S=[].concat(Vr(S),Vr(t))})));var A,k,_,O=Gr(ei(v,n,x,"inside"===i,r,e,l,c,h,f),2);return s=O[0],o=a=O[1],"number"==typeof d&&0!==d&&(y=.5,A=n+2*d,y="positive"===x?d/A:"negative"===x?(d+n)/A:"mid"===x?.5:(d+x*n)/A,k=v,!(o=[])===r&&(O=new Ie(v[0],v[1]).pointAtLength(-d),_=(_=new Ie(v[v.length-2],v[v.length-1])).pointAtLength(_.length()+d),k=[O].concat(Vr(v.slice(1,-1)),[_])),_=f,Array.isArray(f)&&(_="line"),o=Gr(ei(k,A,y,"inside"===i,r,e,l,c,h,_),2)[1]),s=1<u.length?S:s,null!=m&&!1===r?oi(b,[g[0],t[0]],[g[g.length-1],t[t.length-1]],s,a,o,d,n,T):[s,a,o]}function ii(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=3<arguments.length?arguments[3]:void 0,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"mid",o=5<arguments.length?arguments[5]:void 0,a=6<arguments.length?arguments[6]:void 0,s=7<arguments.length?arguments[7]:void 0,l=8<arguments.length&&void 0!==arguments[8]?arguments[8]:Math.PI/7,u=9<arguments.length&&void 0!==arguments[9]&&arguments[9],c=10<arguments.length&&void 0!==arguments[10]?arguments[10]:1,h=11<arguments.length&&void 0!==arguments[11]?arguments[11]:0,f=(r=function(t,e,n){for(var r=3<arguments.length&&!1,i=[],o=1;o<t.length-1;o+=1)i.push(Ar(t[o-1],t[o],t[o+1],n,r));return e&&(i.push(Ar(t[t.length-2],t[t.length-1],t[0],n,r)),i.push(Ar(t[t.length-1],t[0],t[1],n,r))),i}(t,n,r,!1),[]),d=[],p=[],m="number"==typeof h?h:0;return r.forEach((function(t){var n=(r=Gr(ri(t,e,!1,i,o,a,s,l,[],u,c,"line",m),3))[0],r=(t=r[1],r[2]);f=[].concat(Vr(f),Vr(n)),d=[].concat(Vr(d),Vr(t)),p=[].concat(Vr(p),Vr(r))})),[f,d,p]}function oi(t,e,n,r,i,o,a,s,l){var u={},c=r,h=i;r=o,i=c.length,null!=(o=(u=null!=t?t:u).start)&&(t=new Ie(e[0],e[1]),e=new Ie(c[0],c[2]).midPoint(),t=(e=Gr(qr(ft({},o,{align:"tail",drawPosition:(f=[(t=new Ie({p1:e,length:t.length(),angle:t.angle()})).p1,t.p2])[0],angle:new Ie(f[0],f[1]).angle(),drawBorderBuffer:a,tailWidth:s})),3))[0],f=e[1],e=e[2],o=Hr(t,o),c=[].concat(Vr(c),Vr(o),[c[0]._dup(),c[2]._dup(),e[0]._dup(),e[0]._dup(),c[2]._dup(),e[1]._dup()]),h=[].concat(Vr(h),[t]),r=[].concat(Vr(r),[f[0]]));var f=u.end;return null!=f&&(u=i,i=new Ie(n[0],n[1]),n=new Ie(c[u-2],c[u-1]).midPoint(),n=(i=Gr(qr(ft({},f,{align:"tail",drawPosition:(n=[(i=new Ie({p1:n,length:i.length(),angle:i.angle()})).p1,i.p2])[0],angle:new Ie(n[0],n[1]).angle(),drawBorderBuffer:a,tailWidth:s})),3))[0],a=i[1],s=i[2],i=Hr(n,f),f=[],l&&(f=[c[u-2]._dup(),c[u-1]._dup(),s[0]._dup(),s[0]._dup(),c[u-1]._dup(),s[1]._dup()]),c=[].concat(Vr(c),Vr(i),Vr(f)),h=[].concat(Vr(h),[n]),r=[].concat(Vr(r),[a[0]])),[c,h,r]}function ai(t,e,n){for(var r,i,o=n?4*t.length+2:4*(t.length-1),a=Array(o),s=e/2,l=Math.PI/2,u=function(e,n){var r=t[e],i=t[n],o=Math.atan2(i.y-r.y,i.x-r.x),a=s*Math.cos(o-l);return e=s*Math.cos(o+l),n=s*Math.sin(o-l),o=s*Math.sin(o+l),[new Oe(r.x+a,r.y+n),new Oe(r.x+e,r.y+o),new Oe(i.x+a,i.y+n),new Oe(i.x+e,i.y+o)]},c=0;c<t.length-1;c+=1){var h=(p=Gr(u(c,c+1),4))[0],f=p[1],d=p[2],p=p[3];a[4*c]=h,a[4*c+1]=f,a[4*c+2]=d,a[4*c+3]=p}return n&&(r=(i=Gr(u(t.length-1,0),4))[0],e=i[1],n=i[2],i=i[3],a[o-6]=r,a[o-5]=e,a[o-4]=n,a[o-3]=i,a[o-2]=a[0]._dup(),a[o-1]=a[1]._dup()),[a,[[]],[[]],[[]]]}function si(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||ui(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function li(t){return function(t){if(Array.isArray(t))return ci(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||ui(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ui(t,e){if(t){if("string"==typeof t)return ci(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ci(t,e):void 0}}function ci(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function hi(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01;return[(t=Ae(t)).x-e/2,t.y-e/2,t.x+e/2,t.y-e/2,t.x+e/2,t.y+e/2,t.x-e/2,t.y-e/2,t.x+e/2,t.y+e/2,t.x-e/2,t.y+e/2]}function fi(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.01,n=Ae(t);return t=2*Math.PI/6,[(n=[[e+n.x,n.y],[e*Math.cos(t)+n.x,e*Math.sin(t)+n.y],[e*Math.cos(2*t)+n.x,e*Math.sin(2*t)+n.y],[e*Math.cos(3*t)+n.x,e*Math.sin(3*t)+n.y],[e*Math.cos(4*t)+n.x,e*Math.sin(4*t)+n.y],[e*Math.cos(5*t)+n.x,e*Math.sin(5*t)+n.y]])[0][0],n[0][1],n[1][0],n[1][1],n[2][0],n[2][1],n[0][0],n[0][1],n[2][0],n[2][1],n[3][0],n[3][1],n[0][0],n[0][1],n[3][0],n[3][1],n[4][0],n[4][1],n[0][0],n[0][1],n[4][0],n[4][1],n[5][0],n[5][1]]}function di(t){return"number"==typeof t&&2<t?4===t?hi.bind(this):6===t?fi.bind(this):function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.01,r=Ae(e),i=2*Math.PI/t,o=[],a=0;a<t;a+=1)o.push([n*Math.cos(i*a)+r.x,n*Math.sin(i*a)+r.y]);for(var s=[],l=1;l<t-1;l+=1)s.push.apply(s,[o[0][0],o[0][1],o[l][0],o[l][1],o[l+1][0],o[l+1][1]]);return s}.bind(this,t):"hex"===t?fi.bind(this):"function"==typeof t?t:hi.bind(this)}var pi=function(t,e){for(var n=[],r=0;r<e;r+=1)n.push.apply(n,li(t));return n};function mi(t,e,n,r){for(var i=[],o=[],a=[e,n],s=[0,0],l=0;l<n;l+=1)for(var u=0;u<e;u+=1){var c=l*e*4+4*u;r(c=[t[c]/255,t[1+c]/255,t[2+c]/255,t[3+c]/255],[u,l])&&(i.push([u,l]),o.push(c),a[0]=u<a[0]?u:a[0],a[1]=l<a[1]?l:a[1],s[0]=u>s[0]?u:s[0],s[1]=l>s[1]?l:s[1])}return{max:s,min:a,pixels:i,pixelColors:o}}function yi(t,e,n){for(var r=1<arguments.length&&void 0!==e?e:null,i=t,o=(n=si(function(t,e){for(var n=i,r=0,o=Array(n.length).fill(0),a=Array(n.length).fill(0),s=1;s<n.length;s+=1){var l=[n[s].x,n[s].y],u=[n[s-1].x,n[s-1].y];r+=u=Math.sqrt(Math.pow(l[0]-u[0],2)+Math.pow(l[1]-u[1],2)),o[s]=u,a[s]=r}return e&&(t=[n[0].x,n[0].y],e=[n[n.length-1].x,n[n.length-1].y],r+=e=Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)),o[0]=e,a[0]=r),[r,a,o]}(0,e=2<arguments.length&&void 0!==n&&n),3),t=n[0],n[1]),a=n[2],s=i.length,l=t/((s=null!=r?r:s)-1),u=[],c=1,h=0,f=0;f<s-1;f+=1){var d=f*l,p=void 0;if(0===f)p=new Oe(i[f].x,i[f].y);else{for(;o[c]<d&&0<c;)c===i.length-1?c=0:c+=1,h+=1;var m=1-(o[c]-d)/a[c],y=i[h],v=i[c];p=new Oe((v.x-y.x)*m+y.x,(v.y-y.y)*m+y.y)}u.push(p)}return e||u.push(i[i.length-1]._dup()),[u,t,l]}function vi(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||wi(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gi(t){return(gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function bi(t){return function(t){if(Array.isArray(t))return xi(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||wi(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wi(t,e){if(t){if("string"==typeof t)return xi(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xi(t,e):void 0}}function xi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Si={simple:{src:"\nattribute vec4 a_vertex; \nuniform mat4 u_worldViewProjectionMatrix;\nvoid main() {\n gl_Position = u_worldViewProjectionMatrix * a_vertex;\n}",vars:["a_vertex","u_worldViewProjectionMatrix"]},selector:{src:"\nattribute vec4 a_vertex; \nuniform mat4 u_worldViewProjectionMatrix;\nvoid main() {\n gl_Position = u_worldViewProjectionMatrix * a_vertex;\n}",vars:["a_vertex","u_worldViewProjectionMatrix"]},noLight:{src:"attribute vec3 a_vertex;uniform mat4 u_worldMatrix;uniform mat4 u_projectionMatrix;uniform mat4 u_viewMatrix;void main() {gl_Position = u_projectionMatrix * u_viewMatrix * u_worldMatrix * vec4(a_vertex.xyz, 1);}",vars:["a_vertex","u_worldMatrix","u_projectionMatrix","u_viewMatrix"]},pointLight:{src:"\nattribute vec4 a_vertex;\nattribute vec3 a_normal;\nvarying vec3 v_normal;\nuniform vec3 u_lightWorldPosition;\nuniform mat4 u_worldMatrix;\nuniform mat4 u_worldViewProjectionMatrix;\nuniform mat4 u_worldInverseTranspose;\nvarying vec3 v_vertexToLight;\nvoid main() {\n gl_Position = u_worldViewProjectionMatrix * a_vertex;\n v_normal = mat3(u_worldInverseTranspose) * a_normal;\n vec3 vertexWorldPosition = (u_worldMatrix * a_vertex).xyz;\n v_vertexToLight = u_lightWorldPosition - vertexWorldPosition;\n}",vars:["a_vertex","a_normal","u_worldViewProjectionMatrix","u_worldInverseTranspose","u_lightWorldPosition","u_worldMatrix"]},directionalLight:{src:"\nattribute vec4 a_vertex;\nattribute vec3 a_normal;\nvarying vec3 v_normal;\nuniform mat4 u_worldViewProjectionMatrix;\nuniform mat4 u_worldInverseTranspose;\nvoid main() {\n gl_Position = u_worldViewProjectionMatrix * a_vertex;\n v_normal = mat3(u_worldInverseTranspose) * a_normal;\n}",vars:["a_vertex","a_normal","u_worldViewProjectionMatrix","u_worldInverseTranspose"]},vertexColor:{src:"\nattribute vec2 a_vertex;\nattribute vec4 a_color;\nvarying vec4 v_color;\nuniform mat4 u_worldMatrix;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_viewMatrix;\nuniform float u_z;\nvoid main() {\n gl_Position = u_projectionMatrix * u_viewMatrix * u_worldMatrix * vec4(a_vertex.xy, u_z, 1);\n v_color = a_color;\n}",vars:["a_vertex","a_color","u_worldMatrix","u_z","u_projectionMatrix","u_viewMatrix"]},vertexColor3D:{src:"\nattribute vec3 a_vertex;\nattribute vec4 a_color;\nvarying vec4 v_color;\nuniform mat4 u_worldMatrix;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_viewMatrix;\nvoid main() {\n gl_Position = u_projectionMatrix * u_viewMatrix * u_worldMatrix * vec4(a_vertex.xyz, 1);\n v_color = a_color;\n}",vars:["a_vertex","a_color","u_worldMatrix","u_projectionMatrix","u_viewMatrix"]},withTexture:{src:"attribute vec2 a_vertex;attribute vec2 a_texcoord;uniform mat4 u_worldMatrix;uniform mat4 u_projectionMatrix;uniform mat4 u_viewMatrix;uniform float u_z;varying vec2 v_texcoord;void main() {gl_Position = u_projectionMatrix * u_viewMatrix * u_worldMatrix * vec4(a_vertex.xy, u_z, 1);v_texcoord = a_texcoord;}",vars:["a_vertex","a_texcoord","u_worldMatrix","u_z","u_projectionMatrix","u_viewMatrix"]},morph4:{src:"\nattribute vec2 a_pos0;\nattribute vec2 a_pos1;\nattribute vec2 a_pos2;\nattribute vec2 a_pos3;\nuniform mat4 u_worldMatrix;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_viewMatrix;\nuniform float u_percent;\nuniform int u_from;\nuniform int u_to;\n\nvoid main() {\n vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[4];\n\n positions[0] = a_pos0;\n positions[1] = a_pos1;\n positions[2] = a_pos2;\n positions[3] = a_pos3;\n\n for (int i = 0; i < 4; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n break;\n }\n }\n for (int i = 0; i < 4; i++) {\n if (u_to == i) {\n toPos = positions[i];\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = u_worldMatrix * vec4(newPosition.xy, u_z, 1);\n}\n",vars:["a_pos0","a_pos1","a_pos2","a_pos3","u_worldMatrix","u_percent","u_from","u_to"]},morpher:function(t,e){var n="",r="vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[".concat(t,"];\n"),i="",o="",a=["u_worldMatrix","u_percent","u_projectionMatrix","u_viewMatrix"];e&&(o="vec4 fromCol = a_col0;\n vec4 toCol = a_col1;\n vec4 colors[".concat(t,"];"));for(var s=0;s<t;s+=1)a.push("a_pos".concat(s)),n="".concat(n,"attribute vec2 a_pos").concat(s,";\n"),r="".concat(r," positions[").concat(s,"] = a_pos").concat(s,";\n"),e&&(i="".concat(i,"attribute vec4 a_col").concat(s,";\n"),o="".concat(o," colors[").concat(s,"] = a_col").concat(s,";\n"),a.push("a_col".concat(s)));a.push("u_to"),a.push("u_from");var l="",u="",c="";return e&&(i="".concat(i,"varying vec4 v_color;\n"),l="toCol = colors[i];\n",u="fromCol = colors[i];\n",c="v_color = (toCol - fromCol) * u_percent + fromCol;\n"),{src:"\n".concat(n,"\n").concat(i,"\nuniform mat4 u_worldMatrix;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_viewMatrix;\nuniform float u_percent;\n").concat("uniform int u_from;\nuniform int u_to;\n","\n\nvoid main() {\n ").concat(r,"\n ").concat(o,"\n\n for (int i = 0; i < ").concat(t,"; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n ").concat(u,"\n break;\n }\n }\n for (int i = 0; i < ").concat(t,"; i++) {\n if (u_to == i) {\n toPos = positions[i];\n ").concat(l,"\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = u_projectionMatrix * u_viewMatrix * u_worldMatrix * vec4(newPosition.xy, 0, 1);\n ").concat(c,"\n}\n"),vars:a}},morph4VertexColor:{src:"\nattribute vec2 a_pos0;\nattribute vec2 a_pos1;\nattribute vec2 a_pos2;\nattribute vec2 a_pos3;\nattribute vec4 a_col0;\nattribute vec4 a_col1;\nattribute vec4 a_col2;\nattribute vec4 a_col3;\nuniform mat3 u_worldMatrix;\nuniform float u_percent;\nuniform int u_from;\nuniform int u_to;\nvarying vec4 v_color;\n\nvoid main() {\n vec2 fromPos = a_pos0;\n vec2 toPos = a_pos1;\n vec2 positions[4];\n positions[0] = a_pos0;\n positions[1] = a_pos1;\n positions[2] = a_pos2;\n positions[3] = a_pos3;\n\n vec4 fromCol = a_col0;\n vec4 toCol = a_col1;\n vec4 colors[4];\n colors[0] = a_col0;\n colors[1] = a_col1;\n colors[2] = a_col2;\n colors[3] = a_col3;\n\n for (int i = 0; i < 4; i++) {\n if (u_from == i) {\n fromPos = positions[i];\n fromCol = colors[i];\n break;\n }\n }\n for (int i = 0; i < 4; i++) {\n if (u_to == i) {\n toPos = positions[i];\n toCol = colors[i];\n break;\n }\n }\n\n vec2 newPosition = (toPos - fromPos) * u_percent + fromPos;\n gl_Position = u_worldMatrix * vec4(newPosition.xy, u_z, 1);\n v_color = (toCol - fromCol) * u_percent + fromCol;\n}\n",vars:["a_pos0","a_pos1","a_pos2","a_pos3","a_col0","a_col1","a_col2","a_col3","u_worldMatrix","u_percent","u_from","u_to"]}},Ti={simple:{src:"precision mediump float;uniform vec4 u_color;void main() {gl_FragColor = u_color;gl_FragColor.rgb *= gl_FragColor.a;}",vars:["u_color"]},directionalLight:{src:"\nprecision mediump float;\nuniform vec4 u_color;\nvarying vec3 v_normal;\nuniform vec3 u_directionalLight;\nuniform float u_ambientLight;\nvoid main() {\n vec3 normal = normalize(v_normal);\n float light = dot(normal, u_directionalLight);\n gl_FragColor = u_color;\n gl_FragColor.rgb *= gl_FragColor.a;\n gl_FragColor.rgb *= max((light + 1.0) / 2.0, u_ambientLight);\n}",vars:["u_color","u_directionalLight","u_ambientLight"]},pointLight:{src:"\nprecision mediump float;\nuniform vec4 u_color;\nvarying vec3 v_normal;\nvarying vec3 v_vertexToLight;\nuniform float u_ambientLight;\nvoid main() {\n vec3 normal = normalize(v_normal);\n vec3 surfaceToLightDirection = normalize(v_vertexToLight);\n float light = dot(normal, surfaceToLightDirection);\n gl_FragColor = u_color;\n gl_FragColor.rgb *= gl_FragColor.a;\n // gl_FragColor.rgb *= max((light + 1.0) / 2.0, u_ambientLight);\n gl_FragColor.rgb *= max((light + 1.0) / 2.0, u_ambientLight);\n}",vars:["u_color","u_ambientLight"]},selector:{src:"\nprecision mediump float;\nuniform vec4 u_color;\nvoid main() {\n gl_FragColor = u_color;\n}",vars:["u_color"]},vertexColor:{src:"precision mediump float;uniform vec4 u_color;varying vec4 v_color;void main() {gl_FragColor = v_color;gl_FragColor.rgb *= gl_FragColor.a;}",vars:["u_color"]},withTexture:{src:"precision mediump float;uniform vec4 u_color;uniform int u_use_texture;uniform sampler2D u_texture;varying vec2 v_texcoord;void main() {if ( u_use_texture == 1) {gl_FragColor = texture2D(u_texture, v_texcoord) * u_color.a;} else {gl_FragColor = u_color;gl_FragColor.rgb *= gl_FragColor.a;}}",vars:["u_color","u_use_texture","u_texture"]},text:{src:"precision mediump float;uniform vec4 u_color;uniform sampler2D u_texture;varying vec2 v_texcoord;void main() {vec4 c = texture2D(u_texture, v_texcoord);gl_FragColor = vec4(c.a * u_color.rgb, c.a * u_color.a);}",vars:["u_color","u_texture"]}},Ai=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);var n=(this.webgl=e).gl;this.target=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.target),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),this.depthBuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,this.depthBuffer),e=n.createFramebuffer(),n.bindFramebuffer(n.FRAMEBUFFER,e),e=n.COLOR_ATTACHMENT0,n.framebufferTexture2D(n.FRAMEBUFFER,e,n.TEXTURE_2D,this.target,0),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,this.depthBuffer)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,[{key:"setFramebufferAttachmentSizes",value:function(t,e){var n=this.webgl.gl;n.bindTexture(n.TEXTURE_2D,this.target);var r=n.RGBA,i=n.RGBA,o=n.UNSIGNED_BYTE;n.texImage2D(n.TEXTURE_2D,0,r,t,e,0,i,o,null),n.bindRenderbuffer(n.RENDERBUFFER,this.depthBuffer),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,t,e)}}]),t}(),ki={TRIANGLES:1,TRIANGLE_STRIP:2,TRIANGLE_FAN:3,LINES:4,LINK_STATUS:1,VERTEX_SHADER:1,COMPILE_STATUS:1,FRAGMENT_SHADER:1,SRC_ALPHA:1,ONE_MINUS_SRC_ALPHA:1,BLEND:1,COLOR_BUFFER_BIT:1,TEXTURE_2D:1,RGBA:1,UNSIGNED_BYTE:1,TEXTURE_WRAP_S:1,CLAMP_TO_EDGE:1,TEXTURE_WRAP_T:1,TEXTURE_MIN_FILTER:1,LINEAR:1,ARRAY_BUFFER:1,STATIC_DRAW:1,FLOAT:1,UNPACK_PREMULTIPLY_ALPHA_WEBGL:1,createBuffer:function(){},bindBuffer:function(){},bufferData:function(){},enableVertexAttribArray:function(){},vertexAttribPointer:function(){},disableVertexAttribArray:function(){},uniformMatrix3fv:function(){},uniform4f:function(){},uniform1f:function(){},uniform1i:function(){},texParameteri:function(){},drawArrays:function(){},clearColor:function(){},clear:function(){},createTexture:function(){},activeTexture:function(){},bindTexture:function(){},pixelStorei:function(){},texImage2D:function(){},blendFunc:function(){},attachShader:function(){},linkProgram:function(){},getProgramParameter:function(){},createProgram:function(){},deleteProgram:function(){},createShader:function(){},shaderSource:function(){},compileShader:function(){},getShaderParameter:function(){},getAttribLocation:function(){},getUniformLocation:function(){},enable:function(){},map:function(){},getExtension:function(){return{loseContext:function(){}}},disable:function(){},deleteShader:function(){},useProgram:function(){},viewport:function(){},canvas:{toDataURL:function(){return""},width:100,clientHeight:100,height:100,style:{top:0,visibility:"visible"}}};function _i(t,e,n){if(e=t.createShader(e),t.shaderSource(e,n),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS))return e;throw new Error("Could not compile shader: ".concat(n))}const Oi=function(){function t(e,n){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),null==(e=e.getContext("webgl",{antialias:!0}))&&(e=ki),this.programs=[],this.lastUsedProgram=null,this.textures={},null!=e&&(this.gl=e,this.resize(),this.gl.disable(this.gl.DEPTH_TEST),this.gl.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),this.gl.enable(e.BLEND),this.targetTexture=new Ai(this))}var e=[{key:"addTexture",value:function(t,e,n){if(this.textures[t]&&null!=this.textures[t].glTexture)return this.textures[t].index;var r=this.textures[t]?this.textures[t].index:Object.keys(this.textures).length;return this.textures[t]={glTexture:e,index:r,type:n,state:"loaded",onLoad:[]},r}},{key:"onLoad",value:function(t){this.textures[t].onLoad.forEach((function(t){return t()})),this.textures[t].onLoad=[]}},{key:"getProgram",value:function(t,e){for(var n=Wt((u=function(t,e){var n=0<arguments.length&&void 0!==t?t:"simple",r=1<arguments.length&&void 0!==e?e:"simple",i="";if(t="",e=[],"string"==typeof n){if(null==Si[n])throw new Error("Built in vertex shader does not exist: ".concat(n));i=Si[n].src,e.push.apply(e,bi(Si[n].vars))}else if(Array.isArray(n)&&"string"==typeof n[0]){var o=Si[n[0]].apply(Si,bi(n.slice(1)));i=o.src,e.push.apply(e,bi(o.vars))}else if(Array.isArray(n)||null==n.src){if("object"!==gi(n))throw new Error("Vertex shader definition incorrect: ".concat(n));i=(o=vi(function(t){var e=(i=ft({dimension:2,color:"uniform",light:null},0<arguments.length&&void 0!==t?t:{})).dimension,n=i.light,r=i.color,i=(t="\nuniform mat4 u_worldViewProjectionMatrix;\n",["u_worldViewProjectionMatrix"]);return 2===e?(t+="attribute vec2 a_vertex;\n",t+="uniform float u_z;\n",i.push("a_vertex","u_z")):3===e&&(t+="attribute vec4 a_vertex;\n",i.push("a_vertex")),"texture"===r?(t+="attribute vec2 a_texcoord;\n",t+="varying vec2 v_texcoord;\n",i.push("a_texcoord")):"vertex"===r&&(t+="attribute vec4 a_color;\n",t+="varying vec4 v_color;\n",i.push("a_color")),null!=n&&"ambient"!==n&&(t+="attribute vec3 a_normal;\n",t+="varying vec3 v_normal;\n",t+="uniform mat4 u_worldInverseTranspose;\n",i.push("u_worldInverseTranspose","a_normal")),"point"===n&&(t+="uniform vec3 u_lightWorldPosition;\n",t+="uniform mat4 u_worldMatrix;\n",t+="varying vec3 v_vertexToLight;\n",i.push("u_lightWorldPosition","u_worldMatrix")),t+="void main() {\n",t+=2===e?" gl_Position = u_worldViewProjectionMatrix * vec4(a_vertex.xy, u_z, 1);\n":" gl_Position = u_worldViewProjectionMatrix * a_vertex;\n","texture"===r?t+=" v_texcoord = a_texcoord;\n":"vertex"===r&&(t+=" v_color = a_color;\n"),null!=n&&"ambient"!==n&&(t+=" v_normal = mat3(u_worldInverseTranspose) * a_normal;\n"),"point"===n&&(t+=" vec3 vertexWorldPosition = (u_worldMatrix * a_vertex).xyz;\n",t+=" v_vertexToLight = u_lightWorldPosition - vertexWorldPosition;\n"),[t+="}\n",i]}(n),2))[0],e=o[1]}else i=n.src,e.push.apply(e,bi(n.vars||[]));if("string"==typeof r){if(null==Ti[r])throw new Error("Built in fragment shader does not exist: ".concat(r));t=Ti[r].src,e.push.apply(e,bi(Ti[r].vars))}else if(Array.isArray(r)&&"string"==typeof r[0]){var a;t=(a=Si[r[0]].apply(Si,bi(r.slice(1)))).src,e.push.apply(e,bi(a.vars))}else if(Array.isArray(r)||null==r.src||"string"!=typeof r.src){if("object"!==gi(r))throw new Error("Fragment shader definition incorrect: ".concat(r));t=(a=vi(function(t){var e=ft({color:"uniform",light:null},0<arguments.length&&void 0!==t?t:{}),n=e.light,r=e.color;return t="\nprecision mediump float;\n",t+="uniform vec4 u_color;\n",e=["u_color"],"vertex"===r?(t+="varying vec4 v_color;\n",e.push("v_color")):"texture"===r&&(t+="uniform sampler2D u_texture;\n",t+="varying vec2 v_texcoord;\n",e.push("u_texture")),"directional"===n?(t+="varying vec3 v_normal;\n",t+="uniform vec3 u_directionalLight;\n",t+="uniform float u_ambientLight;\n",e.push("u_ambientLight","u_directionalLight")):"point"===n?(t+="varying vec3 v_normal;\n",t+="varying vec3 v_vertexToLight;\n",t+="uniform float u_ambientLight;\n",e.push("u_ambientLight")):"ambient"===n&&(t+="uniform float u_ambientLight;\n",e.push("u_ambientLight")),t+="void main() {\n","vertex"===r?(t+=" gl_FragColor = v_color;\n",t+=" gl_FragColor.a *= u_color.a;\n",t+=" gl_FragColor.rgb *= gl_FragColor.a;\n"):"uniform"===r?(t+=" gl_FragColor = u_color;\n",t+=" gl_FragColor.rgb *= gl_FragColor.a;\n"):"texture"===r&&(t+=" gl_FragColor = texture2D(u_texture, v_texcoord) * u_color.a;\n"),"directional"===n?(t+=" vec3 normal = normalize(v_normal);\n",t+=" float light = dot(normal, u_directionalLight);\n",t+=" gl_FragColor.rgb *= max((light + 1.0) / 2.0, u_ambientLight);\n"):"point"===n?(t+=" vec3 normal = normalize(v_normal);\n",t+=" vec3 surfaceToLightDirection = normalize(v_vertexToLight);\n",t+=" float light = dot(normal, surfaceToLightDirection);\n",t+=" gl_FragColor.rgb *= max((light + 1.0) / 2.0, u_ambientLight);\n"):"ambient"===n&&(t+=" gl_FragColor.rgb *= u_ambientLight;\n"),[t+="}\n",e]}(r),2))[0],a=a[1],e.push.apply(e,bi(a))}else t=r.src,e.push.apply(e,bi(r.vars||[]));return{vertexSource:i,fragmentSource:t,vars:e}}(t,e)).vertexSource),r=Wt(u.fragmentSource),i=0;i<this.programs.length;i+=1){var o=this.programs[i];if(o.vertexShader.hash===n&&o.fragmentShader.hash===r)return i}var a,s,l=(a=this.gl,s=u.vertexSource,l=u.fragmentSource,s=_i(a,a.VERTEX_SHADER,s),l=_i(a,a.FRAGMENT_SHADER,l),s&&l?function(t,e,n){var r=t.createProgram();if(t.attachShader(r,e),t.attachShader(r,n),t.linkProgram(r),t.getProgramParameter(r,t.LINK_STATUS))return r;throw r=t.getProgramInfoLog(r),new Error("Could not compile WebGL program. \n\n ".concat(r||""))}(a,s,l):null),u={vertexShader:{src:u.vertexSource,hash:Wt(u.vertexSource),def:t},fragmentShader:{src:u.fragmentSource,hash:Wt(u.fragmentSource),def:e},vars:u.vars,program:l,locations:function(t,e,n){for(var r,i={},o=0;o<n.length;o+=1)"a"===(r=n[o])[0]&&(i[r]=t.getAttribLocation(e,r)),"u"===r[0]&&(i[r]=t.getUniformLocation(e,r));return i}(this.gl,l,u.vars)};return this.programs.push(u),this.programs.length-1}},{key:"useProgram",value:function(t){return t=this.programs[t],this.lastUsedProgram!==t.program&&(this.gl.useProgram(t.program),this.lastUsedProgram=t.program),t.locations}},{key:"resize",value:function(){var t=window.devicePixelRatio,e=Math.floor(this.gl.canvas.clientWidth*t);t=Math.floor(this.gl.canvas.clientHeight*t),this.gl.canvas.width===e&&this.gl.canvas.height===t||(this.gl.canvas.width=e,this.gl.canvas.height=t),this.gl.viewport(0,0,this.gl.drawingBufferWidth,this.gl.drawingBufferHeight),null!=this.targetTexture&&this.targetTexture.setFramebufferAttachmentSizes(this.gl.canvas.width,this.gl.canvas.height)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();var Pi=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);var r=this.defaultOptions();ft(this,r,e),this.calcProjectionMatrix(),this.calcViewMatrix(),this.calcViewProjectionMatrix(),this.onUpdate=n}var e=[{key:"defaultOptions",value:function(){return{style:"2D",left:-1,right:1,bottom:-1,top:1,near:.1,far:10,camera:{position:[0,0,2],lookAt:[0,0,0],up:[0,1,0]},aspectRatio:1,fieldOfView:1,light:{directional:[1,1,1],ambient:.4,point:[10,10,10]}}}},{key:"reset",value:function(t){ft(this,this.defaultOptions(),t),this.calcProjectionMatrix(),this.calcViewMatrix(),this.calcViewProjectionMatrix()}},{key:"calcProjectionMatrix",value:function(){var t,e,n,r,i,o;"orthographic"!==this.style&&"2D"!==this.style?(n=this.fieldOfView,r=this.aspectRatio,i=this.near,o=this.far,this.projectionMatrix=de(n,r,i,o)):(t=this.left,e=this.right,n=this.near,r=this.far,i=this.bottom,o=this.top,this.projectionMatrix=fe(t,e,i,o,n,r))}},{key:"calcViewMatrix",value:function(){this.cameraMatrix=pe(Ae(this.camera.position).toArray(),Ae(this.camera.lookAt).toArray(),Ae(this.camera.up).toArray()),this.viewMatrix=be(this.cameraMatrix),this.cameraPosition=Ae(this.camera.position),this.cameraVector=Ae(this.camera.lookAt).sub(this.cameraPosition).normalize()}},{key:"calcViewProjectionMatrix",value:function(){this.viewProjectionMatrix=Jt(this.projectionMatrix,this.viewMatrix),this.inverseViewProjectionMatrix=be(this.viewProjectionMatrix),null!=this.onUpdate&&this.onUpdate(),"2D"===this.style&&(this.viewProjectionMatrix[11]=0),this.rightVector=this.cameraVector.crossProduct(Ae(this.camera.up)).normalize(),this.upVector=this.rightVector.crossProduct(this.cameraVector).normalize(),"perspective"===this.style?(this.heightNear=Math.tan(.5*this.fieldOfView)*this.near*2,this.heightFar=Math.tan(.5*this.fieldOfView)*this.far*2,this.widthNear=this.aspectRatio*this.heightNear,this.widthFar=this.aspectRatio*this.heightFar,this.nearCenter=this.cameraPosition.add(this.cameraVector.scale(this.near)),this.farCenter=this.cameraPosition.add(this.cameraVector.scale(this.far))):(this.heightNear=this.top-this.bottom,this.widthNear=this.right-this.left,this.heightFar=this.heightNear,this.widthFar=this.widthNear,this.nearCenter=this.cameraPosition.add(this.cameraVector.scale(this.near)).add(this.rightVector.scale(this.left+this.widthNear/2)).add(this.upVector.scale(this.bottom+this.heightNear/2)),this.farCenter=this.cameraPosition.add(this.cameraVector.scale(this.far)).add(this.rightVector.scale(this.left+this.widthFar/2)).add(this.upVector.scale(this.bottom+this.heightFar/2))),this.nearPlane=new He(this.nearCenter,this.cameraVector),this.farPlane=new He(this.farCenter,this.cameraVector)}},{key:"dupMatrix",value:function(t){return t.slice()}},{key:"setCamera",value:function(t){ft(this.camera,t),this.calcViewMatrix(),this.calcViewProjectionMatrix()}},{key:"setProjection",value:function(t){ft(this,t),this.calcProjectionMatrix(),this.calcViewProjectionMatrix()}},{key:"set2D",value:function(t){ft(this,{style:"2D"},t),this.calcProjectionMatrix(),this.calcViewProjectionMatrix()}},{key:"setOrthographic",value:function(t){ft(this,{style:"orthographic"},t),this.calcProjectionMatrix(),this.calcViewProjectionMatrix()}},{key:"setPerspective",value:function(t){ft(this,{style:"perspective"},t),this.calcProjectionMatrix(),this.calcViewProjectionMatrix()}},{key:"setLight",value:function(t){ft(this.light,t)}},{key:"figureToGL",value:function(t){var e=Ae(t);return"2D"===this.style||"orthographic"===this.style?Ae(t).transformBy(this.viewProjectionMatrix):(e=he(this.viewProjectionMatrix,[e.x,e.y,e.z,1]),new Oe(e[0]/e[3],e[1]/e[3],e[2]/e[3]))}},{key:"glToFigure",value:function(t){var e=Ae(t);if("2D"===this.style||"orthographic"===this.style)return Ae(e).transformBy(this.inverseViewProjectionMatrix);var n=this.projectionMatrix[0],r=this.projectionMatrix[5];return t=this.projectionMatrix[10],t=-this.projectionMatrix[11]/(e.z+t),n=-e.x*t/n,r=-e.y*t/r,new Oe(n,r,t).transformBy(this.cameraMatrix)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Ei(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Mi(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mi(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ci(t,e,n){var r=ft({},{precision:5,ignoreShown:!1,min:!1},n),i=r.precision,o={};return e.forEach((function(e){var n,a=function t(e,n,r){var i=Ei(r,1)[0];return 1===r.length?[e,n,r[0]]:(null==e[i]&&(e[i]={}),null==n[i]?null:t(e[i],n[i],r.slice(1)))}(o,t,e.split("."));null!=a&&(e=(n=Ei(a,3))[0],a=n[1],e[n=n[2]]=function t(e){if("string"==typeof e)return e;if("number"==typeof e)return e;if("boolean"==typeof e)return e;if("function"!=typeof e){if(null==e)return e;if(null!=e._def)return e._def(i);if(null!=e._state)return e._state(r);if(Array.isArray(e)){var n=[];return e.forEach((function(e){n.push(t(e))})),n}if(null!=e._dup)return e._dup();var o,a={},s=Object.keys(e),l=s=e._stateKeys?e._stateKeys():s;return e._excludeStateKeys&&(l=[],o=e._excludeStateKeys(),s.forEach((function(t){-1===o.indexOf(t)&&l.push(t)}))),l.forEach((function(n){"function"!=typeof e[n]&&(a[n]=t(e[n]))})),a}}(a[n]))})),o}var ji=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e=ft({},{onFinish:null,completeOnCancel:null,removeOnFinish:!0,name:xt(),duration:1,delay:0,beforeFrame:null,afterFrame:null,precision:8,element:null},e),this.onFinish=e.onFinish,this.completeOnCancel=e.completeOnCancel,this.duration=e.duration,this.element=e.element,this.startTime=null,this.state="idle",this.name=e.name,this.afterFrame=e.afterFrame,this.beforeFrame=e.beforeFrame,this.startDelay=e.delay,this.precision=e.precision,(this.timeKeeper=null)!=e.timeKeeper&&(this.timeKeeper=e.timeKeeper),this.removeOnFinish=e.removeOnFinish,this.startTimeOffset=0,this.fnMap=new X,this.fnMap.add("tools.math.easein",T),this.fnMap.add("tools.math.easeout",S),this.fnMap.add("tools.math.easeinout",x),this.fnMap.add("tools.math.linear",b),this.fnMap.add("tools.math.sinusoid",A),this}var e=[{key:"_fromDef",value:function(t){return ft(this,t),this}},{key:"fnExec",value:function(t){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(e=this.fnMap).exec.apply(e,[t].concat(r))}},{key:"setTimeDelta",value:function(t){null!=this.startTime&&null!=t&&(this.startTime+=t),null==t&&(this.startTime=null)}},{key:"_getStateProperties",value:function(){return["startTime","duration","onFinish","completeOnCancel","state","startTimeOffset","removeOnFinish","name","startDelay","beforeFrame","afterFrame","_stepType"]}},{key:"_getStateName",value:function(){return"animationStep"}},{key:"_state",value:function(t){return{f1Type:this._getStateName(),state:Ci(this,this._getStateProperties(),t)}}},{key:"_fromState",value:function(t,e,n){return ft(this,t),null!=this.element&&"string"==typeof this.element&&null!=e&&(this.element=e(this.element)),this.timeKeeper=n,this}},{key:"setTimeSpeed",value:function(t,e,n){null!=this.startTime&&(t=(n-this.startTime)*t,this.startTime=n-t/e)}},{key:"nextFrame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return null==this.startTime&&(this.startTime=t-this.startTimeOffset),t=m((t-this.startTime)*e,this.precision),null==this.duration?(this.beforeFrame&&this.beforeFrame(t),this.setFrame(t),this.afterFrame&&this.afterFrame(t),null==this.duration?null:(this.finish(),0)):(e=m(-(this.duration+this.startDelay-t),this.precision),t>=this.startDelay&&((t-=this.startDelay)>=this.duration&&(e=t-this.duration,t=this.duration),this.beforeFrame&&this.beforeFrame(t/this.duration),this.setFrame(t),this.afterFrame&&this.afterFrame(t/this.duration),0<=e&&this.finish()),e)}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;if(null==this.duration)return null;var e=this.getTotalDuration();return null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:(t-=this.startTime,this.duration+this.startDelay-t)}},{key:"getTotalDuration",value:function(){return null==this.duration?null:this.duration+this.startDelay}},{key:"setFrame",value:function(t){}},{key:"startWaiting",value:function(){this.state="waitingToStart"}},{key:"start",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.state="animating","number"!=typeof e&&null!=e?"nextFrame"!==e?null!=this.timeKeeper?(t=this.timeKeeper.getWhen(e),this.startTime=null!=t?t/1e3:null):this.startTime="nextFrame"===e?null:performance.now():this.startTime=null:this.startTime=e}},{key:"finishIfZeroDuration",value:function(){0===this.duration&&0===this.startDelay&&this.finish()}},{key:"setToEnd",value:function(){}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(t=this.state,this.state="finished",e&&("complete"===n||null==n&&!0===this.completeOnCancel?("waitingToStart"===t&&this.start(),this.setToEnd()):"waitingToStart"===t&&this.cancelledWithNoComplete()),!1===e&&("waitingToStart"===t&&this.start(),this.setToEnd()),null!=this.onFinish&&this.fnExec(this.onFinish,e,n))}},{key:"cancelledWithNoComplete",value:function(){}},{key:"cancel",value:function(){this.finish(!0,0<arguments.length&&void 0!==arguments[0]?arguments[0]:null)}},{key:"_dup",value:function(){var e=new t;return dt(this,e,["timeKeeper","element"]),e.timeKeeper=this.timeKeeper,e.element=this.element,e}},{key:"whenFinished",value:function(t){return this.onFinish=t,this}},{key:"ifCanceledThenComplete",value:function(){return this.completeOnCancel=!0,this}},{key:"ifCancelled",value:function(){return this.completeOnCancel="complete"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"freeze"),this}},{key:"ifCanceledThenStop",value:function(){return this.completeOnCancel=!1,this}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Ri(t){return(Ri="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Bi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Fi(t,e,n){return(Fi="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Di(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ii(t,e){return(Ii=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Di(t){return(Di=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Li=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ii(t,e)}(i,ji);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Di(e);return function(t,e){if(e&&("object"===Ri(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Di(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var e=r.call(this,t),n="easeinout";return t=ft({},{element:null,type:"custom",progression:n="color"===t.type||"custom"===t.type||"opacity"===t.type?"linear":n},t),e.element=t.element,e.type=t.type,e.onFinish=t.onFinish,e.progression=t.progression,"linear"===e.progression?e.progression="tools.math.linear":"easein"===t.progression?e.progression="tools.math.easein":"easeout"===t.progression?e.progression="tools.math.easeout":"easeinout"===t.progression?e.progression="tools.math.easeinout":e.progression=t.progression,e}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(r)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(r))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Bi(t)}(t=Fi(Di(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Bi(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Bi(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["type","progression","element"]);var t}},{key:"getPercentComplete",value:function(t){return"string"!=typeof this.progression?"function"==typeof this.progression?this.progression(t):0:null==(t=this.fnExec(this.progression,t))?0:t}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Fi(Di(i.prototype),"start",this).call(this,t),null!=this.element&&this.element.animateNextFrame()}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function zi(t){return(zi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Wi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ni(t,e,n){return(Ni="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Hi(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function qi(t,e){return(qi=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Hi(t){return(Hi=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ui=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&qi(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Hi(e);return function(t,e){if(e&&("object"===zi(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Hi(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t;!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ft.apply(void 0,[{},{type:"position"}].concat(n));bt(a,["start","delta","target","path","pathOptions","velocity","maxDuration"]),(t=r.call(this,a))._stepType="position";var s={start:null,target:null,delta:null,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},maxDuration:null,velocity:null};return t.element&&t.element.animations.options.translation&&(a=t.element.animations.options.translation,ft(s.path,a)),null!=(s=ft.apply(void 0,[{},s].concat(n))).start&&(s.start=Ae(s.start)),null!=s.target&&(s.target=Ae(s.target)),null!=s.delta&&(s.delta=Ae(s.delta)),t.position={path:{}},wt(s,t.position,["start","delta","target","path","velocity","maxDuration"]),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Wi(t)}(t=Ni(Hi(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Wi(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Wi(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["position"]);var t}},{key:"_getStateName",value:function(){return"positionAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(Ni(Hi(i.prototype),"start",this).call(this,t),null==this.position.start){if(null==this.element)return void(this.duration=0);this.position.start=this.element.getPosition()}null==this.position.delta&&null!=this.position.target&&null!=this.position.start?(n=this.position.target.sub(this.position.start),this.position.delta=n):null!=this.position.delta&&null!=this.position.start?this.position.target=this.position.start.add(this.position.delta):this.duration=0;var e=this.position,n=e.target,r=e.start;null!=(e=e.velocity)&&null!=r&&null!=n&&(e=_e(e),this.duration=dr((new Qe).translate(r),(new Qe).translate(n),(new Qe).translate(e))),null!=this.position.maxDuration&&this.duration>this.position.maxDuration&&(this.duration=this.position.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration,t=this.getPercentComplete(t),null!=this.position.delta&&null!=this.position.start&&(t=Le(this.position.start,this.position.delta,t,this.position.path.style,this.position.path),null!=this.element&&this.element.setPosition(t))}},{key:"setToEnd",value:function(){null!=this.element&&null!=this.position.target&&this.element.setPosition(this.position.target)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Ki(t){return(Ki="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Vi(t,e){var n=new RegExp(e,"g");return e=function(t){return t[1].toUpperCase()},t.replace(n,"").replace(/-[a-z]/g,e).replace(/_[a-z]/g,e).replace(/-/g,"")}function Gi(t,e){var n,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:function(t){return t},a={},s=t;return(s="string"==typeof t?document.getElementById(t):s)instanceof HTMLElement&&(n=window.getComputedStyle(s))&&e.forEach((function(t){var e,s,l=n.getPropertyValue(t);null!=l&&(l=l.trim(),e=parseFloat(l),Number.isNaN(e)||(l=e),l=o(l),i?(s=Vi(t,r),a[s]=l):(s=new RegExp(r,"g"),s=t.replace(s,""),lt(a,s,l,"-")))})),a}var Yi=["base","lighter","light","dark","darker","higher","high","low","lower"],Xi=[];["blue","red","yellow","green","cyan","brown","orange","violet","grey","black","white"].forEach((function(t){Yi.forEach((function(e){Xi.push("--palette-".concat(t,"-").concat(e))}))}));var $i=["--figure-background","--figure-primary","--figure-warning","--figure-safe","--figure-passive","--figure-construction1","--figure-construction2","--figure-construction3","--figure-construction4","--figure-construction5","--figure-construction6","--figure-construction7","--figure-construction8","--figure-construction9","--figure-disabled","--figure-disabledDark","--figure-disabledDarker","--figure-disabledDarkest","--figure-push","--figure-action","--figure-text-base","--figure-text-warning","--figure-text-plot","--figure-text-keyword","--figure-text-keyword2","--figure-text-latin","--figure-text-greek","--figure-text-english","--figure-text-note","--figure-qr-background"];function Ji(){var t={},e={},n={},r=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[]).map((function(t){return"--colors-".concat(t)})),i=document.body;return i&&(t=Gi(i,r,"--colors-",!1,to),e=Gi(i,Xi,"--palette-",!1,to),n=Gi(i,$i,"--figure-",!1,to)),t.palette=e,t.figure=n,t}function Zi(t){return 3===(t=t.replace(/.*\(/i,"").replace(/\)/i,"").split(",").map((function(t,e){return e<3?parseInt(t,10)/255:parseFloat(t)}))).length&&t.push(1),t}function Qi(t){return(t=t.slice(1)).length<6&&(t="".concat(t[0]).concat(t[0]).concat(t[1]).concat(t[1]).concat(t[2]).concat(t[2])),[parseInt(t.slice(0,2),16)/255,parseInt(t.slice(2,4),16)/255,parseInt(t.slice(4,6),16)/255,1]}function to(t){var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},n=t.slice(0);return t=[],(n=n in e?e[n]:n).toLowerCase().startsWith("rgb")?t=Zi(n):n.startsWith("#")&&(t=Qi(n)),0<t.length?t:null}function eo(t){return[Math.floor(255*t[0]),Math.floor(255*t[1]),Math.floor(255*t[2]),Math.floor(255*t[3])]}function no(t){return"rgba(".concat(Math.floor(255*t[0]),",").concat(Math.floor(255*t[1]),",").concat(Math.floor(255*t[2]),",").concat(t[3],")")}function ro(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(m(t[r],n)!==m(e[r],n))return!1;return!0}function io(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.001;if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(n<Math.abs(t[r]-e[r]))return!1;return!0}function oo(t){return(oo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ao(t,e,n){return(ao=co()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&uo(r,n.prototype),r}).apply(null,arguments)}function so(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function lo(t,e,n){return(lo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ho(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function uo(t,e){return(uo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function co(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function ho(t){return(ho=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var fo=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&uo(t,e)}(i,ji);var t,e,n,r=(e=i,n=co(),function(){var t,r=ho(e);return function(t,e){if(e&&("object"===oo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ho(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var n,o={steps:[],duration:0},a=arguments.length,s=new Array(1<a?a-1:0),l=1;l<a;l++)s[l-1]=arguments[l];return Array.isArray(e)?(n=ft.apply(void 0,[{},o].concat(s))).steps=e:n=ft.apply(void 0,[{},o,e].concat(s)),(t=r.call(this,n)).steps=[],e=[],Array.isArray(n.steps)||null==n.steps?null!=n.steps&&(e=n.steps):e=[n.steps],t.steps=[],e.forEach((function(e){null!=e&&t.steps.push(e)})),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return so(t)}(t=lo(ho(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return so(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?so(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["steps"]);var t}},{key:"_getStateName",value:function(){return"parallelAnimationStep"}},{key:"setTimeDelta",value:function(t){lo(ho(i.prototype),"setTimeDelta",this).call(this,t),null!=this.steps&&this.steps.forEach((function(e){e.setTimeDelta(t)}))}},{key:"with",value:function(t){return null!=t&&this.steps.push(t),this}},{key:"setTimeSpeed",value:function(t,e,n){lo(ho(i.prototype),"setTimeSpeed",this).call(this,t,e,n),this.steps.forEach((function(r){return r.setTimeSpeed(t,e,n)}))}},{key:"nextFrame",value:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return null===this.startTime&&(this.startTime=t-this.startTimeOffset),null!=this.beforeFrame&&this.beforeFrame(t-this.startTime),this.steps.forEach((function(r){"animating"!==r.state&&"waitingToStart"!==r.state||(r=r.nextFrame(t,n),void 0===e?e=r:null===e||null===r?e=null:r<e&&(e=r))})),null!=this.afterFrame&&this.afterFrame(t-this.startTime),null===e?null:void 0===e?0:(0<=e&&this.finish(),e)}},{key:"finishIfZeroDuration",value:function(){var t="finished";this.steps.forEach((function(e){"finished"!==e.state&&(t="animating")})),"finished"===t&&this.finish()}},{key:"startWaiting",value:function(){lo(ho(i.prototype),"startWaiting",this).call(this),this.steps.forEach((function(t){t.startWaiting()}))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.startWaiting(),lo(ho(i.prototype),"start",this).call(this,t),this.steps.forEach((function(e){e.start(t),e.finishIfZeroDuration()}))}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(this.state="finished",!(t=null)===this.completeOnCancel&&(t="complete"),!1===this.completeOnCancel&&(t="freeze"),null!=n&&(t=n),this.steps.forEach((function(n){"idle"!==n.state&&"finished"!==n.state&&n.finish(e,t)})),null!=this.onFinish&&this.fnExec(this.onFinish,e))}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.steps.length;e+=1){var n=this.steps[e].getTotalDuration();if(null==n)return null;t<n&&(t=n)}return t}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;var e=this.getTotalDuration();return null==e?null:null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:e-(t-this.startTime)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function po(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return ao(fo,[t].concat(n))}function mo(t){return(mo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function yo(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||vo(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vo(t,e){if(t){if("string"==typeof t)return go(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?go(t,e):void 0}}function go(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function bo(t,e,n){return(bo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=xo(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function wo(t,e){return(wo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function xo(t){return(xo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var So=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&wo(t,e)}(i,fo);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=xo(e);return function(t,e){if(e&&("object"===mo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=xo(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t;!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ft.apply(void 0,[{},{type:"scenario"}].concat(n));bt(a,["start","target","path","velocity","maxDuration","allDurationsSame","rotDirection","clipRotationTo","element","progression"]),(t=r.call(this,a))._stepType="position";var s,l={element:null,start:null,target:null,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},rotDirection:0,clipRotationTo:null,velocity:null,maxDuration:null,allDurationsSame:!0,zeroDurationThreshold:0,progression:"tools.math.easeinout"};return t.element&&t.element.animations.options.translation&&(s=t.element.animations.options.translation,ft(l.path,s)),l=ft.apply(void 0,[{},l].concat(n)),t.element=l.element,t.scenario={},wt(l,t.scenario,["start","target","path","velocity","maxDuration","allDurationsSame","zeroDurationThreshold","rotDirection","clipRotationTo","progression"]),null!=t.scenario.velocity&&null==a.duration?t.duration=0:null==a.duration&&(t.duration=1),t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return go(t)}(t=bo(xo(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||vo(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["scenario","element"]);var t}},{key:"_getStateName",value:function(){return"scenarioAnimationStep"}},{key:"getDuration",value:function(t,e){var n=this.element,r=this.scenario.velocity;if(null==r||null==n)return[this.duration,this.duration,this.duration];var i=n.transform.identity(),o=null==r.color?1:r.color,a=null==r.opacity?1:r.opacity;if(null!=r.transform&&(i=rn(r.transform)._dup()),null!=r.position&&i.hasComponent("t")&&i.updateTranslation(_e(r.position)),null!=r.translation&&i.hasComponent("t")&&i.updateTranslation(_e(r.translation)),null!=r.scale&&i.hasComponent("s")&&i.updateScale(_e(r.scale)),null!=r.rotation){for(var s=0;s<i.def.length;s+=1)"r"===yo(i.def[s],1)[0]&&(i.def[s]=["r",r.rotation,0,0,0]);i.calcAndSetMatrix()}var l=0,u=t.transform;return n=e.transform,null!=u&&null!=n&&(l=dr(u._dup(),n._dup(),i,this.scenario.rotDirection)),n=0,null==t.color||null==e.color||ro(e.color,t.color)||(n=Math.max(Math.abs(e.color[0]-t.color[0]),Math.abs(e.color[1]-t.color[1]),Math.abs(e.color[2]-t.color[2]),Math.abs(e.color[3]-t.color[3]))/o),o=0,null!=t.isShown&&null!=e.isShown&&(null!=t.opacity&&!0===e.isShown?o=(1-t.opacity)/a:null!=t.opacity&&!1===e.isShown?o=t.opacity/a:t.isShown!==e.isShown&&(o=1/a)),null!=(a=this.scenario.maxDuration)&&(n=Math.min(n,a),o=Math.min(o,a),l=Math.min(l,a)),(n=n<=this.scenario.zeroDurationThreshold?0:n)<this.duration&&(n=this.duration),(o=o<=this.scenario.zeroDurationThreshold?0:o)<this.duration&&(o=this.duration),(l=l<=this.scenario.zeroDurationThreshold?0:l)<this.duration&&(l=this.duration),[l=this.scenario.allDurationsSame?o=n=Math.max(n,o,l):l,n,o]}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;bo(xo(i.prototype),"start",this).call(this,t);var e=this.element;if(null==e)throw new Error("Missing Element in scenario animation - null element for target: ".concat(this.scenario.target));var n=e.getScenarioTarget(this.scenario.target);0===Object.keys(n).length&&(n=e.getCurrentScenario());var r={};null!=this.scenario.start&&(r=e.getScenarioTarget(this.scenario.start)),0===Object.keys(r).length&&(r=e.getCurrentScenario(),1!==e.opacity&&(r.opacity=e.opacity));var o=null,a=!1;!1===r.isShown&&!0===n.isShown&&null==r.opacity?o="in":!0===n.isShown&&null!=r.opacity?(o="in",a=!0):!0===r.isShown&&!1===n.isShown&&null==r.opacity?o="out":!1===n.isShown&&null!=r.opacity&&(o="out",a=!0);var s=(c=yo(this.getDuration(r,n),3))[0],l=c[1],u=c[2],c=[];null!=n.transform&&c.push(e.animations.transform({delay:this.startDelay,start:r.transform,target:n.transform,duration:s,rotDirection:this.scenario.rotDirection,path:this.scenario.path,clipRotationTo:this.scenario.clipRotationTo,progression:this.scenario.progression})),null!=n.color&&c.push(e.animations.color({delay:this.startDelay,start:r.color,target:n.color,duration:l,progression:this.scenario.progression})),null!=o&&c.push(e.animations.opacity({delay:this.startDelay,dissolve:o,dissolveFromCurrent:a,duration:u,progression:this.scenario.progression})),this.steps=c,bo(xo(i.prototype),"start",this).call(this,t)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function To(t){return(To="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ao(t,e,n){return(Ao=Co()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&Eo(r,n.prototype),r}).apply(null,arguments)}function ko(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Oo(t,e,n){return(Oo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=jo(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Po(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Eo(t,e)}function Eo(t,e){return(Eo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Mo(t){var e=Co();return function(){var n,r=jo(t);return function(t,e){if(e&&("object"===To(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=jo(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function Co(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function jo(t){return(jo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ro=function(){Po(n,Li);var t,e=Mo(n);function n(){_o(this,n);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];bt(a=ft.apply(void 0,[{}].concat(r,[{type:"color"}])),["start","delta","target","dissolve"]);var o=e.call(this,a),a=ft.apply(void 0,[{},{start:null,target:null,delta:null,dissolve:null}].concat(r));return o.color={},wt(a,o.color,["start","delta","target","dissolve"]),"dim"===o.color.target?(null!=o.element&&(o.color.target=o.element.dimColor.slice()),o.color.setDefault=!1):"undim"===o.color.target?(null!=o.element&&(o.color.target=o.element.defaultColor.slice()),o.color.setDefault=!1):o.color.setDefault=!0,o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return ko(t)}(t=Oo(jo(n.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return ko(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ko(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["color"]);var t}},{key:"_getStateName",value:function(){return"colorAnimationStep"}},{key:"start",value:function(){var t,e,r,i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=this.element;null!=o?(Oo(jo(n.prototype),"start",this).call(this,i),null==this.color.start&&(this.color.start=o.color.slice()),null==this.color.delta&&null==this.color.target?this.color.target=this.color.start.slice():null!=this.color.delta&&(this.color.target=(e=this.color.start,r=this.color.delta,e.map((function(t,e){return Math.min(t+r[e],1)})))),this.color.whenComplete=this.color.target.slice(),"out"===this.color.dissolve&&(this.color.target[3]=.001),"in"===this.color.dissolve&&(this.color.start[3]=.001,o.setColor(this.color.start,this.color.setDefault),o.showAll()),this.color.delta=(o=this.color.target,t=this.color.start,o.map((function(e,n){return e-t[n]})))):this.duration=0,"now"!==i&&"prevFrame"!==i||this.setFrame(0)}},{key:"setFrame",value:function(t){var e=this,n=(t/=this.duration,this.getPercentComplete(t));t=this.color.start.map((function(t,r){return(r=1<(r=t+e.color.delta[r]*n)?1:r)<0?0:r})),null!=this.element&&this.element.setColor(t,this.color.setDefault)}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(t.setColor(this.color.whenComplete,this.color.setDefault),"out"===this.color.dissolve&&t.hide())}},{key:"_dup",value:function(){var t=new n;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(n.prototype,t),n}(),Bo=function(){Po(e,Ro);var t=Mo(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_o(this,e);for(var r={duration:1,target:"dim",completeOnCancel:!0},i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return n=ft.apply(void 0,("number"==typeof n?[{},r,{duration:n}]:[{},r,n]).concat(o)),t.call(this,n)}return e}(),Fo=function(){Po(e,Ro);var t=Mo(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_o(this,e);for(var r={duration:1,target:"undim",completeOnCancel:!0},i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return n=ft.apply(void 0,("number"==typeof n?[{},r,{duration:n}]:[{},r,n]).concat(o)),t.call(this,n)}return e}();function Io(t){return(Io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Do(t,e,n){return(Do=Uo()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&qo(r,n.prototype),r}).apply(null,arguments)}function Lo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function zo(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Wo(t,e,n){return(Wo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ko(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function No(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&qo(t,e)}function qo(t,e){return(qo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ho(t){var e=Uo();return function(){var n,r=Ko(t);return function(t,e){if(e&&("object"===Io(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Ko(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function Uo(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Ko(t){return(Ko=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Vo=function(){No(n,Li);var t,e=Ho(n);function n(){zo(this,n);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];bt(a=ft.apply(void 0,[{}].concat(r,[{type:"opacity"}])),["start","delta","target","dissolve","dissolveFromCurrent"]);var o=e.call(this,a),a=ft.apply(void 0,[{},{start:null,target:null,delta:null,dissolve:null,dissolveFromCurrent:!1}].concat(r));return o.opacity={},wt(a,o.opacity,["start","delta","target","dissolve","dissolveFromCurrent"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Lo(t)}(t=Wo(Ko(n.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Lo(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Lo(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["opacity"]);var t}},{key:"_getStateName",value:function(){return"opacityAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=this.element;null!=e?(Wo(Ko(n.prototype),"start",this).call(this,t),null==this.opacity.start&&(this.opacity.start=e.opacity),null==this.opacity.delta&&null==this.opacity.target?this.opacity.target=this.opacity.start:null!=this.opacity.delta&&(this.opacity.target=this.opacity.start+this.opacity.delta),this.opacity.whenComplete=this.opacity.target,"out"===this.opacity.dissolve&&(this.opacity.dissolveFromCurrent&&e.isShown?this.opacity.start=e.opacity:this.opacity.start=1,this.opacity.target=.001,this.opacity.whenComplete=1,e.setOpacity(this.opacity.start)),"in"===this.opacity.dissolve&&(this.opacity.dissolveFromCurrent&&e.isShown?this.opacity.start=e.opacity:this.opacity.start=.001,this.opacity.target=1,this.opacity.whenComplete=1,e.showAll(),e.setOpacity(this.opacity.start)),this.opacity.delta=this.opacity.target-this.opacity.start):this.duration=0,"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"cancelledWithNoComplete",value:function(){var t=this.element;null!=t&&.001===t.opacity&&(t.hide(),t.opacity=1)}},{key:"setFrame",value:function(t){t/=this.duration,t=this.getPercentComplete(t),(t=1<(t=this.opacity.start+this.opacity.delta*t)?1:t)<0&&(t=0),null!=this.element&&this.element.setOpacity(t)}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(t.setOpacity(this.opacity.whenComplete),"out"===this.opacity.dissolve&&t.hide())}},{key:"_dup",value:function(){var t=new n;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(n.prototype,t),n}(),Go=function(){No(e,Vo);var t=Ho(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};zo(this,e);for(var r={duration:1,dissolve:"in",completeOnCancel:!0},i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return n=ft.apply(void 0,("number"==typeof n?[{},r,{duration:n}]:[{},r,n]).concat(o)),t.call(this,n)}return e}(),Yo=function(){No(e,Vo);var t=Ho(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};zo(this,e);for(var r={duration:1,dissolve:"out",completeOnCancel:!0},i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return n=ft.apply(void 0,("number"==typeof n?[{},r,{duration:n}]:[{},r,n]).concat(o)),t.call(this,n)}return e}();function Xo(t){return(Xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Jo(t,e,n){return(Jo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Qo(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Zo(t,e){return(Zo=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Qo(t){return(Qo=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ta=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Zo(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Qo(e);return function(t,e){if(e&&("object"===Xo(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Qo(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ft.apply(void 0,[{},{type:"transform"}].concat(e));bt(o,["start","delta","target","rotDirection","path","velocity","clipRotationTo","maxDuration"]);var a,s={start:null,target:null,delta:null,rotDirection:0,path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},velocity:null,clipRotationTo:null,maxDuration:null};return(a=r.call(this,o)).element&&a.element.animations.options.translation&&(o=a.element.animations.options.translation,ft(s.path,o)),null!=(s=ft.apply(void 0,[{},s].concat(e))).start&&(s.start=rn(s.start)),null!=s.target&&(s.target=rn(s.target)),null!=s.delta&&(s.delta=rn(s.delta)),null!=s.velocity&&"number"!=typeof s.velocity&&(s.velocity=rn(s.velocity)),a.transform={},wt(s,a.transform,["start","delta","target","path","velocity","rotDirection","clipRotationTo","maxDuration"]),a}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return $o(t)}(t=Jo(Qo(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return $o(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?$o(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["transform"]);var t}},{key:"_getStateName",value:function(){return"transformAnimationStep"}},{key:"start",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(Jo(Qo(i.prototype),"start",this).call(this,e),null===this.transform.start){if(null==this.element)return void(this.duration=0);this.transform.start=this.element.transform._dup()}null==this.transform.delta&&null!=this.transform.target?(t=this.transform.target.sub(this.transform.start),this.transform.delta=t):null!=this.transform.delta?this.transform.target=this.transform.start.add(this.transform.delta):this.duration=0,null!=this.transform.velocity&&(this.duration=dr(this.transform.start,this.transform.target,this.transform.velocity,this.transform.rotDirection)),null!=this.transform.maxDuration&&this.duration>this.transform.maxDuration&&(this.duration=this.transform.maxDuration),"now"!==e&&"prevFrame"!==e||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration+1e-6,t=this.getPercentComplete(t),t=this.transform.start.toDelta(this.transform.delta,t,this.transform.path.style,this.transform.path),null!==this.transform.clipRotationTo&&t.clipRotation(this.transform.clipRotationTo),null!=this.element&&this.element.setTransform(t)}},{key:"setToEnd",value:function(){null!=this.element&&this.element.setTransform(this.transform.target)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function ea(t){return(ea="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function na(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ra(t,e,n){return(ra="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=oa(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ia(t,e){return(ia=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function oa(t){return(oa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var aa=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ia(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=oa(e);return function(t,e){if(e&&("object"===ea(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=oa(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ft.apply(void 0,[{},{type:"transform"}].concat(e));bt(o,["start","delta","target","rotDirection","path","velocity","clipRotationTo","maxDuration","zeroDurationThreshold"]);var a,s,l={start:null,target:null,delta:[],path:{style:"linear",magnitude:.5,offset:.5,controlPoint:null,direction:"positive"},rotDirection:0,velocity:null,clipRotationTo:null,maxDuration:null,zeroDurationThreshold:0};return(a=r.call(this,o)).element&&a.element.animations.options.translation&&(s=a.element.animations.options.translation,ft(l.path,s)),l=ft.apply(void 0,[{},l].concat(e)),a.transform={},wt(l,a.transform,["start","delta","target","path","velocity","rotDirection","clipRotationTo","maxDuration","zeroDurationThreshold"]),null!=a.transform.velocity&&null==o.duration&&(a.duration=0),a}return t=[{key:"spread",value:function(t,e){if(e===t.length)return t;if(e<=1)return[t[0]];var n=[];if(e>t.length){for(var r=e-t.length,i=Math.ceil(r/2),o=Math.floor(r/2),a=t[0]._dup(),s=t[t.length-1]._dup(),l=0;l<i;l+=1)n.push(a._dup());for(var u=0;u<t.length;u+=1)n.push(t[u]._dup());for(var c=0;c<o;c+=1)n.push(s._dup());return n}e=t.length-e;for(var h=Math.ceil((t.length-e)/2),f=(e=Math.floor((t.length-e)/2),0);f<h;f+=1)n.push(t[f]._dup());for(var d=t.length-e;d<t.length;d+=1)n.push(t[d]._dup());return n}},{key:"setStartAndTarget",value:function(){var t=(e=this.transform).start,e=e.target;e=Math.max(t.length,e.length),this.transform.start=this.spread(this.transform.start,e),this.transform.target=this.spread(this.transform.target,e)}},{key:"calculateStartTargetDelta",value:function(){if(this.transform.start.length===this.transform.target.length){this.transform.delta=[];for(var t=0;t<this.transform.start.length;t+=1){var e=this.transform.start[t];e=this.transform.target[t].sub(e),this.transform.delta.push(e)}}else this.transform.delta=[]}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return na(t)}(t=ra(oa(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return na(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?na(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["transform"]);var t}},{key:"_getStateName",value:function(){return"transformAnimationStep"}},{key:"getVelocityTransform",value:function(){var t=this.transform.velocity;if(null==t)return new Qe;if(t instanceof Qe)return t;if("number"==typeof t)return this.transform.start[0]._dup().constant(t);var e=this.transform.start[0]._dup().constant(1);null!=t.transform&&(e=rn(t.transform)._dup());for(var n=0;n<e.def.length;n+=1){var r,i,o=e.def[n];"s"===o[0]&&null!=t.scale&&(r=_e(t.scale),o[1]=r.x,o[2]=r.y),"t"===o[0]&&null!=t.translation&&(i=_e(t.translation),o[1]=i.x,o[2]=i.y),"t"===o[0]&&null!=t.position&&(i=_e(t.position),o[1]=i.x,o[2]=i.y),"r"===o[0]&&null!=t.rotation&&(o[1]=t.rotation),e.calcAndSetMatrix()}return e}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(ra(oa(i.prototype),"start",this).call(this,t),null==this.transform.start||0===this.transform.start.length){if(null==this.element)return void(this.duration=0);0<this.element.pulseTransforms.length?this.transform.start=this.element.pulseTransforms.map((function(t){return t._dup()})):this.transform.start=[this.transform.target[0].identity()]}if(0===this.transform.start.length&&null!=this.element&&(this.transform.start=[this.element.transform._dup()]),this.setStartAndTarget(),this.calculateStartTargetDelta(),0===this.transform.delta.length&&(this.duration=0),null!=this.transform.velocity)for(var e=this.getVelocityTransform(),n=0;n<this.transform.start.length;n+=1){var r=dr(this.transform.start[n],this.transform.target[n],e,this.transform.rotDirection);r>this.duration&&(this.duration=r)}null!=this.transform.maxDuration&&this.duration>this.transform.maxDuration&&(this.duration=this.transform.maxDuration),this.duration<=this.transform.zeroDurationThreshold&&(this.duration=0),this.duration=m(this.duration,this.precision),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration;var e=this.getPercentComplete(t);if(null!=this.element){var n=this.element;n.frozenPulseTransforms=[];for(var r=0;r<this.transform.start.length;r+=1){var i=this.transform.start[r].toDelta(this.transform.delta[r],e,this.transform.path.style,this.transform.path);null!==this.transform.clipRotationTo&&i.clipRotation(this.transform.clipRotationTo),n.frozenPulseTransforms.push(i)}}}},{key:"setToEnd",value:function(){var t;null!=this.element&&((t=this.element).frozenPulseTransforms=[],this.transform.target.forEach((function(e){t.frozenPulseTransforms.push(e._dup())})))}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function sa(t){return(sa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function la(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ua(t,e,n){return(ua="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ha(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ca(t,e){return(ca=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ha(t){return(ha=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var fa=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ca(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=ha(e);return function(t,e){if(e&&("object"===sa(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ha(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];bt(a=ft.apply(void 0,[{},{type:"rotation"}].concat(e)),["start","delta","target","direction","velocity","clipTo","maxDuration"]);var o=r.call(this,a),a=ft.apply(void 0,[{},{start:null,target:null,delta:null,velocity:null,clipTo:null,maxDuration:null}].concat(e));return o.rotation={},wt(a,o.rotation,["start","delta","target","velocity","clipTo","maxDuration"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return la(t)}(t=ua(ha(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return la(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?la(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["rotation"]);var t}},{key:"_getStateName",value:function(){return"rotationAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(ua(ha(i.prototype),"start",this).call(this,t),null===this.rotation.start){if(null==this.element)return void(this.duration=0);this.rotation.start=this.element.getRotation()}var e=(a=this.rotation).start,n=a.velocity,r=this.rotation,o=r.target,a=r.delta;null!=o?this.rotation.delta=o-e:null!=a?this.rotation.target=e+(s=a):null!=n&&null!=this.duration?(this.rotation.target=e+n*this.duration,this.rotation.delta=n*this.duration):null!=this.duration&&(this.duration=0);var s=this.rotation;o=s.target,a=s.delta,void 0===this.duration&&null!=n&&null!=e&&null!=o&&(this.duration=(o-e)/n),null!=this.rotation.maxDuration&&null!=this.duration&&this.duration>this.rotation.maxDuration&&(this.duration=this.rotation.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){var e,n,r,i;null!=this.duration&&null!=this.rotation.delta?(r=t/(this.duration+1e-6),e=this.getPercentComplete(r),n=(i=this.rotation).start,r=i.delta,null!=(i=this.element)&&i.setRotation(n+r*e)):(t=this.rotation.start+t*this.rotation.velocity,null!=this.element&&this.element.setRotation(t))}},{key:"setToEnd",value:function(){var t=this.element;null!=t&&(null!=this.rotation.target&&t.transform.updateRotation(this.rotation.target),this.fnExec(t.setTransformCallback,t.transform))}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function da(t){return(da="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function pa(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ma(t,e,n){return(ma="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=va(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ya(t,e){return(ya=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function va(t){return(va=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ga=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ya(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=va(e);return function(t,e){if(e&&("object"===da(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=va(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];bt(a=ft.apply(void 0,[{},{type:"position"}].concat(e)),["start","delta","target","velocity","maxDuration"]);var o=r.call(this,a),a=ft.apply(void 0,[{},{start:null,target:null,delta:null,velocity:null,maxDuration:null}].concat(e));return o.scale={},null!=a.start&&(a.start=_e(a.start)),null!=a.target&&(a.target=_e(a.target)),null!=a.delta&&(a.delta=_e(a.delta)),wt(a,o.scale,["start","delta","target","path","velocity","maxDuration"]),o}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return pa(t)}(t=ma(va(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return pa(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?pa(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["scale"]);var t}},{key:"_getStateName",value:function(){return"scaleAnimationStep"}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(ma(va(i.prototype),"start",this).call(this,t),null===this.scale.start){if(null==this.element)return void(this.duration=0);this.scale.start=this.element.getScale()}null==this.scale.delta&&null!=this.scale.target&&null!=this.scale.start?(n=this.scale.target.sub(this.scale.start),this.scale.delta=n):null!=this.scale.delta&&null!=this.scale.start?this.scale.target=this.scale.start.add(this.scale.delta):this.duration=0;var e=this.scale,n=e.target,r=e.start;null!=(e=e.velocity)&&null!=n&&null!=r&&(e=_e(e),this.duration=dr((new Qe).scale(r),(new Qe).scale(n),(new Qe).scale(e))),null!=this.scale.maxDuration&&this.duration>this.scale.maxDuration&&(this.duration=this.scale.maxDuration),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"setFrame",value:function(t){t/=this.duration+1e-6,t=this.getPercentComplete(t),null!=this.scale.start&&null!=this.scale.delta&&(t=Le(this.scale.start,this.scale.delta,t),null!=this.element&&this.element.setScale(t))}},{key:"setToEnd",value:function(){null!=this.element&&null!=this.scale.target&&this.element.setScale(this.scale.target)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function ba(t){return(ba="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function wa(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function xa(t,e,n){return(xa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ta(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Sa(t,e){return(Sa=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ta(t){return(Ta=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Aa=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Sa(t,e)}(i,Li);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Ta(e);return function(t,e){if(e&&("object"===ba(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ta(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t;!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var a=ft.apply(void 0,[{},{type:"position"}].concat(n));return bt(a,["stopAfterDuration","frequency","scale","rotation","translation","angle","min","centerOn","xAlign","yAlign","space","done","num","when","stopAfterDuration","velocity","maxDuration"]),(t=r.call(this,a))._stepType="pulse",void 0===(a=ft.apply(void 0,[{},{scale:2,rotation:null,translation:null,angle:0,duration:1,frequency:0,xAlign:"center",yAlign:"middle",num:1,space:"figure",done:null,progression:"sinusoid",when:"syncNow",type:"pulse",stopAfterDuration:!0}].concat(n))).centerOn&&null!=t.element&&(a.centerOn=t.element),t.pulse={},wt(a,t.pulse,["stopAfterDuration","frequency","scale","rotation","translation","angle","min","centerOn","xAlign","yAlign","space","done","num","when","stopAfterDuration","velocity","maxDuration","duration","elements"]),t.pulse.centerOn=a.centerOn,t.duration=a.duration,t.toStart=!0,t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return wa(t)}(t=xa(Ta(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return wa(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?wa(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["toStart","pulse"]);var t}},{key:"_getStateName",value:function(){return"pulseAnimationStep"}},{key:"setFrame",value:function(){var t;this.toStart&&(null!=(t=this.element)&&t.pulse(this.pulse),this.toStart=!1)}},{key:"setToEnd",value:function(){null!=this.element&&this.pulse.stopAfterDuration&&this.element.stopPulsing()}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.element=this.element,t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function ka(t){return(ka="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _a(t,e,n){return(_a=Ma()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&Ea(r,n.prototype),r}).apply(null,arguments)}function Oa(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Pa(t,e,n){return(Pa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ca(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ea(t,e){return(Ea=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ma(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Ca(t){return(Ca=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ja=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ea(t,e)}(i,ji);var t,e,n,r=(e=i,n=Ma(),function(){var t,r=Ca(e);return function(t,e){if(e&&("object"===ka(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ca(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e,n={payload:null,duration:0,setToEnd:null,autoDuration:!0},o=arguments.length,a=new Array(1<o?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return"function"==typeof t||"string"==typeof t?(e=ft.apply(void 0,[{},n].concat(a))).callback=t:e=ft.apply(void 0,[{},n,t].concat(a)),(t=r.call(this,e)).element=e.element,t.callback=e.callback,t.payload=e.payload,t.duration=e.duration,t.autoDuration=e.autoDuration,e.setToEnd&&(t.setToEndCallback=e.setToEnd),t.customProperties=e.customProperties,t}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(r)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(r))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Oa(t)}(t=Pa(Ca(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Oa(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Oa(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["callback","payload","customProperties","element"]);var t}},{key:"_getStateName",value:function(){return"triggerAnimationStep"}},{key:"setFrame",value:function(){var t=this.fnExec(this.callback,this.payload,this.customProperties);null!=t&&"number"==typeof t&&this.autoDuration&&(this.duration=t),this.callback=null}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Pa(Ca(i.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame()}},{key:"setToEnd",value:function(){null!=this.setToEndCallback?this.fnExec(this.setToEndCallback,this.payload,this.customProperties):this.fnExec(this.callback,this.payload,this.customProperties),this.callback=null}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element","timeKeeper"]),t.timeKeeper=this.timeKeeper,t.element=this.element,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Ra(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return _a(ja,[t].concat(n))}function Ba(t){return(Ba="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fa(t,e,n){return(Fa=za()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&La(r,n.prototype),r}).apply(null,arguments)}function Ia(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Da(t,e,n){return(Da="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Wa(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function La(t,e){return(La=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function za(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Wa(t){return(Wa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Na=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&La(t,e)}(i,ji);var t,e,n,r=(e=i,n=za(),function(){var t,r=Wa(e);return function(t,e){if(e&&("object"===Ba(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Wa(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o=ft.apply(void 0,[{}].concat(e)),a=r.call(this,o);return o=ft.apply(void 0,[{},{element:null,callback:null,startPercent:0,progression:"linear",duration:1}].concat(e)),a.element=o.element,a.progression=o.progression,"linear"===a.progression?a.progression="tools.math.linear":"easein"===o.progression?a.progression="tools.math.easein":"easeout"===o.progression?a.progression="tools.math.easeout":"easeinout"===o.progression&&(a.progression="tools.math.easeinout"),a.callback=o.callback,a.startPercent=o.startPercent,a.startTimeOffset=a.getPercentComplete(o.startPercent,!0)*o.duration,a.duration=o.duration,a.customProperties=o.customProperties,a.isInfinite=null==a.duration,a}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(r)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(r))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Da(Wa(i.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Ia(t)}(t=Da(Wa(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Ia(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ia(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["callback","startPercent","progression","customProperties","element"]);var t}},{key:"_getStateName",value:function(){return"customAnimationStep"}},{key:"setFrame",value:function(t){var e;(null==this.duration?this.fnExec(this.callback,t,this.customProperties):(e=t/this.duration,e=this.getPercentComplete(e),this.fnExec(this.callback,e,this.customProperties)))&&(this.duration=t)}},{key:"getPercentComplete",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return"string"!=typeof this.progression?"function"==typeof this.progression?this.progression(t):0:null==(e=this.fnExec(this.progression,t,e))?0:e}},{key:"setToEnd",value:function(){this.isInfinite||this.fnExec(this.callback,1,this.customProperties)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function qa(t){return(qa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ha(t,e,n){return(Ha=Ga()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&Va(r,n.prototype),r}).apply(null,arguments)}function Ua(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ka(t,e,n){return(Ka="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ya(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Va(t,e){return(Va=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ga(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Ya(t){return(Ya=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Xa=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Va(t,e)}(i,ji);var t,e,n,r=(e=i,n=Ga(),function(){var t,r=Ya(e);return function(t,e){if(e&&("object"===qa(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ya(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e,n={steps:[],duration:0},o=arguments.length,a=new Array(1<o?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return Array.isArray(t)?(e=ft.apply(void 0,[{},n].concat(a))).steps=t:e=ft.apply(void 0,[{},n,t].concat(a)),(t=r.call(this,e)).index=0,t.steps=[],Array.isArray(e.steps)||null==e.steps?null!=e.steps&&(t.steps=e.steps):t.steps=[e.steps],t}return t=[{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Ua(t)}(t=Ka(Ya(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Ua(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ua(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["steps","index"]);var t}},{key:"_getStateName",value:function(){return"serialAnimationStep"}},{key:"setTimeDelta",value:function(t){Ka(Ya(i.prototype),"setTimeDelta",this).call(this,t),null!=this.steps&&this.steps.forEach((function(e){e.setTimeDelta(t)}))}},{key:"then",value:function(t){return null!=t&&this.steps.push(t),this}},{key:"startWaiting",value:function(){Ka(Ya(i.prototype),"startWaiting",this).call(this),this.steps.forEach((function(t){t.startWaiting()}))}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;"animating"!==this.state&&(this.startWaiting(),Ka(Ya(i.prototype),"start",this).call(this,t),this.index=0,this.startStep(t))}},{key:"finishIfZeroDuration",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=t,n=this.steps[t];e<this.steps.length&&"finished"===n.state;)(e+=1)<this.steps.length&&(this.index=e,(n=this.steps[e]).start(this.steps[e-1].startTime),n.finishIfZeroDuration());e===this.steps.length&&this.finish()}},{key:"startStep",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.index>=this.steps.length?this.finish():((t=this.steps[this.index]).start(e),t.finishIfZeroDuration(),"finished"===t.state&&(this.index+=1,this.index===this.steps.length?this.finish():this.startStep(e)))}},{key:"setTimeSpeed",value:function(t,e,n){Ka(Ya(i.prototype),"setTimeSpeed",this).call(this,t,e,n),this.steps.forEach((function(r){return r.setTimeSpeed(t,e,n)}))}},{key:"nextFrame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;null===this.startTime&&(this.startTime=t-this.startTimeOffset);var n=-1;if(null!=this.beforeFrame&&this.beforeFrame(t-this.startTime),this.index<=this.steps.length-1&&(n=this.steps[this.index].nextFrame(t,e),null!=this.afterFrame&&this.afterFrame(t-this.startTime),null!=n&&0<=n)){if(this.index===this.steps.length-1)return this.finish(),n;if(this.index+=1,this.startStep(t-n),this.index<this.steps.length)return this.nextFrame(t,e)}return n}},{key:"finish",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"idle"!==this.state&&"finished"!==this.state&&(this.state="finished",!(t=null)===this.completeOnCancel&&(t="complete"),!1===this.completeOnCancel&&(t="freeze"),null!=n&&(t=n),this.steps.forEach((function(n){"idle"!==n.state&&"finished"!==n.state&&n.finish(e,t)})),null!=this.onFinish&&this.fnExec(this.onFinish,e,n))}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.steps.length;e+=1){var n=this.steps[e];if(null==n.getTotalDuration())return null;t+=n.getTotalDuration()}return t}},{key:"getRemainingTime",value:function(t){if("animating"!==this.state&&"waitingToStart"!==this.state)return 0;var e=this.getTotalDuration();return null==e?null:null==this.startTime?"animating"===this.state||"waitingToStart"===this.state?e:0:e-(t-this.startTime)}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function $a(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Ha(Xa,[t].concat(n))}function Ja(t){return(Ja="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Za(t,e,n){return(Za=es()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&ts(r,n.prototype),r}).apply(null,arguments)}function Qa(t,e,n){return(Qa="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ns(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function ts(t,e){return(ts=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function es(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function ns(t){return(ns=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var rs=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ts(t,e)}(i,ji);var t,e,n,r=(e=i,n=es(),function(){var t,r=ns(e);return function(t,e){if(e&&("object"===Ja(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ns(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var e={duration:0},n=arguments.length,o=new Array(1<n?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return t=ft.apply(void 0,("number"==typeof t?[{},e,{duration:t}]:[{},e,t]).concat(o)),r.call(this,t)}return t=[{key:"_dup",value:function(){var t=new i;return dt(this,t,["timeKeeper"]),t.timeKeeper=this.timeKeeper,t}},{key:"start",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;Qa(ns(i.prototype),"start",this).call(this,t),"now"!==t&&"prevFrame"!==t||this.setFrame(0)}},{key:"_getStateName",value:function(){return"delayAnimationStep"}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function is(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Za(rs,[t].concat(n))}function os(t,e,n){return(e.x-t.x)*(n.y-t.y)-(n.x-t.x)*(e.y-t.y)}function as(t,e){var n=0,r=e.length-1,i=e.slice(),o=t;t=!1,i[0].isNotEqualTo(i[r])&&(i.push(i[0]),t=!0,r+=1);for(var a=0;a<r;a+=1)i[a].y<=o.y?i[a+1].y>o.y&&0<os(i[a],i[a+1],o)&&(n+=1):i[a+1].y<=o.y&&os(i[a],i[a+1],o)<0&&--n;return t&&i.pop(),0!==n}var ss=n(477),ls=n.n(ss);function us(){return ls()('(()=>{"use strict";var e=function(e){var n=Math.pow(10,1<arguments.length&&void 0!==arguments[1]?arguments[1]:5);return-0!=(e=Math.round(e*n)/n)||0===e&&1/e!=-1/0?e:0};function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||t(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(n,t){var r=1<arguments.length&&void 0!==t?t:null;if("number"==typeof n&&null!=r)return e(n,r);if("number"==typeof n||"boolean"==typeof n||"string"==typeof n||null==n||NaN===n||"function"==typeof n)return n;if("function"==typeof n._dup)return n._dup();if(Array.isArray(n)){var i=[];return n.forEach((function(e){return i.push(f(e,r))})),i}var a={};return Object.keys(n).forEach((function(e){var t=f(n[e],r);a[e]=t})),a}function a(n,t,r,i){var f=1<arguments.length&&void 0!==t?t:"",o=2<arguments.length&&void 0!==r?r:{},s=3<arguments.length&&void 0!==i?i:null;return"string"==typeof n||"boolean"==typeof n||"function"==typeof n?o["".concat(f)]=n:"number"==typeof n?o["".concat(f)]=null!=s?e(n,s):n:null===n?o["".concat(f)]=null:void 0===n||(Array.isArray(n)?n.forEach((function(e,n){a(e,"".concat(f,"[").concat(n,"]"),o,s)})):Object.keys(n).forEach((function(e){a(n[e],"".concat(f,".").concat(e),o,s)}))),o}function o(e,n,t,r){var f=3<arguments.length&&void 0!==r&&r,a=e[0];if(0!==a.length)if(r=a.match(/\\[[^\\]]*\\]/g),a=a.replace(/\\[.*/,""),1!==e.length||!f||r){if(r){var s=r.map((function(e){return parseInt(e.replace(/\\[|\\]/g,""),10)}));null!=n[a]&&Array.isArray(n[a])||(n[a]=[]);for(var c=n[a],l=0,u=0;u<s.length;u+=1){if(l=s[u],c.length<=l)for(var d=c.length;d<l-c.length+1;d+=1)c.push(void 0);u<s.length-1&&(Array.isArray(c[l])||(c[l]=[]),c=c[l])}return 1===e.length&&f?void(c[l]=void 0):1===e.length?void(c[l]=t):(null!=c[l]&&"object"===i(c[l])||(c[l]={}),void o(e.slice(1),c[l],t,f))}1!==e.length?(null==n[a]&&(n[a]={}),o(e.slice(1),n[a],t,f)):n[a]=t}else delete n[a]}function s(e){var n={};return Object.keys(e).forEach((function(t){var r=t.split(".").filter((function(e){return 0<e.length}));t=e[t],Array.isArray(t)?o(r,n,t.slice(-1)[0]):o(r,n,t)})),n}function c(e){for(var n=f(e),t=function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){var i=r.split(".").filter((function(e){return 0<e.length}));r=e[r],Array.isArray(r)?o(i,n,r.slice(-1)[0],t):o(i,n,r,t)}))},r=arguments.length,i=new Array(1<r?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.forEach((function(e){var n=e.added,r=e.removed;e=e.diff,null!=r&&t(r,!0),null!=n&&t(n),null!=e&&t(e)})),n}function l(e){var n={};return e.diff&&0<Object.keys(e.diff).length&&(n.diff=s(e.diff)),e.added&&0<Object.keys(e.added).length&&(n.added=s(e.added)),e.removed&&0<Object.keys(e.removed).length&&(n.removed=s(e.removed)),n}function u(e){var n={};return e.diff&&0<Object.keys(e.diff).length&&(n.diff=a(e.diff)),e.added&&0<Object.keys(e.added).length&&(n.added=a(e.added)),e.removed&&0<Object.keys(e.removed).length&&(n.removed=a(e.removed)),n}var d=function(){function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:8;(function(n){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")})(this),this.precision=n,this.reset()}return r=[{key:"toObj",value:function(){var e=this,n={};Object.keys(this.references).forEach((function(t){n[t]={basedOn:e.references[t].basedOn,diff:l(e.references[t].diff)}}));var t=this.diffs.map((function(e){return[e[0],e[1],l(e[2]),e[3]]}));return{baseReference:f(this.baseReference),diffs:t,references:n,precision:this.precision,lastReferenceName:this.lastReferenceName}}},{key:"setFromObj",value:function(e){var n={};Object.keys(e.references).forEach((function(t){n[t]={basedOn:e.references[t].basedOn,diff:u(e.references[t].diff)}})),this.references=n,this.baseReference=f(e.baseReference),this.precision=e.precision,this.diffs=e.diffs.map((function(e){return[e[0],e[1],u(e[2]),e[3]]})),this.lastReferenceName=e.lastReferenceName}},{key:"reset",value:function(){this.baseReference=null,this.references={},this.diffs=[],this.lastReferenceName="__base"}},{key:"setBaseReference",value:function(e){this.baseReference=f(e),this.lastReferenceName="__base"}},{key:"addReference",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"__base";null!=this.baseReference&&"__base"!==n||this.setBaseReference(e),"__base"!==n&&(this.references[n]={diff:this.getDiffToReference(e,t),basedOn:t},this.lastReferenceName=n)}},{key:"getReferenceChain",value:function(e,t){return"__base"===e||null==this.references[e]?t:this.getReferenceChain(this.references[e].basedOn,[this.references[e].diff].concat(n(t)))}},{key:"getReference",value:function(e){return e=this.getReferenceChain(e,[]),c.apply(void 0,[this.baseReference].concat(n(e)))}},{key:"getDiffToReference",value:function(e,t){return t=this.getReferenceChain(t,[]),function(e,t,r,i,f){i=3<arguments.length&&void 0!==i?i:null;var o=4<arguments.length&&void 0!==f&&f,s=(f=e,a(f=0<t.length?c.apply(void 0,[e].concat(n(t))):f,"",{},i)),l=a(r,"",{},i),u={},d={},h={};return Object.keys(s).forEach((function(e){void 0!==l[e]?s[e]!==l[e]&&(d[e]=o?[s[e],l[e]]:l[e]):h[e]=s[e]})),Object.keys(l).forEach((function(e){void 0===s[e]&&(u[e]=l[e])})),i={},0<Object.keys(d).length&&(i.diff=d),0<Object.keys(u).length&&(i.added=u),0<Object.keys(h).length&&(i.removed=h),i}(this.baseReference,t,e,this.precision)}},{key:"getObjFromDiffAndReference",value:function(e,t){return t=this.getReferenceChain(t,[]),e=[].concat(n(t),[e]),c.apply(void 0,[this.baseReference].concat(n(e)))}},{key:"add",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(n),n=this.getDiffToReference(n,t),this.diffs.push([e,t,n,r])}},{key:"addWithWorker",value:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.lastReferenceName,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;null==this.baseReference&&this.setBaseReference(n),this.startWorker(),null!=this.worker&&this.worker.postMessage([e,t,n,r])}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new Worker)}},{key:"getFromIndex",value:function(e){if(e>this.diffs.length||0===this.diffs.length)return null;r=3,e=(r=function(e){if(Array.isArray(e))return e}(n=this.diffs[e])||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,i,f=[],a=!0,o=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(f.push(r.value),!n||f.length!==n);a=!0);}catch(e){o=!0,i=e}finally{try{a||null==t.return||t.return()}finally{if(o)throw i}}return f}}(n,r)||t(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1];var n,r=r[2];return this.getObjFromDiffAndReference(r,e)}}],function(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,r),e;var r}(),h=new d;addEventListener("message",(function(e){e=(n=e.data).message;var n=n.payload;"reset"===e?((h=new d).baseReference=n.baseReference,h.references=n.references):"get"===e?postMessage({message:"cache",payload:{baseReferece:h.baseReference,references:h.references,diffs:h.diffs}}):"add"===e?h.add(n.now,n.state,n.reference,n.lastRecordTimeCount):"addReference"===e&&h.addReference(n.state,n.refName,n.basedOn)}))})();',"Worker",void 0,n.p+"figureone.worker.js")}function cs(t){return function(t){if(Array.isArray(t))return ds(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||fs(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function hs(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||fs(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fs(t,e){if(t){if("string"==typeof t)return ds(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ds(t,e):void 0}}function ds(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ps(t,e){if(e<1)return e;for(var n=e,r=!0,i=t[e][0];0<n&&r;)t[n-1][0]!==i?r=!1:--n;return n}function ms(t,e){for(var n=t[e][0],r=e,i=!0;i;)r!==t.length-1&&t[r+1][0]===n?r+=1:i=!1;return Math.max(r,e)}function ys(t,e,n,r){var i=2<arguments.length&&void 0!==n?n:0,o=3<arguments.length&&void 0!==r?r:t.length-1;return 0===t.length?[-1,-1]:e===(n=parseFloat(t[i][0]))?[i,i]:e<n?[-1,i]:e===(r=parseFloat(t[o][0]))?[o,o]:r<e?[o,-1]:(n=o-i)<2?[i,o]:(r=i+Math.floor(n/2),e===(n=parseFloat(t[r][0]))?[r,r]:e<n?ys(t,e,i,r):ys(t,e,r,o))}function vs(t,e,n,r,i){return n=2<arguments.length&&void 0!==n?n:0,r=3<arguments.length&&void 0!==r?r:t.length-1,((i=!(4<arguments.length&&void 0!==i)||i)?ps:ms)(t,r=ys(t,e,n,r)[1])}function gs(t,e,n,r,i){return n=2<arguments.length&&void 0!==n?n:0,r=3<arguments.length&&void 0!==r?r:t.length-1,((i=!(4<arguments.length&&void 0!==i)||i)?ps:ms)(t,r=ys(t,e,n,r)[0])}function bs(t,e){var n=null,r=null;return t.forEach((function(t){var i,o=gs(t,e);o<0||(i=t[o][0],(null==n||n<i)&&(n=i,r=t[o]))})),r}var ws=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.timeKeeper=e,this.initialize()}var e=[{key:"initialize",value:function(){this.notifications=new It,this.events={},this.eventsCache={},this.reset(),this.precision=8,this.stateTimeStep=1,this.audio=null,this.worker=null,this.pauseState=null,this.settings={pause:"freeze",play:"instant"},this.queueSeekTime=0,this.queueSeekId=null,this.timeUpdates=100}},{key:"timeStamp",value:function(){return this.timeKeeper.now()}},{key:"now",value:function(){return m((this.timeStamp()-this.videoToNowDelta)/1e3,8)}},{key:"getCurrentTime",value:function(){return"idle"!==this.state?this.now():this.currentTime}},{key:"getDeltaTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return(t=this.getCurrentTime()+t)>this.duration?this.duration:t<0?0:t}},{key:"setCurrentTime",value:function(t){this.currentTime=t,this.notifications.publish("timeUpdate",[t])}},{key:"setVideoToNowDeltaTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;this.videoToNowDelta=this.timeStamp()-1e3*t}},{key:"calcDuration",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=0,r=0,i=0,o=0,a=0;return Object.keys(this.events).forEach((function(e){0<(e=t.events[e]).list.length&&(n=Math.max(n,e.list[e.list.length-1][0]))})),Object.keys(this.eventsCache).forEach((function(e){0<(e=t.eventsCache[e]).list.length&&(r=Math.max(r,e.list[e.list.length-1][0]))})),0<this.states.diffs.length&&(i=hs(this.states.diffs[this.states.diffs.length-1],1)[0]),0<this.statesCache.diffs.length&&(o=hs(this.statesCache.diffs[this.statesCache.diffs.length-1],1)[0]),null==this.audio||isNaN(this.audio.duration)||(a=this.audio.duration),e?Math.max(r,o):Math.max(n,r,i,o,a)}},{key:"reset",value:function(){var t=this;this.states=new Bt(this.precision),this.statesCache=new Bt(this.precision),Object.keys(this.events).forEach((function(e){t.events[e].list=[]})),this.eventsCache={},this.stateIndex=-1,this.eventIndex={},this.stopTimeouts(),this.videoToNowDelta=0,this.state="idle",this.isAudioPlaying=!1,this.setCurrentTime(0),this.duration=0,this.reference="__base",this.lastRecordTimeCount=0,this.lastRecordTime=null,this.eventsToPlay=[],this.lastSeekTime=null,this.referenceIndex=0}},{key:"loadAudioTrack",value:function(t){var e=this;this.audio=t,this.audio.onloadedmetadata=function(){e.duration=e.calcDuration(),e.notifications.publish("durationUpdated",e.duration)},this.audio.oncanplaythrough=function(){e.notifications.publish("audioLoaded")},this.audio.addEventListener("pause",(function(){"playing"===e.state&&e.pausePlayback()})),this.audio.addEventListener("play",(function(){"idle"===e.state&&null==e.audioStartedCallback&&e.resumePlayback()})),t.addEventListener("playing",(function(){return e.audioStarted()}),!1),t.addEventListener("ended",(function(){return e.audioEnded()}),!1)}},{key:"loadEvents",value:function(t){var e=this,n=this.decodeEvents(t,!(1<arguments.length&&void 0!==arguments[1])||arguments[1]);Object.keys(n).forEach((function(t){null!=e.events[t]&&(e.events[t].list=n[t])})),this.duration=this.calcDuration(),this.notifications.publish("eventsLoaded"),this.notifications.publish("durationUpdated",this.duration)}},{key:"loadStates",value:function(t){this.states=this.decodeStates(t,!(1<arguments.length&&void 0!==arguments[1])||arguments[1],!(2<arguments.length&&void 0!==arguments[2])||arguments[2]),this.duration=this.calcDuration(),this.notifications.publish("statesLoaded"),this.notifications.publish("durationUpdated",this.duration)}},{key:"loadSavedData",value:function(t){this.loadStates(t.states,!0,!0),this.loadEvents(t.events,!0),this.notifications.publish("videoLoaded")}},{key:"encodeEvents",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e={},n=ut(this.events);return Object.keys(n).forEach((function(t){t.startsWith("_auto")||(e[t]=n[t].list)})),(t?kt:ut)(e)}},{key:"decodeEvents",value:function(t){return(1<arguments.length&&void 0!==arguments[1]&&!arguments[1]?ut:_t)(t)}},{key:"encodeStates",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.precision;return e=e?this.states.toObj():ut(this.states),t?kt(e,n):e}},{key:"decodeStates",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=t;e&&(r=_t(t)),n&&((i=new Bt).setFromObj(r),r=i);var i=new Bt;return i.diffs=r.diffs,i.baseReference=r.baseReference,i.references=r.references,i.precision=r.precision,i}},{key:"clearListOrDiffs",value:function(t,e,n){var r=vs(t,e);return e=gs(t,n),n=[],0<r&&(n=t.slice(0,r)),-1<e&&e+1<=t.length-1?[].concat(cs(n),cs(t.slice(e+1))):n}},{key:"clear",value:function(t,e){var n=this;Object.keys(this.events).forEach((function(r){(r=n.events[r]).list=n.clearListOrDiffs(r.list,t,e)})),this.states.diffs=this.clearListOrDiffs(this.states.diffs,t,e)}},{key:"startRecording",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this.state="recording",this.lastSeekTime=null,this.setVideoToNowDeltaTime(t),0<this.states.diffs.length&&this.setToTime(t,!0),this.states.precision=this.precision,0===t&&null==this.states.baseReference&&this.states.setBaseReference(this.figure.getState({precision:this.precision,ignoreShown:!0})),this.recordingStates=!!n,this.startWorker(),null!=this.worker&&this.worker.postMessage({message:"reset",payload:{baseReference:this.states.baseReference,references:this.states.references}}),this.eventsCache={},this.lastRecordTime=null,this.duration=this.calcDuration(),this.recordingStates&&this.queueRecordState(t%this.stateTimeStep),this.eventsToPlay=e,this.startEventsPlayback(t),e=this.startAudioPlayback(t),this.notifications.publish("recordingStarted"),this.startRecordingTime=t,this.startTimeUpdates(),e||this.pausePlayback()}},{key:"startStatesRecording",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.1;this.states.reset(),this.seek(0),this.figure.timeKeeper.setManualFrames(),this.startRecording(0,Object.keys(this.events),!0),this.autoFrame(t)}},{key:"autoFrame",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.1;"recording"===this.state?(this.figure.animateNextFrame(),this.figure.timeKeeper.frame(t),this.getCurrentTime()<=this.duration?setTimeout(this.autoFrame.bind(this,t),5):this.stopStatesRecording()):this.stopStatesRecording()}},{key:"startWorker",value:function(){null==this.worker&&(this.worker=new us,this.worker.addEventListener("message",this.parseMessage.bind(this)))}},{key:"parseMessage",value:function(t){t=(e=t.data).message;var e=e.payload;"cache"===t&&(this.statesCache=new Bt,this.statesCache.diffs=e.diffs,this.statesCache.baseReference=e.baseReference,this.statesCache.references=e.references,this.mergeEventsCache(),this.mergeStatesCache(),this.duration=this.calcDuration(),this.recordingStates&&(0<this.duration%1&&(t=this.states.diffs.length-1,t=(e=hs(this.states.diffs[t],3))[1],e=e[2],this.states.diffs.push([Math.ceil(this.duration),t,ut(e),0]),Math.ceil(this.duration)>this.duration&&(e=this.duration<=this.getCurrentTime(),this.duration=Math.ceil(this.duration),this.notifications.publish("durationUpdated",this.duration),e&&(this.setCurrentTime(this.duration),this.notifications.publish("timeUpdate",[this.duration])))),this.notifications.publish("recordingStatesComplete")),this.duration=this.calcDuration())}},{key:"addCurrentStateAsReference",value:function(){var t;"recording"===this.state&&(this.referenceIndex+=1,this.reference="ref".concat(this.referenceIndex),t=this.figure.getState({precision:this.precision,ignoreShown:!0}),null!=this.worker?this.worker.postMessage({message:"addReference",payload:{state:t,refName:this.reference,basedOn:"__base"}}):this.states.addReference(t,this.reference))}},{key:"getCacheStartTime",value:function(){var t=this,e=null;return 0<this.statesCache.diffs.length&&(e=this.statesCache.diffs[0][0]),Object.keys(this.eventsCache).forEach((function(n){0<(n=t.eventsCache[n]).list.length&&(n=hs(n.list[0],1)[0],e=null==e?n:Math.min(n,e))})),e}},{key:"getCacheEndTime",value:function(){return this.calcDuration(!0)}},{key:"getMergedCacheArray",value:function(t,e){var n=this.startRecordingTime,r=this.currentTime;if(null==n||0===r)return[];var i=gs(t,n);-1<i&&t[i][0]===n&&(i=ps(t,i)-1)<0&&(i=-1);var o=vs(t,r);return-1<o&&t[o][0]===r&&(o=ms(t,o)+1)>t.length-1&&(o=-1),n=[],r=[],0<=i&&(n=t.slice(0,i+1)),0<=o&&(r=t.slice(o)),[].concat(cs(n),cs(e),cs(r))}},{key:"mergeEventsCache",value:function(){var t=this,e={};Object.keys(this.events).forEach((function(t){e[t]=null})),Object.keys(this.eventsCache).forEach((function(t){e[t]=null})),Object.keys(e).forEach((function(e){var n=[];null!=t.eventsCache[e]&&(n=t.eventsCache[e].list);var r=[];null!=t.events[e]&&(r=t.events[e].list),0!==(n=t.getMergedCacheArray(r,n)).length&&(t.events[e].list=n)}))}},{key:"mergeStatesCache",value:function(){var t;!this.recordingStates||0!==(t=this.getMergedCacheArray(this.states.diffs,this.statesCache.diffs)).length&&(this.states.diffs=t,this.states.references=ut(this.statesCache.references))}},{key:"stopTimeouts",value:function(){this.timeKeeper.clearTimeout(this.timeoutID),this.timeKeeper.clearTimeout(this.timeUpdatesTimeoutID),this.timeoutID=null,this.timeUpdatesTimeoutID=null}},{key:"stopRecording",value:function(){this.setCurrentTime(this.getCurrentTime()),this.state="idle",this.stopTimeouts(),null!=this.worker&&this.worker.postMessage({message:"get"}),this.audio&&(this.audio.pause(),this.isAudioPlaying=!1),this.lastSeekTime=null,this.notifications.publish("recordingStopped")}},{key:"stopStatesRecording",value:function(){this.stopRecording(),this.figure.timeKeeper.endManualFrames()}},{key:"addEventType",value:function(t,e){this.events[t]={setOnSeek:!(2<arguments.length&&void 0!==arguments[2])||arguments[2],list:[],playbackAction:e},this.eventIndex[t]=-1}},{key:"recordState",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.getCurrentTime();(null==this.lastRecordTime||e>this.lastRecordTime)&&(this.lastRecordTime=e,this.lastRecordTimeCount=0),null!=this.worker&&this.worker.postMessage({message:"add",payload:{now:e,state:t,reference:this.reference,lastRecordTimeCount:this.lastRecordTimeCount}}),this.lastRecordTimeCount+=1,e>this.duration&&!1===this.figure.timeKeeper.manual&&(this.duration=e,this.notifications.publish("durationUpdated",this.duration))}},{key:"recordCurrentState",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getCurrentTime(),e=this.figure.getState({precision:this.precision,ignoreShown:!0});this.recordState(e,t)}},{key:"recordCurrentStateAsReference",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"__base",n=this.figure.getState({precision:this.precision,ignoreShown:!0});null!=this.worker&&this.worker.postMessage({message:"addReference",payload:{state:n,refName:t,basedOn:e}})}},{key:"recordEvent",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.getCurrentTime();null!=this.events[t]&&(null==this.eventsCache[t]&&(this.eventsCache[t]={list:[]}),(null==this.lastRecordTime||n>this.lastRecordTime)&&(this.lastRecordTime=n,this.lastRecordTimeCount=0),this.eventsCache[t].list.push([n,e,this.lastRecordTimeCount]),this.lastRecordTimeCount+=1,n>this.duration&&!1===this.figure.timeKeeper.manual&&(this.duration=n,this.notifications.publish("durationUpdated",this.duration)))}},{key:"queueRecordState",value:function(){function t(){"recording"===e.state&&(e.recordCurrentState(),e.queueRecordState(e.stateTimeStep-e.getCurrentTime()%e.stateTimeStep))}var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;0!==m(n,10)?this.timeoutID=this.timeKeeper.setTimeout((function(){t()}),m(1e3*n,10),"state",!0):t()}},{key:"save",value:function(){var t=(new Date).toISOString().split(".")[0].split("-").join("_"),e=window.location.pathname.split("/").slice(1,-1).join("_"),n={states:this.encodeStates(),events:this.encodeEvents()};Dt("".concat(t,"_").concat(e,".json"),JSON.stringify(n))}},{key:"show",value:function(){function t(t){return(t=(t=JSON.stringify(t,null,2)).replace(/\n/g,"<br>")).replace(/ /g,"&nbsp")}var e=window.open("about:blank","","_blank");e.document.write("<br><br>"),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("<br><br>"),e.document.write(t(this.events),"<br>"),e.document.write("<br><br>"),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("// ".concat("/".repeat(500),"<br>")),e.document.write("<br><br>"),e.document.write(t(this.states.diffs),"<br>"),e.document.write(t(this.states.references),"<br>")}},{key:"genAutoMouseEvents",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"figure",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]&&!arguments[2]?"".concat(t,".recorder.loadEventData('_autoCursorMove', [\n").concat(this.showEvent("cursorMove",e,2),"\n], false, 2, 2);"):"".concat(t,".recorder.loadEventData('_autoCursorMove', ").concat(this.encodeCursorEvent("cursorMove",e,e),", 'cursor', 2, 2);");return"\n".concat(t,".recorder.loadEventData('_autoCursor', [\n").concat(this.showEvent("cursor",e,2),",\n]);\n").concat(t,".recorder.loadEventData('_autoTouch', [\n").concat(this.showEvent("touch",e,2),",\n]);\n").concat(t,".recorder.loadEventData('_autoTouchElement', [\n").concat(this.showEvent("touchElement",e,2),",\n]);\n").concat(n,"\n ")}},{key:"showEvent",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=[];return this.events[t].list.forEach((function(t){t=(o=hs(t,2))[0];var i,o=o[1],a=Array.isArray(o)?(a="",i=[],o.forEach((function(t){"string"==typeof t?i.push("'".concat(t,"'")):i.push(m(t,e))})),i.join(", ")):o;r.push("".concat(Array(n+1).join(" "),"[").concat(m(t,4),", [").concat(a,"]]"))})),r.join(",\n")}},{key:"encodeCursorEvent",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:.01,i=[],o=this.events[t].list[0][0],a=0,s=null;return this.events[t].list.forEach((function(t){t=(l=hs(t,2))[0];var l=l[1],u=(t=m(t-o,e),l.map((function(t){return m(t,n)})));if(null==s)return s=u,a=t,void i.push.apply(i,[m(o,e)].concat(cs(u)));if(!(t<=a+r)){for(var c=!0,h=0;h<u.length;h+=1)u[h]!==s[h]&&(c=!1);if(!c){for(var f=Array(u.length),d=0;d<u.length;d+=1)f[d]=Math.round((u[d]-s[d])*Math.pow(10,n));i.push.apply(i,[Math.round(m(t-a,e)*Math.pow(10,e))].concat(f)),a=t,s=u.slice()}}})),JSON.stringify(i)}},{key:"decodeCursorEvent",value:function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:2,i=e[0],o=e[1],a=e[2],s=[],l=0,u=0;u<e.length;u+=3){var c=e[u]/Math.pow(10,n),h=e[u+1],f=e[u+2];0===u?s.push([i,[h,f]]):(h=o+h/Math.pow(10,r),f=a+f/Math.pow(10,r),s.push([i+l+c,[o=h,a=f]]),l+=c)}return s}},{key:"decodeEvent",value:function(t,e){for(var n=e[0],r=[],i=0,o=0;o<e.length;o+=3){var a=e[o],s=e[o+1],l=e[o+2];0===o?r.push([n,[s,l]]):(r.push([n+i+a,[s,l]]),i+=a)}return r}},{key:"loadEventData",value:function(t,e){var n,r=this,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:2,a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:2;i?!0===i?(n=this.events[t].list).push.apply(n,cs(this.decodeEvent(t,e))):"cursor"===i&&(i=this.events[t].list).push.apply(i,cs(this.decodeCursorEvent(t,e,o,a))):(e=e.map((function(t){return[r.convertTime(t[0]),t[1],0]})),(t=this.events[t].list).push.apply(t,cs(e)))}},{key:"seekToPercent",value:function(t){var e=this.calcDuration();this.seek(e*t)}},{key:"convertTime",value:function(t){var e;return"string"==typeof t?(e=t.split(":"),60*parseInt(e[0],10)+parseFloat(e[1])):t}},{key:"queueSeek",value:function(t){var e=this;this.queueSeekTime=t,this.figure.timeKeeper.clearTimeout(this.queueSeekId),this.queueSeekId=this.figure.timeKeeper.setTimeout((function(){e.seek(e.queueSeekTime)}),100)}},{key:"seek",value:function(t){this.figure.timeKeeper.clearTimeout(this.queueSeekId),this.queueSeekId=null,(t=this.convertTime(t))<0&&(t=0),"recording"===this.state?this.stopRecording():"playing"===this.state&&this.pausePlayback("freeze"),this.pauseState=null,this.setToTime(t),this.lastSeekTime=this.currentTime,this.figure.stop("freeze"),this.notifications.publish("seek",t)}},{key:"setToTime",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];0===t&&0<this.states.diffs.length?this.stateIndex=0:this.stateIndex=gs(this.states.diffs,t);var r,i,o,a,s,l=0,u=0;-1!==this.stateIndex&&(r=hs(this.states.diffs[this.stateIndex],4),l=r[0],u=r[3]),l===this.lastSeekTime&&!n||(o=i=0<l?l:t,a=[],s=[],Object.keys(this.events).forEach((function(t){var n=e.events[t];if(!1!==n.setOnSeek){var r=gs(n.list,i);if(-1!==r)for(var c=ms(n.list,gs(n.list,o)),h=r;h<=c;h+=1){var f=(d=hs(n.list[h],3))[0],d=d[2];!(-1===e.stateIndex||f<=l)||"slide"!==t&&"_autoSlide"!==t?(l<f||f===l&&u<d)&&s.push([t,h,f,d]):a.push([t,h,f,d])}}})),(t=function(t){return t.sort((function(t,e){return t[2]<e[2]||t[2]===e[2]&&t[3]<e[3]?-1:t[2]>e[2]||t[2]===e[2]&&t[3]>e[3]?1:0}))})(a),t(s),(t=function(t){t.forEach((function(t){t=(n=hs(t,2))[0];var n=n[1];e.setEvent(t,n)}))})(a),-1!==this.stateIndex&&this.setState(this.stateIndex),t(s),this.setCurrentTime(o),this.figure.animateNextFrame())}},{key:"setCursor",value:function(t){var e,n=this.getCursorState(t);null!=n&&(e=n.show,t=n.up,n=n.position,e&&t?this.figure.showCursor("up",n):e&&!1===t?this.figure.showCursor("down",n):this.figure.showCursor("hide"))}},{key:"getCursorState",value:function(t){if(null==this.events.touch||null==this.events.cursor||null==this.events.cursorMove)return null;var e,n,r,i,o,a,s=bs([this.events.cursor.list,this.events._autoCursor.list],t),l=bs([this.events.touch.list,this.events._autoTouch.list],t),u=bs([this.events.cursorMove.list,this.events._autoCursorMove.list],t),c=null,h=null,f=null,d=null,p=null;return null!=l&&(e=(n=hs(l,3))[0],t=(r=hs(n[1],3))[0],l=r[1],r=r[2],n=n[2],"down"===t?(c=!1,d=e,p=n,f=new Oe(l,r)):c=!0),null!=s&&(r=(a=hs(s,3))[0],s=(o=hs(a[1],3))[0],i=o[1],o=o[2],a=a[2],"show"===s?(h=!0,(null==d||d<r||r===d&&p<a)&&(d=r,p=a,f=new Oe(i,o))):h=!1),null!=u&&(i=(a=hs(u,3))[0],u=(o=hs(a[1],2))[0],o=o[1],a=a[2],(null==d||d<i||i===d&&p<a)&&(f=new Oe(u,o))),{show:null!=h&&h,up:null==c||c,position:null==f?new Oe(0,0):f}}},{key:"getEvents",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return null!=t&&0<t.length?t:Object.keys(this.events)}},{key:"startPlayback",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.currentTime||0,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1],r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];this.notifications.publish("startingPlayback"),this.lastSeekTime=null;var i=this.convertTime(e);(null==e||e>=this.duration)&&(this.seek(0),i=0),this.eventsToPlay=this.getEvents(r),r=this.getStateForTime(i),n&&null!=this.pauseState&&(r=this.pauseState),n=function(){function e(){t.state="playing",t.setCurrentTime(i),t.startTimeUpdates(),t.startEventsPlayback(i),t.figure.animateNextFrame(),!1===t.areEventsPlaying()&&!1===t.isAudioPlaying&&t.finishPlaying(),t.notifications.publish("playbackStarted")}null==t.pauseState?(t.setToTime(i,!0),i=t.currentTime):t.pauseState=null,t.setVideoToNowDeltaTime(i),i=t.getCurrentTime(),null!=t.audio?t.startAudioPlayback(i,e):e()},this.figure.setState(r,this.settings.play),this.figure.state.preparingToSetState?(this.state="preparingToPlay",this.notifications.publish("preparingToPlay"),this.figure.notifications.add("setState",n,1)):n()}},{key:"togglePlayback",value:function(){"recording"!==this.state&&("idle"!==this.state?this.pausePlayback():this.resumePlayback())}},{key:"getPlaySettings",value:function(){var t,e={how:"instant",maxDuration:6,velocity:{position:2,rotation:2*Math.PI/2,scale:1,opacity:.8,color:.8},allDurationsSame:!0,zeroDurationThreshold:1e-5,duration:0};return"string"==typeof this.settings.play?e.how=this.settings.play:e=ft({},e,this.settings.play),"dissolve"===e.how?(t={dissolveIn:.8,dissolveOut:.8,delay:.2},0===e.duration?e.duration=t:"number"==typeof e.duration?e.duration={dissolveOut:e.duration/10*4.5,dissolveIn:e.duration/10*4.5,delay:e.duration/10*1}:e.duration=ft({},t,e.duration)):null!=e.duration&&"number"!=typeof e.duration&&(e.duration=1),e}},{key:"resumePlayback",value:function(){this.startPlayback(this.currentTime,!0)}},{key:"audioStarted",value:function(){null!=this.audioStartedCallback&&(this.audioStartedCallback(),this.audioStartedCallback=null)}},{key:"audioEnded",value:function(){this.isAudioPlaying=!1,"playing"===this.state&&this.finishPlaying()}},{key:"startAudioPlayback",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=this.audio;if(null!=n){if(this.isAudioPlaying=!0,void 0===n.play())return!1;n.currentTime=this.convertTime(t),this.audioStartedCallback=e}return!0}},{key:"startTimeUpdates",value:function(){var t=this;this.timeUpdatesTimeoutID=this.timeKeeper.setTimeout((function(){t.setCurrentTime(t.getCurrentTime()),t.notifications.publish("timeUpdate",[t.getCurrentTime()]),t.startTimeUpdates()}),this.timeUpdates,"timeUpdates")}},{key:"startEventsPlayback",value:function(t){var e=this;this.eventsToPlay.forEach((function(n){var r,i;null!=e.events[n]&&0!==e.events[n].list.length&&(-1===(i=vs((r=e.events[n]).list,t))||(i=hs(r.list[i],1)[0]===t?ms(r.list,i)+1:i)>r.list.length-1?e.eventIndex[n]=-1:e.eventIndex[n]=i)}));var n=this.getNextEvent();null!=this.events[n]&&this.playbackEvent(n)}},{key:"getNextEvent",value:function(){var t=this,e="",n=null,r=null;return this.eventsToPlay.forEach((function(i){var o,a;null==t.eventIndex[i]||-1===t.eventIndex[i]||t.events[i].list.length<=t.eventIndex[i]||(o=(a=hs(t.events[i].list[t.eventIndex[i]],3))[0],a=a[2],(null==n||o<n||o===n&&a<r)&&(n=o,r=a,e=i))})),e}},{key:"playbackEvent",value:function(t){var e=this.eventIndex[t];if(0!==this.events[t].list.length){var n=m(this.events[t].list[e][0]-this.getCurrentTime(),8);if(1e-4<n)this.timeoutID=this.timeKeeper.setTimeout(this.playbackEvent.bind(this,t),m(Math.ceil(1e3*n),0),"event: ".concat(t));else{if(this.setEvent(t,e),this.figure.animateNextFrame(),e+1===this.events[t].list.length){if(!(this.eventIndex[t]=-1)===this.areEventsPlaying()&&!1===this.isAudioPlaying)return void this.finishPlaying()}else this.eventIndex[t]=e+1;null!=(e=this.getNextEvent())&&this.events[e]&&this.playbackEvent(e)}}}},{key:"areEventsPlaying",value:function(){for(var t=0;t<this.eventsToPlay.length;t+=1){var e=this.eventsToPlay[t];if(this.eventIndex[e]<this.events[e].list.length&&-1<this.eventIndex[e])return!0}return!1}},{key:"finishPlaying",value:function(){var t=this;if("recording"===this.state)return!1;if(this.areEventsPlaying())return!1;var e=this.duration-this.getCurrentTime();return.001<e?(this.timeoutID=this.timeKeeper.setTimeout((function(){t.finishPlaying()}),m(1e3*e,0),"finishPlaying"),!1):!this.isAudioPlaying&&(this.setCurrentTime(this.getCurrentTime()),this.stop(),!0)}},{key:"stop",value:function(){this.stopTimeouts(),this.audio&&(this.audio.pause(),this.isAudioPlaying=!1),this.state="idle",this.notifications.publish("playbackStopped")}},{key:"pausePlayback",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.settings.pause;this.notifications.publish("startingPause"),this.setCurrentTime(this.getCurrentTime()),this.pauseState=this.figure.getState({precision:this.precision,ignoreShown:!0}),this.stopTimeouts(),this.audio&&(this.state="preparingToPause",this.audio.pause(),this.isAudioPlaying=!1),this.figure.notifications.add("stopped",(function(){t.state="idle",t.notifications.publish("playbackStopped")}),1),this.figure.stop(e),this.figure.state.preparingToStop&&(this.notifications.publish("preparingToPause"),this.state="preparingToPause")}},{key:"setEvent",value:function(t,e){null!=(t=this.events[t])&&(this.figure.setDrawTimeout(.05),t.playbackAction(t.list[e][1],t.list[e][0]))}},{key:"loadVideoTrack",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){};fetch(t,{mode:"no-cors"}).then((function(t){return t.json()})).then((function(t){e.loadSavedData(t),n()})).catch((function(t){throw new Error("Recorder fetch and load error: ".concat(t))}))}},{key:"setState",value:function(t){t>this.states.diffs.length-1||null!=(t=this.states.getFromIndex(t))&&this.figure.setState(t)}},{key:"getState",value:function(t){return t>this.states.diffs.length-1?{}:this.states.getFromIndex(t)}},{key:"getStateForTime",value:function(t){return t=this.convertTime(t),t=0<this.states.diffs.length&&(0===t||t<=this.states.diffs[0][0])?0:gs(this.states.diffs,t),this.getState(t)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}(),xs=function(){function t(){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.location=new Oe(0,0),this.type="drawingObject"}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,[{key:"_dup",value:function(){return this}},{key:"setText",value:function(t){}},{key:"update",value:function(t){}},{key:"getCanvas",value:function(){}},{key:"drawWithTransformMatrix",value:function(t,e,n,r){}},{key:"getLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?this.location:this.getLocation().transformBy(t)}},{key:"getPointCountForAngle",value:function(){return 0}},{key:"updateVertices",value:function(t){}},{key:"updateBuffer",value:function(t,e){}},{key:"updateUniform",value:function(t,e){}},{key:"getUniform",value:function(t){}},{key:"change",value:function(t){}},{key:"_getStateProperties",value:function(){return[]}},{key:"_state",value:function(t){return Ci(this,this._getStateProperties(),t)}}]),t}();function Ss(t){return(Ss="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ts(t,e){return(Ts=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function As(t){return(As=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const ks=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ts(t,e)}(i,xs);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=As(e);return function(t,e){if(e&&("object"===Ss(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=As(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e,n){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"middle",a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"center";!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var s=r.call(this),l=document.getElementById(e);return l&&(s.element=l),s.id=e,s.location=n,s.yAlign=o,s.xAlign=a,s.parentDiv=t,s.show=!0,s.setBorder(),s.lastMatrix=[0,0,0,0,0,0,0,0,0],s.lastColor=[-1,-1,-1,-1],s}return t=[{key:"_dup",value:function(){var t=new i(this.parentDiv,this.id,this.location._dup(),this.yAlign,this.xAlign);return t.show=this.show,t.border=this.border.map((function(t){return t.map((function(t){return t._dup()}))})),t}},{key:"setBorder",value:function(){var t=this.parentDiv.getBoundingClientRect(),e=this.element.getBoundingClientRect(),n=e.left-t.left,r=n+e.width,i=e.top-t.top;t=i+e.height,(e=[]).push(new Oe(n,i)),e.push(new Oe(r,i)),e.push(new Oe(r,t)),e.push(new Oe(n,t)),this.border=[],this.border.push(e)}},{key:"getBoundaries",value:function(){var t=lr({x:{min:0,span:(o=this.parentDiv.getBoundingClientRect()).width},y:{min:o.height,span:-o.height},z:{min:-1,span:2}},{x:{min:-1,span:2},y:{min:-1,span:2},z:{min:-1,span:2}}),e=this.element.getBoundingClientRect(),n=e.left-o.left,r=n+e.width,i=e.top-o.top,o=i+e.height;return(e=[]).push(new Oe(n,i)),e.push(new Oe(r,i)),e.push(new Oe(r,o)),e.push(new Oe(n,o)),[e.map((function(e){return e.transformBy(t.matrix())}))]}},{key:"glToPixelSpace",value:function(t){var e=(t.x- -1)/2*this.parentDiv.clientWidth;return t=(1-t.y)/2*this.parentDiv.clientHeight,new Oe(e,t)}},{key:"change",value:function(t,e){var n=t;"string"==typeof t&&((n=document.createElement("div")).innerHTML=t),n instanceof HTMLElement&&(this.element.innerHTML="",this.element.appendChild(n),this.transformHtml(e))}},{key:"transformHtml",value:function(t){var e,n,r,i,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;this.show?(i=this.location.transformBy(t),e=this.glToPixelSpace(i),n=this.element.clientWidth,r=this.element.clientHeight,i=t=0,"center"===this.xAlign?t=-n/2:"right"===this.xAlign&&(t=-n),"middle"===this.yAlign?i=-r/2:"bottom"===this.yAlign&&(i=-r),t=e.x+t,i=e.y+i,(i="position: absolute; left: ".concat(t,"px; top: ").concat(i,"px; visibility: visible; opacity: ").concat(o,";"))!==this.element.getAttribute("style")&&this.element.setAttribute("style",i)):this.element.setAttribute("style","position: absolute; left: -10000px; top: -10000px; visibility: hidden; opacity: ".concat(o,";"))}},{key:"drawWithTransformMatrix",value:function(t,e,n){for(var r=!1,i=Zt(Jt(t.viewProjectionMatrix,e)),o=0;o<i.length;o+=1)m(i[o],8)!==this.lastMatrix[o]&&(r=!0);!r&&this.lastColor[3]===m(n[3],8)||(this.transformHtml(i,n[3]),this.lastMatrix=m(i,8),this.lastColor=m(n,8))}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function _s(t){return(_s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Os(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ps(t,e,n){return(Ps="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ms(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Es(t,e){return(Es=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ms(t){return(Ms=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Cs=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Es(t,e)}(i,xs);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Ms(e);return function(t,e){if(e&&("object"===_s(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ms(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{color:"uniform",dimension:2,normals:!1,light:null},o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{color:"uniform",light:null},a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"selector",s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"selector";return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),(e=r.call(this)).gl=t.gl,e.glPrimitive=e.gl.TRIANGLES,e.webgl=t,e.z=0,e.programIndex=e.webgl.getProgram(n,o),e.type="glPrimitive",e.attributes={},e.numVertices=0,e.uniforms={},e.texture=null,e.selectorProgramIndex=e.webgl.getProgram(a,s),e}return t=[{key:"showShaders",value:function(){it(this.webgl.programs[this.programIndex].vertexShader.src),it(this.webgl.programs[this.programIndex].fragmentShader.src)}},{key:"showSelectorShaders",value:function(){it(this.webgl.programs[this.selectorProgramIndex].vertexShader.src),it(this.webgl.programs[this.selectorProgramIndex].fragmentShader.src)}},{key:"getCanvas",value:function(){return this.gl.canvas}},{key:"setPrimitive",value:function(t){if("TRIANGLES"===t)this.glPrimitive=this.gl.TRIANGLES;else if("LINES"===t)this.glPrimitive=this.gl.LINES;else if("TRIANGLE_FAN"===t||"FAN"===t)this.glPrimitive=this.gl.TRIANGLE_FAN;else if("TRIANGLE_STRIP"===t||"STRIP"===t)this.glPrimitive=this.gl.TRIANGLE_STRIP;else if("POINTS"===t)this.glPrimitive=this.gl.POINTS;else if("LINE_LOOP"===t)this.glPrimitive=this.gl.LINE_LOOP;else{if("LINE_STRIP"!==t)throw new Error("Primitive type can only be ['TRIANGLES' | 'POINTS' | 'TRIANGLE_FAN' | 'TRIANGLE_STRIP' | 'LINES' | 'LINE_LOOP' | 'LINE_STRIP']. Input primitive type was: ".concat(t));this.glPrimitive=this.gl.LINE_STRIP}}},{key:"setZ",value:function(t){this.z=t}},{key:"addTextureToBuffer",value:function(t,e,n){function r(t){return 0==(t&t-1)}var i=this.texture,o=this.gl,a=this.webgl;null!=i&&(i=a.textures[i.id].index,o.activeTexture(o.TEXTURE0+i),o.bindTexture(o.TEXTURE_2D,t),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,1),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,e),r(e.width)&&r(e.height)?(o.generateMipmap(o.TEXTURE_2D),null!=n&&!0===n?(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.REPEAT),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.REPEAT)):(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE))):(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE)))}},{key:"updateTextureMap",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=this.texture;null!=e&&(null!=e.buffer&&(this.gl.deleteBuffer(e.buffer),e.buffer=this.gl.createBuffer()),0===t.length?this.createTextureMap(e.mapTo.left,e.mapTo.right,e.mapTo.bottom,e.mapTo.top,e.mapFrom.left,e.mapFrom.right,e.mapFrom.bottom,e.mapFrom.top):e.points=t,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e.buffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(e.points),this.gl.STATIC_DRAW))}},{key:"addTexture",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new En(0,0,1,1),r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new En(-1,-1,2,2),i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"a_vertex",o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],a=5<arguments.length&&void 0!==arguments[5]&&arguments[5],s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:null,l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:[0,0,1,.5];null==this.texture&&(this.texture={id:t,mapTo:Mn(r),mapFrom:Mn(n),repeat:a,src:t,points:[],buffer:this.gl.createBuffer(),type:"image",data:null,mapToBuffer:i}),this.onLoad=s;var u,c,h=this.texture,f=(s=this.gl,this.webgl);null!=h&&(this.updateTextureMap(o),!(h.id in f.textures)||h.id in f.textures&&null==f.textures[h.id].glTexture?(u=s.createTexture(),f.addTexture(h.id,u,h.type),s.activeTexture(s.TEXTURE0+f.textures[h.id].index),s.bindTexture(s.TEXTURE_2D,u),(o=h.src)&&null==h.data?(s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array(eo(l))),(c=new Image).src=o,this.state="loading",f.textures[h.id].state="loading",f.textures[h.id].onLoad.push(this.executeOnLoad.bind(this)),c.addEventListener("load",(function(){h.data=c,e.addTextureToBuffer(u,h.data,h.repeat),f.onLoad(h.id),e.state="loaded",f.textures[h.id].state="loaded"}))):null!=h.data&&this.addTextureToBuffer(u,h.data,h.repeat)):h.id in f.textures&&("loading"===f.textures[h.id].state?(this.state="loading",f.textures[h.id].onLoad.push(this.executeOnLoad.bind(this))):this.state="loaded"))}},{key:"createTextureMap",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:1,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,s=e-t,l=r-n,u=o-i,c=(7<arguments.length&&void 0!==arguments[7]?arguments[7]:1)-a,h=this.texture;if(null!=h){var f=this.attributes[h.mapToBuffer];if(null==f)throw new Error("FigureOne mapToAttribute buffer ('".concat(h.mapToBuffer,"') does not exist. Available attributes: ").concat(JSON.stringify(Object.keys(this.attributes)),"."));if(null!=h){h.points=[];for(var d=0;d<f.data.length;d+=f.size){var p=f.data[d],m=(f.data[d+1]-n)/l;h.points.push((p-t)/s*u+i),h.points.push(m*c+a)}}}}},{key:"addVertices",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"STATIC";this.points=t,this.addAttribute("a_vertex",e,t,"FLOAT",!1,0,0,n)}},{key:"addVertices3",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"STATIC";this.points=t,this.addAttribute("a_vertex",3,t,"FLOAT",!1,0,0,e)}},{key:"addNormals",value:function(t){this.addAttribute("a_normal",3,t,"FLOAT",!1,0,0,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"STATIC")}},{key:"addColors",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"STATIC";e?this.addAttribute("a_color",4,t,"UNSIGNED_BYTE",!0,0,0,n):this.addAttribute("a_color",4,t,"FLOAT",!1,0,0,n)}},{key:"addAttribute",value:function(t,e,n){var r,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"FLOAT",o=4<arguments.length&&void 0!==arguments[4]&&arguments[4],a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,l=this.gl,u=l.STATIC_DRAW;if("DYNAMIC"===(7<arguments.length&&void 0!==arguments[7]?arguments[7]:"STATIC")&&(u=l.DYNAMIC_DRAW),"FLOAT"===i)r=l.FLOAT;else if("UNSIGNED_BYTE"===i)r=l.UNSIGNED_BYTE;else if("BYTE"===i)r=l.BYTE;else if("SHORT"===i)r=l.SHORT;else{if("UNSIGNED_SHORT"!==i)throw new Error('GLObject addAttribute usage needs to be FLOAT, BYTE, SHORT, UNSIGNED_BYTE or UNSIGNED_SHORT - received: "'.concat(i,'"'));r=l.UNSIGNED_SHORT}if(this.attributes[t]={buffer:null,size:e,type:r,normalize:o,stride:a,offset:s,usage:u,data:n},e=n.length/e,0!==this.numVertices&&e!==this.numVertices)throw new Error("Figure One Error: Adding GL attribute ".concat(t," with wrong length (").concat(e," vertices) when previously defined attributes used ").concat(this.numVertices," vertices"));0===this.numVertices&&(this.numVertices=e),"a_vertex"===t&&(this.points=n),this.fillBuffer(t,n)}},{key:"fillBuffer",value:function(t,e){var n,r=this.gl,i=(o=this.attributes[t]).type,o=o.usage;i===r.FLOAT?n=new Float32Array(e):i===r.UNSIGNED_BYTE?n=new Uint8Array(e):i===r.BYTE?n=new Int8Array(e):i===r.SHORT?n=new Int16Array(e):i===r.UNSIGNED_SHORT&&(n=new Uint16Array(e)),this.attributes[t].buffer=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,this.attributes[t].buffer),r.bufferData(r.ARRAY_BUFFER,n,o)}},{key:"executeOnLoad",value:function(){null!=this.onLoad&&this.onLoad()}},{key:"resetTextureBuffer",value:function(){var t=this.texture,e=this.webgl,n=this.gl;t&&(null!=e.textures[t.id].glTexture&&(n.activeTexture(n.TEXTURE0+e.textures[t.id].index),n.bindTexture(n.TEXTURE_2D,null),e.textures[t.id].glTexture=null),null!=t.buffer&&(n.deleteBuffer(t.buffer),t.buffer=null))}},{key:"resetBuffers",value:function(){var t=this,e=this.gl;Object.keys(this.attributes).forEach((function(n){e.deleteBuffer(t.attributes[n].buffer),t.attributes[n].buffer=null})),this.attributes={},this.resetTextureBuffer()}},{key:"updateVertices",value:function(t){this.points=t,this.updateAttribute("a_vertex",t)}},{key:"updateVertices3",value:function(t){this.points=t,this.updateAttribute("a_vertex",t)}},{key:"updateAttribute",value:function(t,e){this.gl.deleteBuffer(this.attributes[t].buffer),this.attributes[t].buffer=null,this.fillBuffer(t,e),this.attributes[t].data=e,this.numVertices=this.attributes[t].data.length/this.attributes[t].size,"a_vertex"===t&&(this.points=e)}},{key:"_getStateProperties",value:function(){return function(t){if(Array.isArray(t))return Os(t)}(t=Ps(Ms(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Os(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Os(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var t}},{key:"getUniform",value:function(t){return this.uniforms[t].value}},{key:"addUniform",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"FLOAT",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;this.uniforms[t]={value:Array(e).fill(0),method:this["uploadUniform".concat(e.toString()).concat(n[0].toLowerCase()).concat(n.endsWith("VECTOR")?"v":"")].bind(this)},null!=r&&this.updateUniform(t,r)}},{key:"uploadUniform1f",value:function(t,e){this.gl.uniform1f(t,this.uniforms[e].value[0])}},{key:"uploadUniform2f",value:function(t,e){this.gl.uniform2f(t,this.uniforms[e].value[0],this.uniforms[e].value[1])}},{key:"uploadUniform3f",value:function(t,e){this.gl.uniform3f(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2])}},{key:"uploadUniform4f",value:function(t,e){this.gl.uniform4f(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2],this.uniforms[e].value[3])}},{key:"uploadUniform1fv",value:function(t,e){this.gl.uniform1fv(t,this.uniforms[e].value)}},{key:"uploadUniform2fv",value:function(t,e){this.gl.uniform2fv(t,this.uniforms[e].value)}},{key:"uploadUniform3fv",value:function(t,e){this.gl.uniform3fv(t,this.uniforms[e].value)}},{key:"uploadUniform4fv",value:function(t,e){this.gl.uniform4fv(t,this.uniforms[e].value)}},{key:"uploadUniform1iv",value:function(t,e){this.gl.uniform1iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform2iv",value:function(t,e){this.gl.uniform2iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform3iv",value:function(t,e){this.gl.uniform3iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform4iv",value:function(t,e){this.gl.uniform4iv(t,new Int32Array(this.uniforms[e].value))}},{key:"uploadUniform1i",value:function(t,e){this.gl.uniform1i(t,this.uniforms[e].value[0])}},{key:"uploadUniform2i",value:function(t,e){this.gl.uniform2i(t,this.uniforms[e].value[0],this.uniforms[e].value[1])}},{key:"uploadUniform3i",value:function(t,e){this.gl.uniform3i(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2])}},{key:"uploadUniform4i",value:function(t,e){this.gl.uniform4i(t,this.uniforms[e].value[0],this.uniforms[e].value[1],this.uniforms[e].value[2],this.uniforms[e].value[3])}},{key:"updateUniform",value:function(t,e){this.uniforms[t].value=Array.isArray(e)?e:[e]}},{key:"drawWithTransformMatrix",value:function(t,e,n){var r=this,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:this.numVertices,o=4<arguments.length&&void 0!==arguments[4]&&arguments[4],a=this.gl,s=this.webgl,l=o?s.useProgram(this.selectorProgramIndex):s.useProgram(this.programIndex);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),"2D"!==t.style?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),Object.keys(this.attributes).forEach((function(t){var e,n,i,s,u,c;o&&"a_vertex"!==t||(e=(c=r.attributes[t]).buffer,n=c.size,i=c.type,s=c.stride,u=c.offset,c=c.normalize,a.enableVertexAttribArray(l[t]),a.bindBuffer(a.ARRAY_BUFFER,e),a.vertexAttribPointer(l[t],n,i,c,s,u))})),null!=l.u_directionalLight&&a.uniform3fv(l.u_directionalLight,Ae(t.light.directional).normalize().toArray()),null!=l.u_lightWorldPosition&&a.uniform3fv(l.u_lightWorldPosition,Ae(t.light.point).toArray()),null!=l.u_ambientLight&&a.uniform1f(l.u_ambientLight,t.light.ambient),null!=l.u_worldInverseTranspose&&a.uniformMatrix4fv(l.u_worldInverseTranspose,!1,be(e)),null!=l.u_worldViewProjectionMatrix&&a.uniformMatrix4fv(l.u_worldViewProjectionMatrix,!1,Zt(Jt(t.viewProjectionMatrix,e))),null!=l.u_worldMatrix&&a.uniformMatrix4fv(l.u_worldMatrix,!1,Zt(e)),null!=l.u_projectionMatrix&&a.uniformMatrix4fv(l.u_projectionMatrix,!1,Zt(t.projectionMatrix)),null!=l.u_viewMatrix&&a.uniformMatrix4fv(l.u_viewMatrix,!1,Zt(t.viewMatrix)),Object.keys(this.uniforms).forEach((function(t){(0,r.uniforms[t].method)(l[t],t)})),a.uniform1f(l.u_z,this.z),a.uniform4f(l.u_color,n[0],n[1],n[2],n[3]),null!=(t=this.texture)&&!1===o?(n=a.FLOAT,a.enableVertexAttribArray(l.a_texcoord),a.bindBuffer(a.ARRAY_BUFFER,t.buffer),a.vertexAttribPointer(l.a_texcoord,2,n,!1,0,0),a.uniform1i(l.u_use_texture,1),s=s.textures[t.id].index,a.uniform1i(l.u_texture,s)):a.uniform1i(l.u_use_texture,0),a.drawArrays(this.glPrimitive,0,i),t&&a.disableVertexAttribArray(l.a_texcoord),Object.keys(this.attributes).forEach((function(t){a.disableVertexAttribArray(l[t])}))}},{key:"getPointCountForAngle",value:function(){return 0<arguments.length&&void 0!==arguments[0]||Math.PI,this.numVertices}},{key:"getPointCountForLength",value:function(t){return this.numVertices}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function js(t){return function(t){if(Array.isArray(t))return Rs(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Rs(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Rs(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rs(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Bs(t,e,n){return"normals"===(2<arguments.length&&void 0!==n?n:"points")?t.map((function(t){return t._dup()})):t.map((function(t){return t.add(e)}))}function Fs(t,e,n){n=2<arguments.length&&void 0!==n?n:"points";var r=e.matrix();return"normals"===n&&(r=Zt(be(r))),t.map((function(t){return t.transformBy(r)}))}function Is(t,e,n){var r=2<arguments.length&&void 0!==n?n:"points";if(null==e.along)return[];var i=0,o=(n=[1,0,0],ft({},{num:1},e));"y"===o.along?n=[0,1,0]:"x"===o.along?n=[1,0,0]:"z"===o.along?n=[0,0,1]:"number"==typeof o.along?(i=o.along,n=Ke(1,o.along).toArray()):(Array.isArray(o.along)||o.along instanceof Oe)&&(n=Ae(o.along));var a=Ae(n).normalize();null==o.step&&(n=hr(t),o.step=Math.abs(n.height/Math.sin(i)));for(var s=[],l=1;l<o.num+1;l+=1)!function(e){var n=o.step*e;s=[].concat(js(s),js("points"===r?t.map((function(t){return t.add(a.scale(n))})):t.map((function(t){return t._dup()}))))}(l);return s}function Ds(t,e,n){n=2<arguments.length&&void 0!==n?n:"points";var r=ft({},{num:1,step:Math.PI/4,center:[0,0],axis:[0,0,1]},e);r.center=Ae(r.center);var i=[],o=r.center;"normals"===n&&(o=Ae([0,0,0]));for(var a=1;a<r.num+1;a+=1)!function(e){var n=(new Qe).translate(-o.x,-o.y).rotate(e*r.step,Ae(r.axis)).translate(o.x,o.y).matrix();i=[].concat(js(i),js(t.map((function(t){return t.transformBy(n)}))))}(a);return i}function Ls(t,e,n){var r=2<arguments.length&&void 0!==n?n:"points",i={},o=0,a=ke(t);return null==e?a:(t=[],t=Array.isArray(e)?e:[e],i[0]=0,t.forEach((function(t,e){var n;i["".concat(e+1)]=a.length,"string"==typeof t?i[t]=a.length:(n="to",null!=(e=ft({},{start:o,end:"end",original:!0},t)).along&&(n=e.along),t=function(t,e,n,r){var i=[],o=(e=r["".concat(e)],"end"===n?t.length:r["".concat(n)]);null==o&&(o=t.length);for(var a=e;a<o;a+=1)i.push(t[a]._dup());return i}(a,e.start,e.end,i),!1===e.original&&(o=a.length),a=[].concat(js(a),js(function(t,e,n,r){var i=3<arguments.length&&void 0!==r?r:"points";if("linear"===e||"x"===e||"y"===e||"z"===e||"number"==typeof e||Array.isArray(e)||e instanceof Oe)return Is(t,n,i);if("to"===e){var o=n.to;if(null==o)return t;if(o instanceof Oe)return Bs(t,o,i);if(o instanceof Qe)return Fs(t,o,i);if(Array.isArray(o)){var a=function(e){return Array.isArray(e)&&"number"==typeof e[0]||e instanceof Oe?Bs(t,Ae(e),i):Array.isArray(e)&&"string"==typeof e[0]||e instanceof Qe?Fs(t,rn(e),i):null};if(null!=(r=a(o)))return r;for(var s=[],l=0;l<o.length;l+=1){var u=a(o[l]);null!=u&&s.push.apply(s,js(u))}return s}if(Array.isArray(o)&&0===o.length)return t}return"rotation"===e?Ds(t,n,i):t}(t,n,e,r))))})),js(a.slice(o)))}function zs(t){return Ls([0,0,0],t).length}function Ws(t){return(Ws="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ns(t,e){return(Ns=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function qs(t,e){if(e&&("object"===Ws(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}function Hs(t){return(Hs=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Us=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ns(t,e)}(r,Cs);var t,e,n=(t=r,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,r=Hs(t);return qs(this,e?(n=Hs(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))});function r(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new En(-1,-1,2,2),o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new En(0,0,1,1),a=4<arguments.length&&void 0!==arguments[4]&&arguments[4];return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),(t=""!==e?n.call(this,t,"withTexture","withTexture"):n.call(this,t,"simple","simple")).points=[],t.copy=[],t.addVertices([]),""!==e&&t.addTexture(e,i,o,"a_vertex",[],a),qs(t)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,[{key:"getPointCountForAngle",value:function(){return 0<arguments.length&&void 0!==arguments[0]||Math.PI,this.numVertices}},{key:"getPointCountForLength",value:function(t){return this.numVertices}},{key:"change",value:function(t){var e=t.points,n=t.drawType,r=t.copy,i=t.texture;t=this.numVertices,null!=e&&(this.vertices=e),null!=n&&(this.glPrimitive="LINES"===n?this.gl.LINES:"STRIP"===n?this.gl.TRIANGLE_STRIP:"FAN"===n?this.gl.TRIANGLE_FAN:this.gl.TRIANGLES),null!=r&&(this.copy=r);for(var o=null!=this.vertices?Ls(this.vertices,this.copy):[new Oe(0,0)],a=Array(2*o.length),s=0;s<o.length;s+=1)a[2*s]=o[s].x,a[2*s+1]=o[s].y;this.updateVertices(a),null!=this.texture&&this.numVertices!==t&&this.updateTextureMap(),null!=i&&(null!=i.mapTo&&(i.mapTo=Mn(i.mapTo)),null!=i.mapFrom&&(i.mapFrom=Mn(i.mapFrom)),this.texOptions=ft({},this.texOptions,i),this.updateTextureMap())}}]),r}();function Ks(t){return(Ks="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Vs(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Qs(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gs(t,e,n){return(Gs="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Js(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ys(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xs(t,e)}function Xs(t,e){return(Xs=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function $s(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Js(t);return function(t,e){if(e&&("object"===Ks(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Js(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function Js(t){return(Js=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Zs(t){return function(t){if(Array.isArray(t))return tl(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Qs(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qs(t,e){if(t){if("string"==typeof t)return tl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tl(t,e):void 0}}function tl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function el(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function nl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function rl(t,e,n){return e&&nl(t.prototype,e),n&&nl(t,n),t}var il=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(el(this,t),e instanceof t)return this.family=e.family,this.style=e.style,this.size=e.size,this.weight=e.weight,this.opacity=e.opacity,this.setColor(e.color),this.width=e.width,this.descent=e.descent,this.midDescent=e.midDescent,this.maxDescent=e.maxDescent,this.midAscent=e.midAscent,void(this.maxAscent=e.maxAscent);e=ft({},{family:"Times New Roman",style:"normal",size:1,weight:"200",color:null,opacity:1,width:1,descent:.08,midDescent:.2,maxDescent:.5,midAscent:.95,maxAscent:1.4},e),this.family=e.family,this.style=e.style,this.size=e.size,this.weight=e.weight,this.opacity=e.opacity,this.setColor(e.color),this.width=e.width,this.descent=e.descent,this.midDescent=e.midDescent,this.maxDescent=e.maxDescent,this.midAscent=e.midAscent,this.maxAscent=e.maxAscent}return rl(t,[{key:"setColor",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.color=null==t?t:t.slice()}},{key:"definition",value:function(){var t=null==(t=this.color)?t:t.slice();return{family:this.family,style:this.style,size:this.size,weight:this.weight,color:t,opacity:this.opacity,width:this.width,descent:this.descent,midDescent:this.midDescent,maxDescent:this.maxDescent,midAscent:this.midAscent,maxAscent:this.maxAscent}}},{key:"setFontInContext",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;t.font="".concat(this.style," ").concat(this.weight," ").concat(this.size*e,"px ").concat(this.family)}},{key:"setColorInContext",value:function(t,e){var n=this.color;null!=n?(n=[].concat(Zs(n.slice(0,3)),[null!=e?e[3]:1]),t.fillStyle=no(n)):null!=e&&(t.fillStyle=no(e))}},{key:"_dup",value:function(){return new t({family:this.family,style:this.style,size:this.size,weight:this.weight,color:this.color,opacity:this.opacity})}}]),t}(),ol=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Oe(0,0),r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new il).definition(),o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"left",a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"baseline",s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;el(this,t),this.location=Ae(n)._dup(),this.locationAligned=this.location._dup(),this.text=r.slice(),this.font=new il(i),this.xAlign=o,this.yAlign=a,this.lastDraw=null,this.lastDrawRect=new En(0,0,1,1),Array.isArray(e)?this.drawContext2D=e:this.drawContext2D=[e],this.touchBorder=s,this.onClick=l}return rl(t,[{key:"measureAndAlignText",value:function(){this.measureText(),this.alignText()}},{key:"calcBorderAndBounds",value:function(){this.calcBounds(),this.calcBorder(),this.calcTouchBorder()}},{key:"setText",value:function(t){"string"==typeof t?this.text=t.slice():(null!=t.location&&(t.location=Ae(t.location)),ft(this,t)),this.measureAndAlignText(),this.calcBorderAndBounds()}},{key:"setFont",value:function(t){t=ft({},this.font.definition(),t),this.font=new il(t),this.measureAndAlignText()}},{key:"_dup",value:function(){return new this.constructor(this.drawContext2D,this.location,this.text,this.font.definition(),this.xAlign,this.yAlign)}},{key:"measureText",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.drawContext2D[0].ctx,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:20/this.font.size;this.font.setFontInContext(t,e);var n=t.font.match(/[^ ]*px/),r=null!=n?parseFloat(n[0])/2:t.measureText("a").width,i=r*this.font.maxAscent,o=r*this.font.descent,a=/[gjyqp@Q(){}[\]|]/g;return"Times New Roman"===this.font.family&&"italic"===this.font.style&&(a=/[gjyqp@Q(){}[\]|f]/g),n=this.text.match(/[acemnorsuvwxz*gyqp: ]/g),Array.isArray(n)&&n.length===this.text.length&&(i=r*this.font.midAscent),n=this.text.match(/[;,$]/g),Array.isArray(n)&&0<n.length&&(o=r*this.font.midDescent),a=this.text.match(a),Array.isArray(a)&&0<a.length&&(o=r*this.font.maxDescent),t=t.measureText(this.text).width,this.measure={ascent:i/e,descent:o/e,width:t/e},this.measure}},{key:"alignText",value:function(){var t=this.location._dup();"center"===this.xAlign?t.x-=this.measure.width/2:"right"===this.xAlign&&(t.x-=this.measure.width),"bottom"===this.yAlign?t.y+=this.measure.descent:"middle"===this.yAlign?t.y+=this.measure.descent-(this.measure.ascent+this.measure.descent)/2:"top"===this.yAlign&&(t.y-=this.measure.ascent),this.locationAligned=t._dup()}},{key:"calcBounds",value:function(){this.bounds=new En(this.locationAligned.x,this.locationAligned.y-this.measure.descent,this.measure.width,this.measure.ascent+this.measure.descent)}},{key:"getBoundary",value:function(t){if(null==t)return this.textBorder;var e=[];return this.textBorder.forEach((function(n){e.push(n.transformBy(t))})),e}},{key:"calcBorder",value:function(){this.textBorder=[new Oe(this.bounds.left,this.bounds.bottom),new Oe(this.bounds.right,this.bounds.bottom),new Oe(this.bounds.right,this.bounds.top),new Oe(this.bounds.left,this.bounds.top)]}},{key:"calcTouchBorder",value:function(){cr(this.touchBorder)?this.textBorderBuffer=fr(this.textBorder,this.touchBorder):this.textBorderBuffer=this.touchBorder}}]),t}(),al=function(){Ys(e,ol);var t=$s(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Oe(0,0),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new il).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"left",s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"baseline",l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;return el(this,e),(u=t.call(this,n,r,i,o,a,s,l,u)).measureAndAlignText(),u.calcBorderAndBounds(),u}return e}(),sl=function(){Ys(e,ol);var t=$s(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Oe(0,0),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new il).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new Oe(0,0),s=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null,c=8<arguments.length&&void 0!==arguments[8]&&arguments[8],h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:0,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:0;return el(this,e),(u=t.call(this,n,r,i,o,"left","baseline",l,u)).offset=Ae(a),u.inLine=s,u.followOffsetY=c,u.lSpace=h,u.rSpace=f,u.measureAndAlignText(),u.calcBorderAndBounds(),u}return rl(e,[{key:"alignText",value:function(){var t=this.location._dup();this.locationAligned=t.add(this.offset)}},{key:"_dup",value:function(){return new e(this.drawContext2D,this.location,this.text,this.font.definition(),this.offset,this.inLine,this.touchBorder,this.onClick,this.followOffsetY,this.rSpace,this.lSpace)}}]),e}(),ll=function(){Ys(e,sl);var t=$s(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Oe(0,0),i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:(new il).definition(),a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:new Oe(0,0),s=!(5<arguments.length&&void 0!==arguments[5])||arguments[5],l=6<arguments.length?arguments[6]:void 0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:0,c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:null,h=9<arguments.length&&void 0!==arguments[9]&&arguments[9],f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:0,d=11<arguments.length&&void 0!==arguments[11]?arguments[11]:0;return el(this,e),(d=t.call(this,n,r,i,o,a,s,u,c,h,f,d)).line=l,d}return rl(e,[{key:"_dup",value:function(){return new e(this.drawContext2D,this.location,this.text,this.font.definition(),this.offset,this.inLine,this.line,this.touchBorder,this.onClick,this.followOffsetY,this.lSpace,this.rSpace)}}]),e}(),ul=function(){Ys(e,xs);var t=$s(e);function e(n){var r;return el(this,e),r=t.call(this),Array.isArray(n)?r.drawContext2D=n:r.drawContext2D=[n],r.lastDrawTransform=[1,0,0,0,1,0,0,0,1],r.text=[],r.fixColor=!1,r}return rl(e,[{key:"loadText",value:function(t){this.calcScalingFactor(),this.layoutText()}},{key:"getCanvas",value:function(){return this.drawContext2D[0<arguments.length&&void 0!==arguments[0]?arguments[0]:0].canvas}},{key:"setTextLocations",value:function(){}},{key:"click",value:function(t,e){this.text.forEach((function(n){null!=n.onClick&&as(t,n.textBorderBuffer)&&e.exec(n.onClick,e)}))}},{key:"calcScalingFactor",value:function(){var t,e=1;0<this.text.length&&(t=this.text[0].font.size,this.text.forEach((function(e){0<e.font.size&&e.font.size<t&&(t=e.font.size)})),e=20/t),this.scalingFactor=e}},{key:"setText",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;this.clear(),this.text[e].setText(t),this.setBorder(),this.setTouchBorder()}},{key:"_dup",value:function(){return new e(this.drawContext2D)}},{key:"setFont",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.clear(),null===e)for(var n=0;n<this.text.length;n+=1)this.text[n].setFont(t);else this.text[e].setFont(t);this.layoutText()}},{key:"setOpacity",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.clear(),null===e)for(var n=0;n<this.text.length;n+=1)this.setFont({opacity:t},n);else this.setFont({opacity:t},e)}},{key:"setColor",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(!this.fixColor)if(null===e)for(var n=0;n<this.text.length;n+=1)this.text[n].font.color=t.slice();else this.text[e].font.color=t.slice()}},{key:"layoutText",value:function(){this.setTextLocations(),this.text.forEach((function(t){t.calcBorderAndBounds()})),this.setBorder(),this.setTouchBorder()}},{key:"setBorder",value:function(){var t=this;this.textBorder=[],this.text.forEach((function(e){t.textBorder.push(e.textBorder)}))}},{key:"setTouchBorder",value:function(){var t=this;this.textBorderBuffer=[],this.text.forEach((function(e){t.textBorderBuffer.push(e.textBorderBuffer)}))}},{key:"drawWithTransformMatrix",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[1,1,1,1],r=this.drawContext2D[0],i=this.drawContext2D[0].ctx;i.save();var o=this.scalingFactor,a=r.canvas.offsetWidth/2,s=r.canvas.offsetHeight/2,l=[a,0,r.canvas.offsetWidth/2,0,s,r.canvas.offsetHeight/2,0,0,1],u=(a=ce(u=Jt(t.viewProjectionMatrix,e),[0,0,0,1]),t=wr(l,[(r=[(s=Jt([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],u))[0]/a[3],s[1]/a[3],s[3]/a[3],s[4]/a[3],s[5]/a[3],s[7]/a[3],s[12]/a[3],s[13]/a[3],s[15]/a[3]])[0],-r[1],r[2],-r[3],r[4],-1*r[5],0,0,1]),(e=wr(t,[1/o,0,0,0,1/o,0,0,0,1]))[0]);s=e[3],a=e[1],l=e[4],r=e[2],t=e[5],i.transform(u,s,a,l,r,t),this.lastDrawTransform=e.slice();var c=n.slice();this.text.forEach((function(t){t.lastDraw={x:t.locationAligned.x*o,y:t.locationAligned.y*-o,width:t.bounds.width*o,height:t.bounds.height*o},t.font.setFontInContext(i,o),t.font.setColorInContext(i,c),i.fillText(t.text,t.locationAligned.x*o,t.locationAligned.y*-o)})),i.restore()}},{key:"clear",value:function(){var t=this.drawContext2D[0].ctx,e=this.lastDrawTransform;t.save(),t.transform(e[0],e[3],e[1],e[4],e[2],e[5]),this.text.forEach((function(e){var n,r,i,o;null!=e.lastDraw&&(n=(o=e.lastDraw).x,r=o.y,i=o.width,o=o.height,t.clearRect(n-+i,r+.5*o,3*i,2*-o),e.lastDraw=null)})),t.restore()}},{key:"_getStateProperties",value:function(){return Zs(Gs(Js(e.prototype),"_getStateProperties",this).call(this))}}]),e}(),cl=function(){Ys(e,ul);var t=$s(e);function e(){return el(this,e),t.apply(this,arguments)}return rl(e,[{key:"loadText",value:function(t){var e=this,n=t.text;Array.isArray(n)||(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor);var r=[];n.forEach((function(n){var i,o,a,s,l,u="string"==typeof n?n:(i=n.font,c=n.location,o=n.xAlign,a=n.yAlign,l=n.touchBorder,s=n.onClick,n.text),c=(n=null==c?new Oe(0,0):Ae(c),t.font);null!=i&&(c=i),null!=l&&Array.isArray(l)&&!cr(l)&&(l=Vs(vr(l),1)[0]),c=ft({},t.font,c),r.push(new al(e.drawContext2D,n,u,c,o||t.xAlign,a||t.yAlign,l||t.defaultTextTouchBorder,s))})),this.text=r,this.calcScalingFactor(),this.layoutText()}},{key:"_dup",value:function(){var t=new e(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.layoutText(),t}}]),e}();function hl(t,e){var n=1<arguments.length&&void 0!==e?e:new Oe(0,0),r=0,i=0;return t.forEach((function(t){var e;t.location=n.add(t.offset).add(t.lSpace),t.inLine&&(n=t.followOffsetY?t.location.add(t.measure.width+t.rSpace,0):t.location.add(t.measure.width+t.rSpace,-t.offset.y),e=t.location.y+t.measure.ascent,t=t.location.y-t.measure.descent,r<e&&(r=e),t<i&&(i=t))})),{width:+n.x,minY:i,maxY:r}}function fl(t,e,n,r,i,o){var a=new Oe(0,0);"center"===e?a.x-=r/2:"right"===e&&(a.x-=r),"bottom"===n?a.y-=i:"middle"===n?a.y+=-i-(o-i)/2:"top"===n&&(a.y-=o),t.forEach((function(t){t.locationAligned=t.location.add(a)}))}var dl=function(){Ys(e,ul);var t=$s(e);function e(){return el(this,e),t.apply(this,arguments)}return rl(e,[{key:"loadText",value:function(t){var e=this,n=t.text;Array.isArray(n)||(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor);var r=[];n.forEach((function(n){var i,o,a,s,l,u,c,h;"string"==typeof n?o=n:(c=n.font,f=n.offset,h=n.inLine,u=n.touchBorder,a=n.onClick,i=n.followOffsetY,s=n.lSpace,l=n.rSpace,o=n.text,null!=u&&Array.isArray(u)&&!cr(u)&&(u=Vs(vr(u),1)[0])),n=null==f?new Oe(0,0):Ae(f);var f=t.font;null!=c&&(f=c),null==(f=ft({},t.font,f)).color&&null!=t.color&&(f.color=t.color),r.push(new sl(e.drawContext2D,new Oe(0,0),o,f,n,h,u||t.defaultTextTouchBorder,a,i,s,l))})),this.text=r,this.xAlign=t.xAlign,this.yAlign=t.yAlign,this.calcScalingFactor(),this.layoutText()}},{key:"setText",value:function(t){this.text[1<arguments.length&&void 0!==arguments[1]?arguments[1]:1].setText(t),this.layoutText()}},{key:"setTextLocations",value:function(){var t=(n=hl(this.text)).width,e=n.minY,n=n.maxY;fl(this.text,this.xAlign,this.yAlign,t,e,n)}},{key:"_dup",value:function(){var t=new e(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.xAlign=this.xAlign,t.yAlign=this.yAlign,t.layoutText(),t}}]),e}(),pl=function(){Ys(e,ul);var t=$s(e);function e(){return el(this,e),t.apply(this,arguments)}return rl(e,[{key:"loadText",value:function(t){var e=this,n=t.text;"string"==typeof n&&(n=[n]),null!=t.fixColor&&(this.fixColor=t.fixColor),this.modifiers=t.modifiers||{},this.lines=[];var r=[],i={style:"italic"};null!=t.defaultAccent&&(i=ft({},i,t.defaultAccent)),n.forEach((function(n,o){var a,s,l,u=t.justify,c=t.lineSpace,h=t.font;"string"!=typeof n?(a=n.font,s=n.justify,l=n.lineSpace,d=n.text,null!=a&&(h=ft({},{color:t.color},t.font,a)),null!=l&&(c=l),null!=s&&(u=s)):d=n;var f=[],d=(n=Vs(Lt(d,"|","/"),2))[0],p=n[1];d.forEach((function(n,a){var s,l,u=n,c=h,d=new Oe(0,0),m=!0,y=!1,v=0,g=0;a%2===p&&(null!=(n=null!=e.modifiers[n]?e.modifiers[n]:{text:n,font:i}).text&&(u=n.text),null!=n.font&&(c=ft({},h,n.font)),null!=n.inLine&&(m=n.inLine),null!=n.offset&&(d=n.offset),null!=n.touchBorder&&null!=(l=n.touchBorder)&&Array.isArray(l)&&!cr(l)&&(l=Vs(vr(l),1)[0]),null!=n.onClick&&(s=n.onClick),null!=n.followOffsetY&&(y=n.followOffsetY),null!=n.lSpace&&(g=n.lSpace),null!=n.rSpace&&(v=n.rSpace)),v=new ll(e.drawContext2D,new Oe(0,0),u,c,d,m,o,l||t.defaultTextTouchBorder,s,y,g,v),r.push(v),f.push(v)})),e.lines.push({justify:u,space:c,text:f,width:0})})),this.text=r,this.xAlign=t.xAlign,this.yAlign=t.yAlign,this.calcScalingFactor(),this.layoutText()}},{key:"setText",value:function(t){this.text[1<arguments.length&&void 0!==arguments[1]?arguments[1]:0].setText(t),this.layoutText()}},{key:"setTextLocations",value:function(){var t=(n=this.createLines()).width,e=n.minY,n=n.maxY;fl(this.text,this.xAlign,this.yAlign,t,e,n)}},{key:"createLines",value:function(){var t=0,e=0,n=0,r=0;return this.lines.forEach((function(i,o){0<o&&0<i.text.length?r-=i.space:0<o&&0===i.text.length&&(r-=i.space/3);var a=(s=hl(i.text,new Oe(0,r))).width,s=(o=s.minY,s.maxY);e=o<e?o:e,t=t<s?s:t,n=n<a?a:n,i.width=a})),this.lines.forEach((function(t){var e=new Oe(0,0);"center"===t.justify?e.x+=n/2-t.width/2:"right"===t.justify&&(e.x+=n-t.width),t.text.forEach((function(t){t.location=t.location.add(e)}))})),{width:n,minY:e,maxY:t}}},{key:"_dup",value:function(){var t=new dl(this.drawContext2D);return t.text=this.text.map((function(t){return t._dup()})),t.scalingFactor=this.scalingFactor,t.xAlign=this.xAlign,t.yAlign=this.yAlign,t.layoutText(),t}}]),e}();const ml=function(){function t(){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.requestNextAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,this.reset()}var e,n,r,i;function o(t){return r.apply(this,arguments)}function a(t,e){return i.apply(this,arguments)}return e=t,n=[{key:"reset",value:function(){this.syncNowTimeout=100,this.drawQueue=[],this.nextDrawQueue=[],this.lastDrawTime=null,this.idCounter=0,this.speed=1,this.lastTime=performance.now(),this.nowTime=this.lastTime,this.clearTimeouts(),null!=this.syncNowTimer&&this.clearTimeout(this.syncNowTimer),this.timeoutId=null,this.updateSyncNow=!0,this.manual=!1,this.animateOnFrame=!1}},{key:"clearTimeouts",value:function(){var t=this;null!=this.timers&&Object.keys(this.timers).map((function(e){return t.timers[e]})).forEach((function(t){null!=t.id&&clearTimeout(t.id)})),this.timers={}}},{key:"getWhen",value:function(t){return"now"===t?this.now():"prevFrame"===t?this.lastDrawTime:"syncNow"===t?this.syncNow():null}},{key:"syncNow",value:function(){var t=this;return this.updateSyncNow&&(this.updateSyncNow=!1,this.synchronizedNow=this.now(),this.syncNowTimer=this.setTimeout((function(){t.updateSyncNow=!0}),this.syncNowTimeout)),this.synchronizedNow}},{key:"updateNow",value:function(){var t,e;this.manual||(e=(t=performance.now())-this.lastTime,this.nowTime+=e*this.speed,this.lastTime=t)}},{key:"now",value:function(){return this.manual||this.updateNow(),this.nowTime}},{key:"setSpeed",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;if(e<=0)throw new Error("speedFactor ".concat(e," is not greater than 0"));Object.keys(this.timers).forEach((function(n){var r=t.timers[n];n=(r.timeout-t.nowTime)/e,null!=r.id&&clearTimeout(r.id),t.manual||(r.id=setTimeout(r.callback,n))})),this.speed=e}},{key:"setManualFrames",value:function(){this.updateNow(),this.manual=!0}},{key:"endManualFrames",value:function(){this.manual=!1,this.lastTime=performance.now()}},{key:"frame",value:function(t){t=this.nowTime+1e3*t,this.incrementTimers(t),this.nowTime=t,this.lastTime=t,this.animateOnFrame=!0,this.animateNextFrame()}},{key:"incrementTimers",value:function(t){if(null==this.timers||0===Object.keys(this.timers).length)return 0;for(var e=Object.keys(this.timers),n=null,r=0;r<e.length;r+=1){var i=e[r],o=this.timers[i];o.timeout<=t&&(null==n||o.timeout<n.timer.timeout||o.timeout===n.timer.timeout&&n.timer.stateTimer)&&(n={id:i,timer:o})}if(null==n)return 0;var a=(s=n.timer).callback,s=s.timeout;return this.nowTime=s,this.lastTime=s,a(),this.draw(),delete this.timers[n.id],this.incrementTimers(t)}},{key:"setTimeout",value:(i=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return this.manual||this.updateNow(),this.timers["".concat(this.idCounter)]={timeout:this.nowTime+e,description:n,stateTimer:r,id:null,callback:t},this.manual||(this.timers["".concat(this.idCounter)].id=setTimeout(t,e/this.speed)),this.idCounter+=1,this.idCounter-1},a.toString=function(){return i.toString()},a)},{key:"clearTimeout",value:(r=function(t){var e;null==t||null!=(e=this.timers["".concat(t)])&&(null!=e.id&&clearTimeout(e.id),delete this.timers["".concat(t)])},o.toString=function(){return r.toString()},o)},{key:"draw",value:function(){this.animationId=null,this.clearTimeout(this.syncNowTimer),this.updateSyncNow=!0,this.drawQueue=this.nextDrawQueue,this.nextDrawQueue=[],this.updateNow();for(var t=.001*this.now(),e=0;e<this.drawQueue.length;e+=1)this.drawQueue[e](t);this.drawQueue=[],this.lastDrawTime=1e3*t}},{key:"queueNextFrame",value:function(t){this.nextDrawQueue.push(t),1===this.nextDrawQueue.length&&this.animateNextFrame()}},{key:"animateNextFrame",value:function(){if(this.manual)return this.animateOnFrame&&null==this.animationId&&(this.animateOnFrame=!1,this.animationId=this.requestNextAnimationFrame.call(window,this.draw.bind(this))),void(this.animateOnFrame=!1);null==this.animationId&&(this.animationId=this.requestNextAnimationFrame.call(window,this.draw.bind(this)))}},{key:"_dup",value:function(){return this}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(e.prototype,n),t}();function yl(t){return(yl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function vl(t,e,n){return(vl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=xl(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function gl(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&bl(t,e)}function bl(t,e){return(bl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function wl(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=xl(t);return function(t,e){if(e&&("object"===yl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=xl(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function xl(t){return(xl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Sl(t){return function(t){if(Array.isArray(t))return kl(t)}(t)||Al(t)||Tl(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tl(t,e){if(t){if("string"==typeof t)return kl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kl(t,e):void 0}}function Al(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function kl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ol(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Pl(t,e,n){return e&&Ol(t.prototype,e),n&&Ol(t,n),t}function El(t,e){if(0===e.length)return t;for(var n=[],r=0;r<t.length;r+=1)for(var i=0;i<e.length;i+=1)n.push(Jt(t[r],e[i]));return n}function Ml(t,e){var n=[];return 0===e.length?t.map((function(t){return t._dup()})):(t.forEach((function(t){e.forEach((function(e){n.push(rn(t).transform(rn(e)))}))})),0<n.length?n:t.map((function(t){return t._dup()})))}var Cl=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Qe,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:mt("element_"),i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new ml;_l(this,t),this.name=r,this.uid=(1e18*Math.random()).toString(36),this.uniqueColor=null,this.isShown=!0,this.simple=!1,this.transform=e._dup(),this.dependantTransform=!1,this.fnMap=new X,this.notifications=new It(this.fnMap),this.isMovable=!1,this.isTouchable=!1,this.touchScale=new Oe(1,1,1),this.isInteractive=void 0,this.color=[1,1,1,1],this.lastDrawOpacity=1,this.dimColor=[.5,.5,.5,1],this.defaultColor=this.color.slice(),this.opacity=1,this.setTransformCallback=null,this.beforeDrawCallback=null,this.afterDrawCallback=null,this.internalSetTransformCallback=null,this.scene=null,this.parentTransform=[new Qe],this.lastDrawPulseTransform=this.transform._dup(),this.onClick=null,this.custom={},this._custom={},this.customState={},this.parent=n,this.drawPriority=1,this.stateProperties=[],this.lastDrawTime=0,this.cancelSetTransform=!1,this.onAdd=null,this.timeKeeper=i,this.pulseDefault={scale:2,rotation:null,translation:null,angle:0,duration:1,frequency:0,xAlign:"center",yAlign:"middle",centerOn:"this",num:1,space:"figure",done:null,progression:"sinusoid",when:"syncNow"},this.move={bounds:null,plane:new He([0,0,0],[0,0,1]),maxVelocity:5,freely:{zeroVelocityThreshold:1e-4,deceleration:5,callback:null,bounceLoss:.5},type:"translation",element:null},this.scenarios={},this.fnMap.add("_elementPulseSettingsTransformMethod",(function(t,e,n){return"scale"===n?null==e?(new Qe).translate(0,0).scale(t,t).translate(0,0):(new Qe).translate(-e.x,-e.y).scale(t,t).translate(e.x,e.y):"rotation"===n?(new Qe).translate(-e.x,-e.y).rotate(t).translate(e.x,e.y):(e=t*Math.cos(n),n=t*Math.sin(n),(new Qe).translate(e,n))})),this.fnMap.add("tools.math.easeinout",x),this.fnMap.add("tools.math.linear",b),this.fnMap.add("tools.math.sinusoid",A),this.fnMap.add("tools.math.sinusoidAbs",k),this.fnMap.add("tools.math.triangle",w),this.pulseSettings={time:1,frequency:.5,A:1,B:.5,C:0,progression:"tools.math.sinusoid",num:1,delta:new Oe(0,0),transformMethod:"_elementPulseSettingsTransformMethod",callback:function(){},allowFreezeOnStop:!1,type:"scale"},this.state={isBeingMoved:!1,isMovingFreely:!1,isChanging:!1,movement:{previousTime:null,velocity:0},isPulsing:!1,pulse:{startTime:null},preparingToStop:!1},this.interactiveLocation=new Oe(0,0),this.animationFinishedCallback=null,this.animations=new Il({element:this,finishedCallback:this.animationFinished.bind(this),timeKeeper:this.timeKeeper}),this.tieToHTML={element:null,scale:"fit",updateOnResize:!0},this.isRenderedAsImage=!1,this.unrenderNextDraw=!1,this.renderedOnNextDraw=!1,this.pulseTransforms=[],this.frozenPulseTransforms=[],this.copyTransforms=[],this.drawTransforms=[]}return Pl(t,[{key:"animationFinished",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"animation";this.fnMap.exec(this.animationFinishedCallback),this.notifications.publish("animationFinished",t)}},{key:"animateNextFrame",value:function(){null!=this.figure&&this.figure.animateNextFrame(!0,this.name)}},{key:"setScene",value:function(t){this.scene=new Pi(t)}},{key:"setProperties",value:function(t){ht({except:1<arguments.length&&void 0!==arguments[1]?arguments[1]:[]},this,t)}},{key:"_getStateProperties",value:function(t){return null==(t=t.ignoreShown)&&(t=!1),this.isShown||t?["animations","color","opacity","dimColor","defaultColor","transform","_custom","scene","isShown","isMovable","isTouchable","state","pulseSettings","setTransformCallback","move","notifications","pulseTransforms","frozenPulseTransforms","customState"].concat(Sl(this.stateProperties)):["isShown","transform","customState"]}},{key:"_getStatePropertiesMin",value:function(){return this.isShown?["color","transform","isShown"]:["isShown"]}},{key:"_state",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.notifications.publish("getState");var e=t.returnF1Type;return(e=null==e||e)?{f1Type:"de",state:this.getPath()}:(t=ft({},t,{returnF1Type:!0})).min?Ci(this,this._getStatePropertiesMin(),t):Ci(this,this._getStateProperties(t),t)}},{key:"stateSet",value:function(){this.notifications.publish("setState")}},{key:"setFigure",value:function(t){null!=(this.figure=t)&&(this.recorder=t.recorder,this.animationFinishedCallback=t.animationFinished,this.timeKeeper=t.timeKeeper,this.animations.timeKeeper=t.timeKeeper,this.animations.recorder=t.recorder),this.isTouchable&&this.setTouchable(),this.isMovable&&this.setMovable(),this.notifications.publish("setFigure")}},{key:"setTimeDelta",value:function(t){"animating"===this.animations.state&&this.animations.setTimeDelta(t),this.state.isPulsing&&null!=this.state.pulse.startTime&&(this.state.pulse.startTime+=t),null!=this.state.movement.previousTime&&(this.state.movement.previousTime+=t)}},{key:"getRootElement",value:function(){return null!=this.parent?this.parent.getRootElement():null}},{key:"getScene",value:function(){return null!=this.scene?this.scene:null!=this.parent?this.parent.getScene():null}},{key:"getDrawToFigureTransformDef",value:function(){return null!=this.parent?[].concat(Sl(this.getTransform().def),Sl(this.parent.getDrawToFigureTransformDef())):this.transform.def}},{key:"getLocalToFigureTransformDef",value:function(){return null!=this.parent?this.parent.getDrawToFigureTransformDef():[]}},{key:"getLocalToFigureTransform",value:function(){return null!=this.parent?new Qe(this.getLocalToFigureTransformDef()):new Qe}},{key:"getFigureTransform",value:function(){return new Qe(this.getDrawToFigureTransformDef())}},{key:"updateHTMLElementTie",value:function(t){var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y;null==(e="string"==typeof this.tieToHTML.element?document.getElementById(this.tieToHTML.element):e)||null!=(h=this.getScene())&&(n=h.right-h.left,m=h.top-h.bottom,r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),c=this.tieToHTML.window,o=i.width/i.height,a=n/m,s=r.width/r.height,l=c.width/c.height,y=(f=new Oe(r.left-i.left,r.top-i.top)).add(new Oe(r.width,r.height)),u=this.spaceTransformMatrix("pixel","figure"),h=f.transformBy(u),f=(t=y.transformBy(u)).x-h.x,y=h.y-t.y,u=h.add(new Oe(f/2,-y/2)),t=this.tieToHTML.scale.trim().toLowerCase(),f=h=1,y=n/c.width,m/=c.height,t.endsWith("em")&&(h=(c=parseFloat(t))*(p=parseFloat(getComputedStyle(e).fontSize))*(d=n/.2)/i.width,f=c*p*d/a/i.height),t.endsWith("px")&&(p=parseFloat(t),f=1<l?(h=(d=p/i.width)*y,d*o/a*y):(h=(p/=i.height)/o*a*m,p*m)),"stretch"===t&&(h=r.width/i.width*y,f=r.height/i.height*m),"max"!==t&&"fit"!==t||(m=new Oe(r.height/i.height/o*a*m,r.height/i.height*m),y=new Oe(r.width/i.width*y,r.width/i.width*o/a*y),f="max"===t&&l<s||"fit"===t&&s<l?(h=y.x,y.y):(h=m.x,m.y)),this.setScale(h,f),this.setPosition(u.x-h*(this.tieToHTML.window.left+this.tieToHTML.window.width/2),u.y-f*(this.tieToHTML.window.bottom+this.tieToHTML.window.height/2)))}},{key:"setFirstTransform",value:function(t){}},{key:"clearFrozenPulseTransforms",value:function(){this.frozenPulseTransforms=[]}},{key:"freezePulseTransforms",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];(t&&0===this.pulseTransforms.length||!t&&0<this.pulseTransforms.length)&&(this.frozenPulseTransforms=this.pulseTransforms.map((function(t){return t._dup()})))}},{key:"animateToState",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i={};(this.isShown!==t.isShown&&1===this.opacity||1!==this.opacity)&&(i.isShown=t.isShown),io(this.color,t.color,.001)||(i.color=t.color);var o=rn(t.transform);this.transform.isWithinDelta(o,.001)||!1!==this.dependantTransform&&!1!==n||(i.transform=o);var a,s=null;return n=0,0<Object.keys(i).length&&(a=ft({},e,{target:i}),s=this.animations.scenario(a)),o=null,this.arePulseTransformsSame(t,.001)||(i=this.pulseTransforms.map((function(t){return t._dup()})),0===this.pulseTransforms.length&&(i=this.frozenPulseTransforms.map((function(t){return t._dup()}))),0===(a=0===(a=t.pulseTransforms.map(rn)).length&&0<t.frozenPulseTransforms.length?t.frozenPulseTransforms.map(rn):a).length&&0<i.length&&(a=[i[0].identity()]),o=this.animations.pulseTransform(ft({},e,{start:i,target:a}))),null==s&&null==o||this.animations.new().inParallel([s,o]).start(r),null!=s&&(n=Math.max(n,s.getTotalDuration()||0)),null!=o?Math.max(n,o.getTotalDuration()||0):n}},{key:"dissolveInToState",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.8,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return!1===t.isShown?0:(this.transform=rn(t.transform),this.color=t.color.slice(),this.frozenPulseTransforms=[],t.pulseTransforms.forEach((function(t){return e.frozenPulseTransforms.push(rn(t))})),this.show(),this.animations.new().opacity({target:t.opacity,start:.001,duration:n}).trigger({callback:function(){e.frozenPulseTransforms=[]}}).start(r),n)}},{key:"isStateSame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],r=this.getPath();if(-1<n.indexOf(r))return!0;if(this.isShown!==t.isShown||.001<Math.abs(this.opacity-t.opacity))return!1;if(!io(this.color,t.color,.001))return!1;if(!this.transform.isWithinDelta(rn(t.transform),.001))return!1;if(e)return!!this.arePulseTransformsSame(t,.001);if(t.pulseTransforms.length!==this.pulseTransforms.length)return!1;for(var i=0;i<this.pulseTransforms.length;i+=1)if(!this.pulseTransforms[i].isWithinDelta(rn(t.pulseTransforms[i]),.001))return!1;return!0}},{key:"arePulseTransformsSame",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.001,n=[],r=Ml([this.transform._dup()],t.pulseTransforms);if(r=Ml(r,t.frozenPulseTransforms),n=Ml([this.transform._dup()],this.pulseTransforms),(n=Ml(n,this.frozenPulseTransforms)).length!==r.length)return!1;for(var i=0;i<n.length;i+=1)if(!n[i].isWithinDelta(r[i],e))return!1;return!0}},{key:"getDrawTransforms",value:function(t){return 0<this.copyTransforms.length&&(t=Ml(t,this.copyTransforms)),0<this.pulseTransforms.length&&(t=Ml(t,this.pulseTransforms)),0<this.frozenPulseTransforms.length?Ml(t,this.frozenPulseTransforms):t}},{key:"getDrawTransformsMatrix",value:function(t){return 0<this.copyTransforms.length&&(t=El(t,this.copyTransforms.map((function(t){return t.matrix()})))),0<this.pulseTransforms.length&&(t=El(t,this.pulseTransforms.map((function(t){return t.matrix()})))),0<this.frozenPulseTransforms.length?El(t,this.frozenPulseTransforms.map((function(t){return t.matrix()}))):t}},{key:"exec",value:function(t){var e,n;Array.isArray(t)?(n=(e=function(t){if(Array.isArray(t))return t}(n=t)||Al(n)||Tl(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],e=e.slice(1)):n=t,null!=this[n]&&"function"==typeof this[n]&&(void 0===e?this[n]():this[n].apply(this,Sl(e)))}},{key:"getElement",value:function(){return this}},{key:"getElements",value:function(){return[this]}},{key:"highlight",value:function(){this.undim()}},{key:"setPosition",value:function(t){var e="number"==typeof t?new Oe(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0):Ae(t);(t=this.transform._dup()).updateTranslation(e),this.setTransform(t)}},{key:"setRotation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=this.transform._dup();n.updateRotation(t,e),this.setTransform(n)}},{key:"setScale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;e="number"==typeof t?"number"==typeof e?new Oe(t,e,2<arguments.length&&void 0!==arguments[2]?arguments[2]:1):new Oe(t,t,t):Ae(t),(t=this.transform._dup()).updateScale(e),this.setTransform(t)}},{key:"setTransform",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.notifications.publish("beforeSetTransform",[t]),this.cancelSetTransform?this.cancelSetTransform=!1:this.transform=t,this.transformSet(e)}},{key:"transformSet",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];this.internalSetTransformCallback&&this.fnMap.exec(this.internalSetTransformCallback,this.transform),t&&(this.notifications.publish("setTransform",[this.transform]),this.fnMap.exec(this.setTransformCallback,this.transform)),this.animateNextFrame()}},{key:"nextMovingFreelyFrame",value:function(t){var e,n;this.notifications.publish("beforeMoveFreely"),this.state.isMovingFreely&&(null!=this.state.movement.previousTime?("number"!=typeof this.state.movement.velocity&&(this.state.movement.velocity=Ae(this.state.movement.velocity)),n=t-this.state.movement.previousTime,e=this.decelerate(n),this.state.movement.velocity=e.velocity,this.state.movement.previousTime=t,("number"==typeof this.state.movement.velocity&&0===m(this.state.movement.velocity)||"number"!=typeof this.state.movement.velocity&&this.state.movement.velocity.isZero())&&("number"==typeof this.state.movement.velocity?this.state.movement.velocity=0:this.state.movement.velocity=new Oe(0,0,0),this.stopMovingFreely("complete")),n=this.transform._dup(),this.updateTransformWithMovement(e.value,n),this.setTransform(n)):this.state.movement.previousTime=t)}},{key:"clear",value:function(){}},{key:"willStartAnimating",value:function(){return!!this.animations.willStartAnimating()}},{key:"setColor",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.color=null!=t?t.slice():[0,0,0,0],e&&(this.defaultColor=this.color.slice()),this.notifications.publish("color"),this.animateNextFrame()}},{key:"dim",value:function(){this.setColor(this.dimColor,!1),this.animateNextFrame()}},{key:"setDimColor",value:function(t){this.dimColor=null!=t?t.slice():[0,0,0,0]}},{key:"undim",value:function(){this.setColor(this.defaultColor,!1),this.animateNextFrame()}},{key:"setOpacity",value:function(t){this.opacity=t,this.animateNextFrame()}},{key:"getScenarioTarget",value:function(t){var e,n,r;return null==t?{}:(null!=(t="string"==typeof t?t in this.scenarios?this.scenarios[t]:{}:t).transform&&(e=rn(t.transform)),null!=t.position&&(e=null==e?this.transform._dup():e).updateTranslation(Ae(t.position)),null!=t.translation&&(e=null==e?this.transform._dup():e).updateTranslation(Ae(t.translation)),null!=t.rotation&&(e=null==e?this.transform._dup():e).updateRotation(t.rotation),null!=t.scale&&(e=null==e?this.transform._dup():e).updateScale(_e(t.scale)),{transform:e,color:n=t.color?t.color.slice():n,isShown:r=null!=t.isShown?t.isShown:r})}},{key:"setScenario",value:function(t){null!=(t=this.getScenarioTarget(t)).transform&&this.setTransform(t.transform._dup()),null!=t.isShown&&(t.isShown?this.show():this.hide()),null!=t.color&&this.setColor(t.color)}},{key:"setScenarios",value:function(t){var e=this;t=t,(t=Array.isArray(t)?t:[t]).forEach((function(t){null!=e.scenarios[t]&&e.setScenario(t)}))}},{key:"saveScenario",value:function(t){var e=this.getCurrentScenario(1<arguments.length&&void 0!==arguments[1]?arguments[1]:["transform","color","isShown"]);0<Object.keys(e).length&&(this.scenarios[t]=e)}},{key:"getCurrentScenario",value:function(){var t=this,e={};return(0<arguments.length&&void 0!==arguments[0]?arguments[0]:["transform","color","isShown"]).forEach((function(n){"transform"===n?e.transform=t.transform._dup():"position"===n?e.position=t.getPosition():"rotation"===n?e.rotation=t.getRotation():"scale"===n?e.scale=t.getScale():"color"===n?e.color=t.color.slice():"isShown"===n&&(e.isShown=t.isShown)})),e}},{key:"saveScenarios",value:function(t,e){this.saveScenario(t,e)}},{key:"getAllElementsWithScenario",value:function(t){return null!=this.scenarios[t]?[this]:[]}},{key:"getMovingFreelyEnd",value:function(){return this.decelerate(null)}},{key:"getRemainingMovingFreelyTime",value:function(){return this.state.isMovingFreely?this.decelerate(null).duration:0}},{key:"decelerate",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=this.move.bounds,r=this.move,i=r.type,o=r.freely;return"boolean"==typeof o?{velocity:0,value:0,duration:0}:"position"===i||"translation"===i?{velocity:(r=On(this.transform.t(),this.state.movement.velocity,o.deceleration,e,n,o.bounceLoss,o.zeroVelocityThreshold)).velocity,value:r.position,duration:r.duration}:("scale"===i||"scaleX"===i?t=this.transform.s().x:"scaleY"===i?t=this.transform.s().y:"scaleZ"===i?t=this.transform.s().z:"rotation"===i&&(t="number"==typeof(i=this.transform.r())?i:i[1]),_n(t,this.state.movement.velocity,o.deceleration,e,n,o.bounceLoss,o.zeroVelocityThreshold))}},{key:"getPath",value:function(){return null==this.parent||"figureRoot"===this.parent.name||null==this.parent.parent?this.name:"".concat(this.parent.getPath(),".").concat(this.name)}},{key:"getMovement",value:function(t){var e,n=this.move.type;return"scale"===n||"scaleX"===n?e=t.s().x:"scaleY"===n?e=t.s().y:"scaleZ"===n?e=t.s().z:"position"===n||"translation"===n?e=t.t():"rotation"===n&&(e=t.r()),e}},{key:"updateTransformWithMovement",value:function(t,e){var n,r=this.move.type,i=t;return null!=this.move.bounds&&(i=this.move.bounds.clip(t)),"scale"===r?e.updateScale([i,i,i]):"scaleX"===r?(t=e.s(),e.updateScale([i,t.y,t.z])):"scaleY"===r?(n=e.s(),e.updateScale([n.x,i,n.z])):"scaleZ"===r?(n=e.s(),e.updateScale([n.x,n.y,i])):"position"===r||"translation"===r?e.updateTranslation(i):"rotation"===r&&e.updateRotation(i),e}},{key:"setZeroVelocity",value:function(){var t=this.move.type;this.state.movement.velocity="position"===t||"translation"===t?new Oe(0,0,0):0}},{key:"startBeingMoved",value:function(){this.animations.cancelAll("freeze"),this.stopMovingFreely("freeze"),this.setZeroVelocity(),this.state.movement.previousTime=this.timeKeeper.now()/1e3,this.state.isBeingMoved=!0,this.unrender(),this.notifications.publish("startBeingMoved"),"recording"===this.recorder.state&&this.recorder.recordEvent("startBeingMoved",[this.getPath()])}},{key:"moved",value:function(t){this.notifications.publish("beforeMove");var e=this.getMovement(this.transform);this.calcVelocity(e,t),e=this.transform._dup(),this.updateTransformWithMovement(t,e),this.setTransform(e)}},{key:"stopBeingMoved",value:function(){var t;this.state.isBeingMoved&&(t=this.timeKeeper.now()/1e3,null!=this.state.movement.previousTime&&.05<t-this.state.movement.previousTime&&this.setZeroVelocity(),this.notifications.publish("stopBeingMoved"),"recording"===this.recorder.state&&this.state.isBeingMoved&&this.recorder.recordEvent("stopBeingMoved",[this.getPath(),this.transform._state(),"number"==typeof this.state.movement.velocity?this.state.movement.velocity:this.state.movement.velocity._state()]),this.state.isBeingMoved=!1,this.state.movement.previousTime=null)}},{key:"calcVelocity",value:function(t,e){var n=this.timeKeeper.now()/1e3;if(null!=this.state.movement.previousTime){if(!((i=n-this.state.movement.previousTime)<1e-7)){var r,i,o=e,a=this.move.freely;if("boolean"!=typeof a){if("number"==typeof o&&"number"==typeof t){if(0==(r=(o-t)/i))return void(this.state.movement.velocity=0);e=r/Math.abs(r),Math.abs(r)<=a.zeroVelocityThreshold&&(r=0),r=Math.min(Math.abs(r),this.move.maxVelocity),r*=e}else(i=(r=o.sub(t).scale(1/i)).length())<=a.zeroVelocityThreshold?r=new Oe(0,0,0):i>this.move.maxVelocity&&(r=r.normalize().scale(this.move.maxVelocity));this.state.movement.velocity=r,this.state.movement.previousTime=n}}}else this.state.movement.previousTime=n}},{key:"startMovingFreely",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.animations.cancelAll("freeze"),this.stopBeingMoved(),!1!==this.move.freely&&(t&&(this.move.freely.callback=t),this.state.isMovingFreely=!0,this.state.movement.previousTime=this.timeKeeper.now()/1e3,this.notifications.publish("startMovingFreely"),"recording"===this.recorder.state&&(t=this.state.movement.velocity._state?this.state.movement.velocity._state():this.state.movement.velocity,this.recorder.recordEvent("startMovingFreely",[this.getPath(),this.transform._state(),t])),this.animateNextFrame())}},{key:"stopMovingFreely",value:function(){var t,e,n,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel";"animateToComplete"!==r&&"boolean"!=typeof this.move.freely&&(!(t=!1)===this.state.isMovingFreely&&(t=!0),"complete"===r&&t&&(e=this.getMovingFreelyEnd(),n=this.transform._dup(),this.updateTransformWithMovement(e.value,n),this.setTransform(n)),this.state.isMovingFreely=!1,this.state.movement.previousTime=null,this.move.freely.callback&&(this.fnMap.exec(this.move.freely.callback,r),this.move.freely.callback=null),t&&(this.fnMap.exec(this.animationFinishedCallback),this.animationFinished("movingFreely"),this.notifications.publish("stopMovingFreely")),this.animateNextFrame())}},{key:"getRemainingPulseTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3;return!1===this.state.isPulsing?0:null==this.state.pulse.startTime?this.pulseSettings.time:this.pulseSettings.time-(t-this.state.pulse.startTime)}},{key:"getPulseTransforms",value:function(t){var e=[];if(this.state.isPulsing){null==this.state.pulse.startTime&&(this.state.pulse.startTime=t);var n=t-this.state.pulse.startTime;n>=this.pulseSettings.time&&0!==this.pulseSettings.time&&(this.stopPulsing("complete"),n=this.pulseSettings.time);for(var r=0;r<this.pulseSettings.num;r+=1){var i=this.fnMap.exec(this.pulseSettings.progression,n,this.pulseSettings.frequency,this.pulseSettings.A instanceof Array?this.pulseSettings.A[r]:this.pulseSettings.A,this.pulseSettings.B instanceof Array?this.pulseSettings.B[r]:this.pulseSettings.B,this.pulseSettings.C instanceof Array?this.pulseSettings.C[r]:this.pulseSettings.C);null!=(i=this.fnMap.exec(this.pulseSettings.transformMethod,i,Ae(this.pulseSettings.delta),this.pulseSettings.type))&&e.push(i)}}return e}},{key:"pulse",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if("function"==typeof this.pulseDefault||"string"==typeof this.pulseDefault){var n=null;return"function"==typeof e?n=e:null!=e&&null!=e.done&&(n=e.done),void this.fnMap.exec(this.pulseDefault,n)}var r=this.pulseDefault,i="function"==typeof e||"string"==typeof e?(y=ft({},r),e):null==e?(y=ft({},r),null):(y=ft({},r,e)).done;"sinusoid"===y.progression?y.progression="tools.math.sinusoid":"sinusoidAbs"===y.progression?y.progression="tools.math.sinusoidAbs":"triangle"===y.progression&&(y.progression="tools.math.triangle");var o,a=(h=y).centerOn,s=h.xAlign,l=h.yAlign,u=h.space,c=null==a?new Oe(0,0):"this"===a?this.getPositionInBounds("figure",s,l).transformBy(this.spaceTransformMatrix("figure","draw")):a instanceof t?a.getPositionInBounds("figure",s,l).transformBy(this.spaceTransformMatrix("figure","draw")):Ae(a).transformBy(this.spaceTransformMatrix(u,"draw")),h=(n=(d=y).duration,r=d.scale,e=d.progression,d.when),f=d.num,d=(s=d.rotation,l=d.angle,a=d.translation,(u=y).min),p=u.start,y=u.frequency;if(0!==y&&null!=y||(y=0===n?1:1/n),u=(o=null!=a?(p=null==p?0:p,a):null!=s?(p=null==p?0:p,s):(p=null==p?1:p,r))-(d=null==d?p:d),1<f){for(var v=u/(f-1),g=[],b=[],w=[],x=0;x<f;x+=1){var S,T=o-x*v;T<p?(S=p-T,b.push(Math.PI/2),w.push(p-S/2),g.push(S/2)):(T-=p,b.push(-Math.PI/2),w.push(p+T/2),g.push(T/2))}this.pulseSettings.A=w,this.pulseSettings.B=g,this.pulseSettings.C=b}else r=u/2+d,d=0!=u?(p-r)/(u/2):p,this.pulseSettings.A=r,this.pulseSettings.B=u/2,this.pulseSettings.C=Math.asin(m(d,10));this.pulseSettings.time=n,this.pulseSettings.frequency=y,this.pulseSettings.num=f,this.pulseSettings.delta=c,this.pulseSettings.callback=i,this.pulseSettings.progression=e,this.pulseSettings.type="scale",null!=s&&(this.pulseSettings.type="rotation"),null!=a&&(this.pulseSettings.type=l),this.startPulsing(h),this.animateNextFrame()}},{key:"startPulsing",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"nextFrame";this.state.isPulsing=!0,t=this.timeKeeper.getWhen(t),this.state.pulse.startTime=null==t?t:t/1e3,this.unrender(),this.frozenPulseTransforms=[],this.animateNextFrame()}},{key:"stopPulsing",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=this.state.isPulsing;"animateToComplete"!==e&&("freeze"===e&&this.state.isPulsing&&(this.frozenPulseTransforms=this.pulseTransforms.map((function(t){return t._dup()})),this.pulseTransforms=[]),"cancel"!==e&&"complete"!==e||(this.pulseTransforms=[]),this.state.isPulsing=!1,this.pulseSettings.num=1,this.pulseSettings.callback&&(t=this.pulseSettings.callback,this.pulseSettings.callback=null,this.fnMap.exec(t,e)),n&&(this.animationFinished("pulse"),this.notifications.publish("stopPulsing")),this.animateNextFrame())}},{key:"stop",value:function(){function t(){--r<=0&&(e.state.preparingToStop=!1,e.notifications.publish("stopped"))}var e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",r=0;"animateToComplete"!==n&&"dissolveToComplete"!==n||(this.animations.isAnimating()&&(this.state.preparingToStop=!0,r+=1,this.animations.notifications.add("finished",t,1)),this.state.isPulsing&&(this.state.preparingToStop=!0,r+=1,this.notifications.add("stopPulsing",t,1)),this.state.isMovingFreely&&(this.state.preparingToStop=!0,r+=1,this.notifications.add("stopMovingFreely",t,1))),this.state.preparingToStop&&this.notifications.publish("preparingToStop"),this.stopAnimating(n),this.stopMovingFreely(n),this.stopBeingMoved(),this.stopPulsing(n)}},{key:"stopAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;"freeze"===t?this.animations.cancel(e,"freeze"):"cancel"===t?this.animations.cancel(e,null):"complete"===t&&this.animations.cancel(e,"complete")}},{key:"getRemainingAnimationTime",value:function(){return this.animations.getRemainingTime(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"getNextAnimationFinishTime",value:function(){if(this.simple)return this.state.isMovingFreely||this.state.isChanging||"animating"===this.animations.state?.1:0;var t,e=this.getRemainingMovingFreelyTime(),n=this.getRemainingPulseTime(),r=this.animations.getNextAnimationFinishTime();return null!=e&&0<e&&(t=e),null!=n&&0<n&&(void 0===t||n<t)&&(t=n),void 0===(t=null!=r&&0<r&&(void 0===t||r<t)?r:t)?null===e||null===n||null===r?null:0:t}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;t&&this.tieToHTML.updateOnResize&&this.updateHTMLElementTie(t)}},{key:"transformPoint",value:function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[[0,0,0],[0,0,1]],i=this.getScene();if(null==i)throw new Error("Scene is null for element ".concat(this.getPath()," and all it's parents "));var o=Ae(t);if("2D"===i.style||"gl"===e&&"pixel"===n||"local"===e&&"figure"===n||"draw"===e&&"figure"===n||"draw"===e&&"local"===n||"figure"===e&&"local"===n||"figure"===e&&"draw"===n||"local"===e&&"draw"===n||"orthographic"===i.style&&("gl"===e&&"figure"===n||"gl"===e&&"local"===n||"gl"===e&&"draw"===n||"figure"===e&&"pixel"===n||"local"===e&&"pixel"===n||"draw"===e&&"pixel"===n||"figure"===e&&"gl"===n||"local"===e&&"gl"===n||"draw"===e&&"gl"===n))return t=this.spaceTransformMatrix(e,n),o.transformBy(t);if("pixel"===e&&"figure"===n||"pixel"===e&&"local"===n||"pixel"===e&&"draw"===n)return this.pixelToPlane(o,n,r);if("pixel"===e&&"gl"===n)return this.pixelToGLPlane(o,r);if("gl"===e&&"local"===n||"gl"===e&&"draw"===n||"gl"===e&&"figure"===n)return r=i.glToFigure(o),"figure"===n?r:this.transformPoint(r,"figure",n);if("draw"===e&&"gl"===n||"local"===e&&"gl"===n||"figure"===e&&"gl"===n){var a=o;return"figure"!==e&&(a=this.transformPoint(o,e,"figure")),i.figureToGL(a)}if("draw"===e&&"pixel"===n||"local"===e&&"pixel"===n||"figure"===e&&"pixel"===n)return a=o,"figure"!==e&&(a=this.transformPoint(o,e,"figure")),a=i.figureToGL(a),this.transformPoint(a,"gl","pixel");throw new Error("Figure.transformPoint space definition error -'".concat(e,"', '").concat(n,"'"))}},{key:"getCanvas",value:function(){if(null!=this.drawingObject)return this.drawingObject.getCanvas();throw new Error("getCanvas error: Element ".concat(this.getPath()," has no drawing object."))}},{key:"spaceTransformMatrix",value:function(t,e){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:8;if(t===e)return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var i,o=this.getScene();if(null==o&&("figure"===t||"pixel"===t||"gl"===t||"figure"===e||"pixel"===e||"gl"===e))throw new Error("Scene is null for element ".concat(this.getPath()," and all it's parents "));function a(){var t=lr(l,s()).matrix(r);return t[10]=0,t[11]=0,t}null!=o&&(i=o.viewProjectionMatrix,u={x:{min:o.left,span:o.right-o.left},y:{min:o.bottom,span:o.top-o.bottom},z:{min:-1,span:2}});var s=function(){var t=n.getCanvas().getBoundingClientRect();return{x:{min:0,span:t.width},y:{min:t.height,span:-t.height},z:{min:-1,span:2}}},l={x:{min:-1,span:2},y:{min:-1,span:2},z:{min:-1,span:2}};if("draw"===t&&"local"===e)return this.getTransform().matrix(r);if("draw"===t&&"figure"===e)return this.getFigureTransform().matrix(r);if("draw"===t&&"gl"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from draw space to GL space for a perspective scene.");return m(Jt(o.viewProjectionMatrix,this.getFigureTransform().matrix(r)),r)}if("draw"===t&&"pixel"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from draw space to pixel space for a perspective scene.");return m(Jt(a(),Jt(o.viewProjectionMatrix,this.getFigureTransform().matrix(r))),r)}if("local"===t&&"figure"===e)return this.getLocalToFigureTransform().matrix(r);if("local"===t&&"gl"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from local space to GL space for a perspective scene.");return m(Jt(i,this.getLocalToFigureTransform().matrix(r)),r)}if("local"===t&&"pixel"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from local space to pixel space for a perspective scene.");return m(Jt(a(),Jt(i,this.getLocalToFigureTransform().matrix(r))),r)}if("figure"===t&&"gl"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from figure space to GL space for a perspective scene.");return i}if("figure"===t&&"pixel"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from figure space to pixel space for a perspective scene.");return m(Jt(a(),i),r)}if("gl"===t&&"pixel"===e)return a();if("pixel"===t&&"gl"===e)return lr(s(),l).matrix(r);if("pixel"===t&&"figure"===e){if("2D"!==o.style)throw new Error("Cannot create a transform matrix from pixel space to figure space (needs a plane intersect).");return lr(s(),u).matrix(r)}if("pixel"===t&&"local"===e){if("2D"!==o.style)throw new Error("Cannot create a transform matrix from pixel space to local space (needs a plane intersect).");return m(Jt(be(this.getLocalToFigureTransform().matrix(r)),lr(s(),u).matrix(r)),r)}if("pixel"===t&&"draw"===e){if("2D"!==o.style)throw new Error("Cannot create a transform matrix from pixel space to draw space (needs a plane intersect).");return m(Jt(be(this.getFigureTransform().matrix(r)),lr(s(),u).matrix(r)),r)}if("gl"===t&&"figure"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from GL space to figure space for a perspective scene.");return m(be(i),r)}if("gl"===t&&"local"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from GL space to local space for a perspective scene.");var u=be(i);return m(Jt(be(this.getLocalToFigureTransform().matrix(r)),u),r)}if("gl"===t&&"draw"===e){if("perspective"===o.style)throw new Error("Cannot create a transform matrix from GL space to draw space for a perspective scene.");return o=be(i),m(Jt(be(this.getFigureTransform().matrix(r)),o),r)}if("figure"===t&&"local"===e)return m(be(this.getLocalToFigureTransform().matrix(r)),r);if("figure"===t&&"draw"===e)return m(be(this.getFigureTransform().matrix(r)),r);if("local"===t&&"draw"===e)return m(be(this.getTransform().matrix(r)),r);throw new Error("Invalid space transform matrix inputs: from: '".concat(t,"', to: '").concat(e,"'"))}},{key:"pixelToPlane",value:function(t,e,n){return t=Ae(t).transformBy(this.spaceTransformMatrix("pixel","gl")),this.glToPlane(t,e,n)}},{key:"glToPlane",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"local",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.move.plane,r=Ae(t),i=this.getScene();if(null==i)throw new Error("Scene is null for element ".concat(this.getPath()," and all it's parents "));return t=i.nearCenter.add(i.rightVector.scale(i.widthNear/2*r.x)).add(i.upVector.scale(i.heightNear/2*r.y)),r=i.farCenter.add(i.rightVector.scale(i.widthFar/2*r.x)).add(i.upVector.scale(i.heightFar/2*r.y)),"local"!==e&&"draw"!==e||(e=this.spaceTransformMatrix("figure",e),t=t.transformBy(e),r=r.transformBy(e)),qe(n).lineIntersect([t,r])}},{key:"pixelToGLPlane",value:function(t,e){var n=Ae(t).transformBy(this.spaceTransformMatrix("pixel","gl"));return t=new Oe(n.x,n.y,-1),n=new Oe(n.x,n.y,1),qe(e).lineIntersect([t,n])}},{key:"glToPlaneLegacy",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.move.plane,n=Ae(t),r=this.getScene();if(null==r)throw new Error("Scene is null for element ".concat(this.getPath()," and all it's parents "));return t=r.nearCenter.add(r.rightVector.scale(r.widthNear/2*n.x)).add(r.upVector.scale(r.heightNear/2*n.y)),r=r.farCenter.add(r.rightVector.scale(r.widthFar/2*n.x)).add(r.upVector.scale(r.heightFar/2*n.y)),n=qe(e),e=this.spaceTransformMatrix("local","figure"),new He(n.p.transformBy(e),n.n.transformBy(e)).lineIntersect([t,r])}},{key:"pointFromSpaceToSpace",value:function(t,e,n){return Ae(t).transformBy(this.spaceTransformMatrix(e,n))}},{key:"getBorderPoints",value:function(){return[[]]}},{key:"getBorder",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=this.getBorderPoints(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border");if("draw"===t)return e;var n=[],r=Array.isArray(t)?Jt(t,this.getTransform().matrix()):this.spaceTransformMatrix("draw",t);return e.forEach((function(t){n.push(t.map((function(t){return t.transformBy(r)})))})),n}},{key:"getBoundingRect",value:function(){return hr(this.getBorder(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border"))}},{key:"getRelativeBoundingRect",value:function(){var t=this.getBoundingRect(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border"),e=this.getPosition(e);return new En(t.left-e.x,t.bottom-e.y,t.width,t.height)}},{key:"getCenterFigurePosition",value:function(){var t=this.getBoundingRect("figure","border");return new Oe(t.left+t.width/2,t.bottom+t.height/2)}},{key:"getScale",value:function(){var t=this.transform.s(),e=new Oe(1,1);return null!=t?t._dup():e}},{key:"getRotation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=this.transform.r();return""!==t&&null!=e?Ee(e,t):e}},{key:"getPositionInBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location",r=this.getBoundingRect(t,3<arguments.length&&void 0!==arguments[3]?arguments[3]:"border");return t=this.getPosition(t),"left"===e?t.x=r.left:"right"===e?t.x=r.right:"center"===e?t.x=r.left+r.width/2:"number"==typeof e?t.x=r.left+r.width*e:null!=e&&"o"===e.slice(-1)[0]&&(e=parseFloat(e),t.x=r.left+e),"top"===n?t.y=r.top:"bottom"===n?t.y=r.bottom:"middle"===n?t.y=r.bottom+r.height/2:"number"==typeof n?t.y=r.bottom+r.height*n:null!=n&&"o"===n.slice(-1)[0]&&(n=parseFloat(n),t.y=r.bottom+n),t}},{key:"getPosition",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location";return"location"!==e||"location"!==n?this.getPositionInBounds(t,e,n):"draw"===t?new Oe(0,0):new Oe(0,0).transformBy(this.spaceTransformMatrix("draw",t))}},{key:"setFigurePosition",value:function(t){var e=this.spaceTransformMatrix("figure","gl");t=Ae(t).transformBy(e.matrix()),e=this.getLocalToFigureTransform(),e=t.transformBy(be(e.matrix())),this.setPosition(e._dup())}},{key:"setFigurePositionToElement",value:function(t){t=t.getPosition("figure"),this.setFigurePosition(t._dup())}},{key:"setPositionToElement",value:function(t){var e;t.parent!==this.parent?(e=t.getPosition("figure").transformBy(this.spaceTransformMatrix("figure","local")),this.setPosition(e)):null!=(t=t.transform.t())&&this.setPosition(t._dup())}},{key:"getShown",value:function(){return this.isShown?[[this.getPath(),this.uid,this]]:[]}},{key:"getUid",value:function(t){return t===this.uid?this:null}},{key:"show",value:function(){this.isShown=!0,0===this.opacity&&this.setOpacity(1),null!=this.parent&&(this.parent.isShown||this.parent.show()),this.notifications.publish("show"),this.notifications.publish("visibility"),this.animateNextFrame()}},{key:"setTouchable",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=t;if("boolean"==typeof t){if(!1===t)return void this.setNotTouchable();e={}}(e=ft({scale:1,colorSeed:"default",enable:!0},e)).enable&&(this.isTouchable=!0),null==this.uniqueColor&&this.setUniqueColor(yt(e.colorSeed)),null!=e.onClick&&(this.onClick=e.onClick),null!=this.parent&&this.parent.setHasTouchableElements()}},{key:"setNotTouchable",value:function(){this.isTouchable=!1}},{key:"setMove",value:function(t){var e,n,r,i,o,a;"boolean"!=typeof t?(this.setMovable(),a=t.type,e=t.bounds,n=t.plane,r=t.maxVelocity,i=t.freely,o=t.element,null!=a&&(this.move.type=a),null!=n&&(this.move.plane=qe(n)),"rotation"===a&&(this.move.plane.n.isEqualTo([0,0,1])||this.transform.updateRotation(0,this.move.plane.n)),null!=e&&(null!=e.contains?this.move.bounds=e:void 0!==e.left||void 0!==e.right||void 0!==e.bottom||void 0!==e.top||void 0!==e.topDirection||void 0!==e.rightDirection||void 0!==e.position||void 0!==e.normal?(a=ft({},{position:this.move.plane.p,normal:this.move.plane.n},e),this.move.bounds=xn(a)):this.move.bounds=xn(e)),null!=r&&(this.move.maxVelocity="number"==typeof r?r:Ae(r)),null!=o&&(this.move.element=o),null!=i&&(!1===i?this.move.freely=!1:ft(this.move.freely,i))):this.setMovable(t)}},{key:"setMovable",value:function(){0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.isMovable=!1,this.isTouchable=!1):(this.isMovable=!0,this.setTouchable())}},{key:"clearRender",value:function(){var t,e="";"string"==typeof this.tieToHTML.element&&(e=this.tieToHTML.element,t=document.getElementById(this.tieToHTML.element)),t&&(null!=(t=document.getElementById("".concat(e,"_webgl")))&&(t.style.display="none"),null!=(e=document.getElementById("".concat(e,"_2d")))&&(e.style.display="none"))}},{key:"setRenderedOnNextDraw",value:function(){this.renderedOnNextDraw=!0}},{key:"unrender",value:function(){this.isRenderedAsImage&&(this.unrenderNextDraw=!0,this.isRenderedAsImage=!1),null!=this.parent&&this.parent.unrender()}},{key:"showAll",value:function(){this.show()}},{key:"hide",value:function(){this.isShown=!1,this.notifications.publish("hide"),this.notifications.publish("visibility"),this.animateNextFrame()}},{key:"hideAll",value:function(){this.hide()}},{key:"toggleShow",value:function(){this.isShown?this.hide():this.show()}},{key:"click",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);null!=this.onClick&&("recording"===this.recorder.state&&this.recorder.recordEvent("elementClick",[this.getPath(),t.x,t.y]),this.fnMap.exec(this.onClick,t,this)),this.notifications.publish("onClick",[t,this])}},{key:"getTransform",value:function(){return this.transform}},{key:"isMoving",value:function(){return!!this.state.isChanging||!1!==this.isShown&&(!!this.isAnimating()||!!this.state.isBeingMoved)}},{key:"isAnimating",value:function(){return!1!==this.isShown&&!!(this.state.isMovingFreely||this.state.isPulsing||this.animations.isAnimating())}},{key:"isAnyElementMoving",value:function(){return this.isMoving()}},{key:"isBeingTouched",value:function(t){if(!this.isTouchable)return!1;var e=this.getBorder("draw","touchBorder");if(null==e||0===e.length)return!1;var n=t.transformBy(this.spaceTransformMatrix("gl","draw"));if(null==e)return!1;for(var r=0;r<e.length;r+=1){var i=e[r];if(2<i.length&&as(n,i))return!0}return!1}},{key:"getTouched",value:function(t){return this.isTouchable&&this.isBeingTouched(t)?[this]:[]}},{key:"getSelectionFromBorders",value:function(t){return this.isTouchable&&this.isBeingTouched(t)?this:null}},{key:"setUniqueColor",value:function(t){this.uniqueColor=null==t?null:t.slice()}},{key:"getUniqueColorElement",value:function(t){return!1===this.isTouchable||null==this.uniqueColor||this.uniqueColor[0]!==t[0]||this.uniqueColor[1]!==t[1]||this.uniqueColor[2]!==t[2]||this.uniqueColor[3]!==t[3]?null:this}}]),t}(),jl=function(){gl(e,Cl);var t=wl(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Qe,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[.5,.5,.5,1],o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:mt("element_"),s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:new ml;return _l(this,e),(s=t.call(this,r,o,a,s)).drawingObject=n,s.color=null!=i?i.slice():[0,0,0,0],s.defaultColor=s.color.slice(),s.dimColor=[.5,.5,.5,1],s.pointsToDraw=-1,s.angleToDraw=-1,s.lengthToDraw=-1,s.cannotTouchHole=!1,s.type="primitive",s.pointsDefinition={},s.setPointsFromDefinition=null,s.border="draw",s.touchBorder="draw",s}return Pl(e,[{key:"_getStateProperties",value:function(t){var n=t.ignoreShown;return null==n&&(n=!1),this.isShown||n?[].concat(Sl(vl(xl(e.prototype),"_getStateProperties",this).call(this,t)),["pointsToDraw","angleToDraw","lengthToDraw","cannotTouchHole","drawingObject","pointsDefinition"]):vl(xl(e.prototype),"_getStateProperties",this).call(this,t)}},{key:"setAngleToDraw",value:function(){this.angleToDraw=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1}},{key:"click",value:function(){var t,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);vl(xl(e.prototype),"click",this).call(this,n),this.drawingObject instanceof ul&&(t=n,"perspective"!==this.getScene().style&&(t=n.transformBy(this.spaceTransformMatrix("gl","draw"))),this.drawingObject.click(t,this.fnMap),"recording"===this.recorder.state&&this.recorder.recordEvent("elementTextClick",[this.getPath(),n.x,n.y]))}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=new e(this.drawingObject._dup());return dt(this,n,["parent","figure","recorder","pulseDefault.centerOn","timeKeeper"]),null!=t&&(n.transform=t._dup()),"string"!=typeof this.pulseDefault&&"function"!=typeof this.pulseDefault?n.pulseDefault.centerOn=this.pulseDefault.centerOn:n.pulseDefault=this.pulseDefault,n.recorder=this.recorder,n.timeKeeper=this.timeKeeper,n}},{key:"clear",value:function(){this.drawingObject instanceof ul&&this.drawingObject.clear(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,this.pulseTransforms)}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;this.resizeHtmlObject(),vl(xl(e.prototype),"resize",this).call(this,t)}},{key:"setColor",value:function(t){var n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];this.color=null!=t?t.slice():[0,0,0,0],n&&(this.defaultColor=this.color.slice()),this.notifications.publish("color"),this instanceof e&&(this.drawingObject instanceof ul&&this.drawingObject.setColor(this.color),this.drawingObject instanceof ks&&(this.drawingObject.element.style.color=no(this.color)))}},{key:"setOpacity",value:function(t){this.opacity=t,this instanceof e&&(this.drawingObject instanceof ul&&this.drawingObject.setOpacity(t),this.drawingObject instanceof ks&&(this.drawingObject.element.style.opacity="".concat(t))),this.animateNextFrame()}},{key:"show",value:function(){vl(xl(e.prototype),"show",this).call(this),this.drawingObject instanceof ks&&(this.drawingObject.show=!0,this.drawingObject.transformHtml(this.getFigureTransform().matrix()))}},{key:"hide",value:function(){vl(xl(e.prototype),"hide",this).call(this),this.drawingObject instanceof ks&&(this.drawingObject.show=!1,this.drawingObject.transformHtml(this.getFigureTransform().matrix()))}},{key:"setFont",value:function(t){this.drawingObject instanceof ul&&this.drawingObject.setFont(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0)}},{key:"resizeHtmlObject",value:function(){this.drawingObject instanceof ks&&this.drawingObject.transformHtml(this.getFigureTransform().matrix())}},{key:"getBorderPoints",value:function(){return"border"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border")?"draw"===this.border?this.drawBorder:"buffer"===this.border?this.drawBorderBuffer:"rect"===this.border?[fr(this.drawBorder)]:cr(this.border)?[fr(this.drawBorder,this.border)]:this.border:"draw"===this.touchBorder?this.drawBorder:"buffer"===this.touchBorder?this.drawBorderBuffer:"border"===this.touchBorder?this.getBorderPoints("border"):"rect"===this.touchBorder?[fr(this.getBorderPoints("border"))]:cr(this.touchBorder)?[fr(this.getBorderPoints("border"),this.touchBorder)]:this.touchBorder}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(this.isShown){if(this.lastDrawTime=t,!0===this.isRenderedAsImage){if(!this.willStartAnimating())return;this.unrender()}this.notifications.publish("beforeDraw",[t]),null!=this.beforeDrawCallback&&this.fnMap.exec(this.beforeDrawCallback,t),0<this.animations.animations.length&&this.animations.nextFrame(t),this.state.isMovingFreely&&this.nextMovingFreelyFrame(t)}}},{key:"draw",value:function(t,e){var n,r,i,o=this,a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[new Qe],s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,l=4<arguments.length&&void 0!==arguments[4]&&arguments[4],u=5<arguments.length&&void 0!==arguments[5]&&arguments[5],c=6<arguments.length&&void 0!==arguments[6]?arguments[6]:null,h=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;this.isShown&&(l&&!this.isTouchable&&!u||(n=-1,this.drawingObject instanceof Cs?(n=this.drawingObject.numVertices,-1!==this.angleToDraw&&(n=this.drawingObject.getPointCountForAngle(this.angleToDraw)),-1!==this.lengthToDraw&&(n=this.drawingObject.getPointCountForLength(this.lengthToDraw)),-1!==this.pointsToDraw&&(n=this.pointsToDraw)):n=this.drawingObject instanceof Cs?this.drawingObject.numVertices:1,r=[this.color[0],this.color[1],this.color[2],this.color[3]*this.opacity*s],l&&(r=null!=h?h:null==this.uniqueColor?(this.setUniqueColor(yt()),this.uniqueColor.map((function(t){return t/255}))):this.uniqueColor.map((function(t){return t/255}))),this.lastDrawOpacity=r[3],h=this.getTransform(),l&&h.hasComponent("s")&&null!=this.touchScale&&(h=h._dup()).updateScale(h.s().mul(this.touchScale)),l&&h.hasComponent("s")&&null!=c&&h.updateScale(h.s().mul(c)),h=Ml(a,[h]),this.parentTransform=a,this.pulseTransforms=this.getPulseTransforms(t),this.drawTransforms=this.getDrawTransforms(h),i=null!=this.scene?this.scene:e,this.lastDrawPulseTransform=this.drawTransforms[0],0<n&&this.drawTransforms.forEach((function(t){o.drawingObject.drawWithTransformMatrix(i,t.matrix(),r,n,l)}))))}},{key:"setFirstTransform",value:function(){0<arguments.length&&void 0!==arguments[0]||new Qe}},{key:"increaseBorderSize",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=e instanceof Oe?(t=e.x,e.y):(t=e,null==n?t:n);if(this.drawingObject instanceof Us)for(var i=0;i<this.drawingObject.border.length;i+=1)for(var o=this.drawingObject.border[i],a=0;a<o.length;a+=1)o[a].x*=t,o[a].y*=r}}]),e}(),Rl=function(){gl(e,Cl);var t=wl(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};_l(this,e);var r=ft({},{transform:new Qe,parent:null,border:"children",touchBorder:"children",color:[0,0,0,1],name:mt("collection_"),timeKeeper:new ml},n),i=t.call(this,rn(r.transform),r.parent,r.name,r.timeKeeper);return null!=r.position&&i.transform.updateTranslation(Ae(r.position)),i.elements={},i.drawOrder=[],null!=n.move&&!1!==n.move&&(i.setTouchable(),i.setMovable(),i.setMove(n.move)),null!=n.touch&&i.setTouchable(n.touch),null!=n.dimColor&&(i.dimColor=n.dimColor),null!=n.scenarios&&(i.scenarios=n.scenarios),null!=n.scene&&(n.scene instanceof Pi?i.scene=n.scene:i.setScene(n.scene)),i.childrenCanAnimate=!0,i.eqns={},i.type="collection",i.setColor(r.color),i.hasTouchableElements=!1,null!=r.border&&(cr(r.border)?i.border=r.border:i.border=vr(r.border)),null!=r.touchBorder&&(cr(r.touchBorder)?i.touchBorder=r.touchBorder:i.touchBorder=vr(r.touchBorder)),null!=r.touchScale&&(i.touchScale=_e(r.touchScale)),i}return Pl(e,[{key:"_getStateProperties",value:function(t){var n=t.ignoreShown;return null==n&&(n=!1),this.isShown||n?[].concat(Sl(vl(xl(e.prototype),"_getStateProperties",this).call(this,t)),["hasTouchableElements"]):Sl(vl(xl(e.prototype),"_getStateProperties",this).call(this,t))}},{key:"_getStatePropertiesMin",value:function(){return Sl(vl(xl(e.prototype),"_getStatePropertiesMin",this).call(this))}},{key:"getCanvas",value:function(){if(null!=this.parent)return this.parent.getCanvas();throw new Error("Element ".concat(this.getPath()," is not attached to a parent with a canvas"))}},{key:"getRootElement",value:function(){var t=vl(xl(e.prototype),"getRootElement",this).call(this);return null==t?this:t}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=new e({}),r=this.drawOrder.map((function(t){return"_".concat(t)}));dt(this,n,["elements","drawOrder","parent","recorder","figure","collections","pulseDefault.centerOn"].concat(Sl(r),Sl(t)));for(var i=0;i<this.drawOrder.length;i+=1){var o=this.drawOrder[i];n.add(o,this.elements[o]._dup())}return n.recorder=this.recorder,"string"!=typeof this.pulseDefault&&"function"!=typeof this.pulseDefault?n.pulseDefault.centerOn=this.pulseDefault.centerOn:n.pulseDefault=this.pulseDefault,n}},{key:"toFront",value:function(t){var e=t;Array.isArray(t)&&"string"!=typeof t||(e=[t]);var n=[];e.forEach((function(t){"string"==typeof t?n.push(t):n.push(t.name)}));var r=[];this.drawOrder.forEach((function(t){-1===n.indexOf(t)&&r.push(t)})),this.drawOrder=[].concat(r,n)}},{key:"toBack",value:function(t){var e=t;"string"!=typeof t&&Array.isArray(t)||(e=[t]);var n=[];e.forEach((function(t){"string"==typeof t?n.push(t):n.push(t.name)}));var r=[];this.drawOrder.forEach((function(t){-1===n.indexOf(t)&&r.push(t)})),this.drawOrder=[].concat(Sl(n.reverse()),r)}},{key:"isAnyElementMoving",value:function(){if(!1===this.isShown)return!1;if(this.isMoving())return!0;for(var t=0;t<this.drawOrder.length;t+=1)if(this.elements[this.drawOrder[t]].isAnyElementMoving())return!0;return!1}},{key:"addElementWithName",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:-1;return(e.parent=this).elements[t]=e,this.elements[t].name=t,this["_".concat(t)]=this.elements[t],-1!==n?this.drawOrder=[].concat(Sl(this.drawOrder.slice(0,n)),[t],Sl(this.drawOrder.slice(n))):this.drawOrder.push(t),null!=this.figure&&e.setFigure(this.figure),this.animateNextFrame(),e}},{key:"add",value:function(t){var n=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof t){if(null==r)throw new Error("Adding element ".concat(t," fail: Element is null"));return this.addElementWithName(t,r)}r=Array.isArray(t)?t:[t];var i=this,o=[];return r.forEach((function(t,r){if(t instanceof Cl)o.push(n.add(t.name,t));else{if(null==t)throw Error("Add elements index ".concat(r," does not exist in layout"));var a=t.path,s=null!=t.options?t.options:t,l=t.elements,u=t.make,c=t.mods,h=t.scenario,f=null==a||""===a?i:i.getElement(a);if(null==u||""===u)throw new Error("Figure addElement ERROR at index ".concat(r," in collection ").concat(i.name,": missing method property in ").concat(t));var d,p=t.name||mt(u.startsWith("collection")?"collection_":"primitive_");if(null==p||""===p)throw new Error("Figure addElement ERROR at index ".concat(r," in collection ").concat(i.name,": missing name property in ").concat(t));if(!(f instanceof e))throw new Error("Figure addElement ERROR at index ".concat(r," in collection ").concat(i.name,": missing or incorrect path property in ").concat(t));if(a=u.split("/"),"function"==typeof(t=n.getMethod(u))){if("function"!=typeof t)throw new Error("Layout addElement at index ".concat(r," in collection ").concat(i.name,": incorrect method property"));if(a.slice(-1)[0].startsWith("add")){if(null==(d=t(f,p,s)))return;null!=c&&c!=={}&&d.setProperties(c)}else{if(null==(d=Array.isArray(s)?t.apply(void 0,Sl(s)):t(s)))return;null!=c&&c!=={}&&d.setProperties(c),f instanceof e&&(f.add(p,d),o.push(d))}null!=h&&h in d.scenarios&&d.setScenario(h),null!=s.move&&!1!==s.move&&(d.setTouchable(),d.setMovable(),d.setMove(s.move)),null!=s.touch&&d.setTouchable(s.touch),null!=s.touchScale&&(d.touchScale=_e(s.touchScale)),null!=s.dimColor&&(d.dimColor=s.dimColor),null!=s.scenarios&&(d.scenarios=s.scenarios),null!=s.scene&&(s.scene instanceof Pi?d.scene=s.scene:d.setScene(s.scene)),"_".concat(p)in i&&null!=l&&l!=={}&&!u.endsWith("equation")&&d.add(l)}}})),Array.isArray(t)||1!==o.length?o:o[0]}},{key:"getMethod",value:function(t){function e(t,n){return n[0]in t?1===n.length?t[n[0]]:e(t[n[0]],n.slice(1)):null}var n=this.collections,r=n.primitives,i={collection:n.collection.bind(n),polyline:r.polyline.bind(r),polygon:r.polygon.bind(r),rectangle:r.rectangle.bind(r),ellipse:r.ellipse.bind(r),gl:r.gl.bind(r),morph:r.morph.bind(r),arc:r.arc.bind(r),triangle:r.triangle.bind(r),generic:r.generic.bind(r),generic3:r.generic3.bind(r),grid:r.grid.bind(r),sphere:r.sphere.bind(r),cone:r.cone.bind(r),line3:r.line3.bind(r),revolve:r.revolve.bind(r),surface:r.surface.bind(r),cylinder:r.cylinder.bind(r),cube:r.cube.bind(r),prism:r.prism.bind(r),cameraControl:r.cameraControl.bind(r),arrow:r.arrow.bind(r),line:r.line.bind(r),star:r.star.bind(r),text:r.text.bind(r),textLine:r.textLine.bind(r),textLines:r.textLines.bind(r),"text.line":r.textLine.bind(r),"text.lines":r.textLines.bind(r),textGL:r.textGL.bind(r),textHTML:r.htmlText.bind(r),htmlImage:r.htmlImage.bind(r),opolyline:n.polyline.bind(n),oline:n.line.bind(n),angle:n.angle.bind(n),addEquation:n.addEquation.bind(n),equation:n.equation.bind(n)};return t in i?i[t]:null==(t=e(r={primitives:r,shapes:r,collections:n},n=t.split(".")))?null:t.bind(e(r,n.slice(0,-1)))}},{key:"setFigure",value:function(t){vl(xl(e.prototype),"setFigure",this).call(this,t),null!=this.onAdd&&this.fnMap.exec(this.onAdd);for(var n=0,r=this.drawOrder.length;n<r;n+=1){var i=this.elements[this.drawOrder[n]];i.setFigure(t),null!=i.onAdd&&this.fnMap.exec(i.onAdd)}}},{key:"willStartAnimating",value:function(){if(vl(xl(e.prototype),"willStartAnimating",this).call(this))return!0;for(var t=0,n=this.drawOrder.length;t<n;t+=1)if(this.elements[this.drawOrder[t]].willStartAnimating())return!0;return!1}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;if(this.isShown){if(this.lastDrawTime=t,!0===this.isRenderedAsImage){if(!this.willStartAnimating())return;this.unrender()}if(null!=this.beforeDrawCallback&&this.fnMap.exec(this.beforeDrawCallback,t),this.animations.nextFrame(t),this.nextMovingFreelyFrame(t),this.isShown&&this.childrenCanAnimate)for(var n=0,r=this.drawOrder.length;n<r;n+=1)this.elements[this.drawOrder[n]].setupDraw(t,e)}}},{key:"draw",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[new Qe],r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,i=4<arguments.length&&void 0!==arguments[4]&&arguments[4],o=5<arguments.length&&void 0!==arguments[5]&&arguments[5],a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:null,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:null;if(this.isShown&&(!i||this.isTouchable||this.hasTouchableElements||o)){var l=null;i&&(null==a&&null==this.touchScale||(l=new Oe(1,1,1)),null!=a&&(l=l.mul(a)),null!=this.touchScale&&(l=l.mul(_e(this.touchScale))));var u=o;this.isTouchable&&(u=!0);var c=null;null==s&&this.isTouchable?(null==this.uniqueColor&&this.setUniqueColor(yt()),c=this.uniqueColor.map((function(t){return t/255}))):null!=s&&(c=s),s=Ml(n,[s=this.getTransform()]);var h=null!=this.scene?this.scene:e;this.parentTransform=n,this.pulseTransforms=this.getPulseTransforms(t),this.drawTransforms=this.getDrawTransforms(s),this.lastDrawPulseTransform=this.drawTransforms[0];var f=this.color[3]*this.opacity*r;this.lastDrawOpacity=f;for(var d=0,p=this.drawOrder.length;d<p;d+=1)this.elements[this.drawOrder[d]].draw(t,h,this.drawTransforms,f,i,u,l,c);this.unrenderNextDraw&&(this.clearRender(),this.unrenderNextDraw=!1),this.renderedOnNextDraw&&(this.isRenderedAsImage=!0,this.renderedOnNextDraw=!1),null!=this.afterDrawCallback&&this.fnMap.exec(this.afterDrawCallback,t)}}},{key:"exec",value:function(t){var n=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;null!=r?Array.isArray(r)&&0===r.length||r.forEach((function(e){null!=(e="string"==typeof e?n.getElement(e):e)&&e.exec(t)})):vl(xl(e.prototype),"exec",this).call(this,t)}},{key:"pulse",value:function(){var t,n,r,i,o,a,s,l,u=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,h=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;null!=c&&"function"!=typeof c&&"string"!=typeof c?(Array.isArray(c)||null==c.centerOn||"string"!=typeof c.centerOn||null!=(t=this.getElement(c.centerOn))&&(c.centerOn=t),Array.isArray(c)||null!=c.elements&&0!==c.elements.length?(Array.isArray(c)?(n={},i=h,r=c):(r=(n=ft({},c)).elements,i=n.done,null==c.scale&&(n.scale=void 0),null==c.frequency&&(n.frequency=void 0),null==c.duration&&(n.duration=void 0)),n.elements=null,o=0,n.done=function(){(o+=1)===r.length&&null!=i&&i()},a=this.spaceTransformMatrix("draw","figure"),s=n.translation,l=n.min,r.forEach((function(t){var e="string"==typeof t?u.getElement(t):t;null!=e&&(null!=n.translation&&(t=e.spaceTransformMatrix("figure","draw")[0]/a[0],n.translation*=t,null!=n.min&&(n.min*=t)),e.pulse(n),null!=s&&(n.translation=s),null!=l&&(n.min=l))}))):vl(xl(e.prototype),"pulse",this).call(this,c)):vl(xl(e.prototype),"pulse",this).call(this,c)}},{key:"getElement",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return null==t?this:"string"!=typeof t||t instanceof Cl?t:function t(e,n){var r=e.split(".");if(null!=(e=null==(e=n.elements[r[0]])?n[r[0]]:e))return 1<r.length?t(r.slice(1).join("."),e):e}(t,this)}},{key:"getElements",value:function(t){var e=this;if(null==t)return[];t=function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e)return["".concat(n).concat(e)];if(e instanceof Cl)return[e];if(Array.isArray(e)){var r=[];return e.forEach((function(e){r.push.apply(r,Sl(t(e,n)))})),r}var i=[];return Object.keys(e).forEach((function(r){i.push.apply(i,Sl(t(e[r],"".concat(n).concat(r,"."))))})),i}(t);var n=[];return t.forEach((function(t){null!=(t=e.getElement(t))&&n.push(t)})),n}},{key:"getShown",value:function(){var t=this;if(!1===this.isShown)return[];var e=[[this.getPath(),this.uid,this]];return this.drawOrder.forEach((function(n){n=t.elements[n],e.push.apply(e,Sl(n.getShown()))})),e}},{key:"get",value:function(t){return"string"==typeof t?this.getElement(t):this.getElements(t)}},{key:"getUid",value:function(t){if(t===this.uid)return this;for(var e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]].getUid(t);if(null!==n)return n}return null}},{key:"show",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];vl(xl(e.prototype),"show",this).call(this),this.getElements(t).forEach((function(t){t.showAll()}))}},{key:"showOnly",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];this.hideAll(),this.show(t)}},{key:"showAll",value:function(){vl(xl(e.prototype),"show",this).call(this);for(var t=0,n=this.drawOrder.length;t<n;t+=1)this.elements[this.drawOrder[t]].showAll()}},{key:"hide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t?this.getElements(t).forEach((function(t){t.hide()})):vl(xl(e.prototype),"hide",this).call(this)}},{key:"hideAll",value:function(){this.hide();for(var t=0,e=this.drawOrder.length;t<e;t+=1){var n=this.elements[this.drawOrder[t]];n.hide(),"function"==typeof n.hideAll&&n.hideAll()}}},{key:"hideOnly",value:function(t){this.showAll(),this.hide(t)}},{key:"resizeHtmlObject",value:function(){for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].resizeHtmlObject()}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;vl(xl(e.prototype),"resize",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].resize(t)}},{key:"clear",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].clear(t)}},{key:"setFirstTransform",value:function(){0<arguments.length&&void 0!==arguments[0]||new Qe}},{key:"getBorderPoints",value:function(){function t(t){var r=[],a=i;return 0===(a=null==a?Object.keys(n.elements):a).length?[[]]:(a.forEach((function(i){null==(i=n.getElement(i))||o&&!1===i.isShown||(i instanceof e||null!=i.drawBorder)&&r.push.apply(r,Sl(i.getBorder("local",t,null,o)))})),r)}var n=this,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border",i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,o=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];return"border"===r?"children"===this.border?t("border"):"rect"===this.border?[fr(t("border"))]:cr(this.border)?[fr(t("border"),this.border)]:this.border:"border"===this.touchBorder?this.getBorderPoints("border",i,o):"children"===this.touchBorder?t("touchBorder"):"rect"===this.touchBorder?[fr(t("touchBorder"))]:cr(this.touchBorder)?[fr(t("touchBorder"),this.touchBorder)]:this.touchBorder}},{key:"getBorder",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];if(r&&!1===this.isShown)return[[]];var i=Array.isArray(t)?Jt(t,this.getTransform().matrix()):this.spaceTransformMatrix("draw",t);return this.getBorderPoints(e,n,r).map((function(t){return t.map((function(t){return Ae(t).transformBy(i)}))}))}},{key:"getBoundingRect",value:function(){return hr(this.getBorder(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,!(3<arguments.length&&void 0!==arguments[3])||arguments[3]))}},{key:"getRelativeBoundingRect",value:function(){var t=this.getBoundingRect(e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",1<arguments.length&&void 0!==arguments[1]?arguments[1]:"border",2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,!(3<arguments.length&&void 0!==arguments[3])||arguments[3]),e=this.getPosition(e);return new En(t.left-e.x,t.bottom-e.y,t.width,t.height)}},{key:"getPositionInBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"local",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"location",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"location",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return r=this.getBoundingRect(t,4<arguments.length&&void 0!==arguments[4]?arguments[4]:"border",r,!(5<arguments.length&&void 0!==arguments[5])||arguments[5]),t=this.getPosition(t),"left"===e?t.x=r.left:"right"===e?t.x=r.right:"center"===e?t.x=r.left+r.width/2:"number"==typeof e&&(t.x=r.left+r.width*e),"top"===n?t.y=r.top:"bottom"===n?t.y=r.bottom:"middle"===n?t.y=r.bottom+r.height/2:"number"==typeof n&&(t.y=r.bottom+r.height*n),t}},{key:"setUniqueColor",value:function(t){vl(xl(e.prototype),"setUniqueColor",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setUniqueColor(t)}},{key:"getUniqueColorElement",value:function(t){if(vl(xl(e.prototype),"getUniqueColorElement",this).call(this,t))return this;for(var n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]].getUniqueColorElement(t);if(null!=r)return r}return null}},{key:"updateHTMLElementTie",value:function(t){vl(xl(e.prototype),"updateHTMLElementTie",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].updateHTMLElementTie(t)}},{key:"getTouched",value:function(t){if(!this.isTouchable&&!this.hasTouchableElements)return[];var n=[];if(this.isTouchable)return vl(xl(e.prototype),"getTouched",this).call(this,t);for(var r=this.drawOrder.length-1;0<=r;--r){var i=this.elements[this.drawOrder[r]];i.isShown&&(n=n.concat(i.getTouched(t)))}return n}},{key:"setHasTouchableElements",value:function(){this.hasTouchableElements=!0,null!=this.parent&&this.parent.setHasTouchableElements()}},{key:"getSelectionFromBorders",value:function(t){if(!this.isTouchable&&!this.hasTouchableElements)return null;if(this.isTouchable)return vl(xl(e.prototype),"getSelectionFromBorders",this).call(this,t);for(var n=this.drawOrder.length-1;0<=n;--n){var r=this.elements[this.drawOrder[n]];if(r.isShown&&null!=(r=r.getSelectionFromBorders(t)))return r}return null}},{key:"stop",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(vl(xl(e.prototype),"stop",this).call(this,t),!n)for(var r=0;r<this.drawOrder.length;r+=1)this.elements[this.drawOrder[r]].stop(t,n)}},{key:"setFont",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].setFont(t)}},{key:"setColor",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[0,0,0,1],e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=null!=t?t:[0,0,0,0],r=0;r<this.drawOrder.length;r+=1)this.elements[this.drawOrder[r]].setColor(n,e);this.color=n.slice(),this.notifications.publish("color"),e&&(this.defaultColor=this.color.slice())}},{key:"setDimColor",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[0,0,0,1],e=null!=t?t:[0,0,0,0],n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setDimColor(e);this.dimColor=e.slice()}},{key:"undim",value:function(t){var e=this;(t=null!=t?this.getElements(t):(this.color=this.defaultColor.slice(),this.drawOrder.map((function(t){return e.elements[t]})))).forEach((function(t){return t.undim()}))}},{key:"dim",value:function(t){var e=this;(t=null!=t?this.getElements(t):(this.color=this.dimColor.slice(),this.drawOrder.map((function(t){return e.elements[t]})))).forEach((function(t){return t.dim()}))}},{key:"highlight",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t?(t=this.getElements(t),this.dim(),this.exec("undim",t)):this.undim()}},{key:"getElementTransforms",value:function(){for(var t={},e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];t[n.name]=n.transform._dup()}return t}},{key:"setElementTransforms",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];n.name in t&&(n.transform=t[n.name],n.internalSetTransformCallback&&this.fnMap.exec(n.internalSetTransformCallback,n.transform))}}},{key:"reorder",value:function(){var t=this;this.drawOrder.sort((function(e,n){return e=t.elements[e],t.elements[n].drawPriority-e.drawPriority}));for(var n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]];r instanceof e&&r.reorder()}}},{key:"animateToTransforms",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"",a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:"tools.math.easeinout",s=i,l=0,u=0;u<this.drawOrder.length;u+=1){var c=this.elements[this.drawOrder[u]];c.name in t&&(c.isShown?t[c.name].isEqualTo(c.transform)||(c.animations.new(o).delay(n).transform({target:t[c.name],duration:e,rotDirection:r,progression:a,onFinish:s}).start(),s=null,l=e+n):(c.transform=t[c.name]._dup(),c.internalSetTransformCallback&&this.fnMap.exec(c.internalSetTransformCallback,c.transform)))}return 0===l&&null!=s&&this.fnMap.exec(s,!0),l}},{key:"getAllPrimitives",value:function(){for(var t=[],n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]];r instanceof e?t=[].concat(Sl(t),Sl(r.getAllPrimitives())):t.push(r)}return t}},{key:"getAllElements",value:function(){for(var t=[this],n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]];r instanceof e?t.push.apply(t,Sl(r.getAllElements())):t.push(r)}return t}},{key:"getChildren",value:function(){for(var t=[],e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];t.push(n)}return t}},{key:"getAllElementsWithScenario",value:function(t){for(var n=vl(xl(e.prototype),"getAllElementsWithScenario",this).call(this,t),r=0;r<this.drawOrder.length;r+=1){var i=this.elements[this.drawOrder[r]];n=[].concat(Sl(n),Sl(i.getAllElementsWithScenario(t)))}return n}},{key:"getNextAnimationFinishTime",value:function(){if(this.simple)return this.state.isMovingFreely||this.state.isChanging||"animating"===this.animations.state?.1:0;var t=null,n=vl(xl(e.prototype),"getNextAnimationFinishTime",this).call(this),r=!1;null===n?r=!0:0<n&&(t=n);for(var i,o=0;o<this.drawOrder.length;o+=1)this.elements[this.drawOrder[o]].simple||(null===(i=this.elements[this.drawOrder[o]].getNextAnimationFinishTime())?r=!0:(0<i&&null==t||0<i&&i<t)&&(t=i));return null==t?r?null:0:t}},{key:"getRemainingAnimationTime",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=this.getAllElements(),r=vl(xl(e.prototype),"getRemainingAnimationTime",this).call(this,t),i=0;i<n.length;i+=1){var o=n[i].animations.getRemainingTime(t);if(null==o)return null;r<o&&(r=o)}return r}},{key:"getAllPossiblyInteractiveElements",value:function(){for(var t=[],n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]];r instanceof e&&(r.isTouchable||r.isMovable||!r.hasTouchableElements||r.isInteractive&&null!=r.isInteractive||(t=[].concat(Sl(t),Sl(r.getAllPossiblyInteractiveElements())))),(void 0!==r.isInteractive||r.isTouchable||r.isMovable)&&t.push(r)}return t}},{key:"goToStep",value:function(t){var e=document.getElementById("id__figureone_item_selector_0"),n=[];if(null!=e&&0<e.children.length)for(var r=0;r<e.children.length;r+=1)n.push(e.children[r]);n.forEach((function(e,n){n===t?e.classList.add("figureone__item_selector_selected"):e.classList.remove("figureone__item_selector_selected")}))}},{key:"setupWebGLBuffers",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)this.elements[this.drawOrder[e]].setupWebGLBuffers(t)}},{key:"changeWebGLInstance",value:function(t){for(var e=0;e<this.drawOrder.length;e+=1)var n=this.elements[this.drawOrder[e]].changeWebGLInstance(t);return n}},{key:"getLoadingElements",value:function(){for(var t=[],e=0;e<this.drawOrder.length;e+=1){var n=this.elements[this.drawOrder[e]];n instanceof jl?"loading"===n.drawingObject.state&&t.push(n):t=[].concat(Sl(t),Sl(n.getLoadingElements()))}return t}},{key:"setPointsFromDefinition",value:function(){for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];null!=e.setPointsFromDefinition&&e.setPointsFromDefinition()}}},{key:"setPrimitiveColors",value:function(){for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];e instanceof jl?(e.setColor(e.color,!1),e.setOpacity(e.opacity)):e.setPrimitiveColors()}}},{key:"unrenderAll",value:function(){this.unrender();for(var t=0;t<this.drawOrder.length;t+=1){var e=this.elements[this.drawOrder[t]];e instanceof jl?e.unrender():e.unrenderAll()}}},{key:"setScenarios",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];vl(xl(e.prototype),"setScenarios",this).call(this,t);for(var r=0;r<this.drawOrder.length;r+=1){var i=this.elements[this.drawOrder[r]];(n&&i.isShown||!1===n)&&i.setScenarios(t,n)}}},{key:"saveScenarios",value:function(t,n){vl(xl(e.prototype),"saveScenarios",this).call(this,t,n);for(var r=0;r<this.drawOrder.length;r+=1)this.elements[this.drawOrder[r]].saveScenarios(t,n)}},{key:"animateToState",value:function(t,n){var r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,o=0;if(o=vl(xl(e.prototype),"animateToState",this).call(this,t,n,r,i),!1===this.dependantTransform||!1===r)for(var a=0;a<this.drawOrder.length;a+=1){var s=this.elements[this.drawOrder[a]];null==t.elements||null==t.elements[this.drawOrder[a]]||o<(s=s.animateToState(t.elements[this.drawOrder[a]],n,r,i))&&(o=s)}return o}},{key:"dissolveInToState",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.8,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=0;if(0===(i=vl(xl(e.prototype),"dissolveInToState",this).call(this,t,n,r)))return 0;for(var o=0;o<this.drawOrder.length;o+=1){var a=this.elements[this.drawOrder[o]];null==t.elements||null==t.elements[this.drawOrder[o]]||i<(a=a.dissolveInToState(t.elements[this.drawOrder[o]],n,r))&&(i=a)}return i}},{key:"setTimeDelta",value:function(t){vl(xl(e.prototype),"setTimeDelta",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].setTimeDelta(t)}},{key:"isStateSame",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1],r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];if(!1===vl(xl(e.prototype),"isStateSame",this).call(this,t,n,r))return!1;for(var i=0;i<this.drawOrder.length;i+=1){var o=this.elements[this.drawOrder[i]];if(null!=t.elements&&null!=t.elements[this.drawOrder[i]]&&!1===o.isStateSame(t.elements[this.drawOrder[i]],n,r))return!1}return!0}},{key:"clearFrozenPulseTransforms",value:function(){vl(xl(e.prototype),"clearFrozenPulseTransforms",this).call(this);for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].clearFrozenPulseTransforms()}},{key:"freezePulseTransforms",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];vl(xl(e.prototype),"freezePulseTransforms",this).call(this,t);for(var n=0;n<this.drawOrder.length;n+=1)this.elements[this.drawOrder[n]].freezePulseTransforms(t)}},{key:"isAnimating",value:function(){if(!1===this.isShown)return!1;if(vl(xl(e.prototype),"isAnimating",this).call(this))return!0;for(var t=0;t<this.drawOrder.length;t+=1)if(this.elements[this.drawOrder[t]].isAnimating())return!0;return!1}},{key:"remove",value:function(t){var e;null!=this.elements[t]&&((e=this.elements[t]).animations.cancelAll("freeze",!0),e.stop(),e.parent=null,e.animations=null,e.move.element=null,e.recorder=null,e.figure=null,delete this.elements["_".concat(t)],delete this.elements[t],-1!==(t=this.drawOrder.indexOf(t))&&this.drawOrder.splice(t,1))}},{key:"stopAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];if(vl(xl(e.prototype),"stopAnimating",this).call(this,t,n),r)for(var i=0;i<this.drawOrder.length;i+=1)this.elements[this.drawOrder[i]].stopAnimating(t,n,r)}},{key:"stateSet",value:function(){vl(xl(e.prototype),"stateSet",this).call(this);for(var t=0;t<this.drawOrder.length;t+=1)this.elements[this.drawOrder[t]].stateSet()}},{key:"_state",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(this.notifications.publish("getState"),e=null==(e=t.returnF1Type)||e)return{f1Type:"de",state:this.getPath()};var e=(e=ft({},t,{returnF1Type:!0})).min?Ci(this,this._getStatePropertiesMin(),e):Ci(this,this._getStateProperties(e),e);return t=Ci(this.elements,Object.keys(this.elements),t),e.elements=t,e}},{key:"align",value:function(t,e){var n=this.getBoundingRect("draw"),r=new Oe(0,0);r.x="left"===t?-n.left:"center"===t?-n.left+n.width/2:"right"===t?-n.right:-n.left+n.width*t,r.y="bottom"===e?-n.bottom:"middle"===e?-n.bottom+n.height/2:"top"===e?-n.top:-n.bottom+n.height*e;for(var i=0;i<this.drawOrder.length;i+=1){var o=this.elements[this.drawOrder[i]],a=o.transform.t();o.transform.updateTranslation(a.add(r))}}}]),e}();function Bl(t,e,n){return(Bl=function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),1}catch(t){return}}}()?Reflect.construct:function(t,e,n){var r=[null];return r.push.apply(r,e),r=new(Function.bind.apply(t,r)),n&&Fl(r,n.prototype),r}).apply(null,arguments)}function Fl(t,e){return(Fl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var Il=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);for(var n,r={finishedCallback:null},i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return e instanceof Cl?(n=ft.apply(void 0,[{},r].concat(o))).element=e:n=ft.apply(void 0,[{},r,e].concat(o)),this.timeKeeper=n.timeKeeper,this.recorder=n.recorder,this.element=n.element,this.animations=[],this.state="idle",this.options={translation:{}},this.fnMap=new X,this.finishedCallback=n.finishedCallback,this.notifications=new It,this.customSteps=[],this.animationSpeed=1,this}var e=[{key:"new",value:function(t){var e={customSteps:this.customSteps,timeKeeper:this.timeKeeper};return null!=this.element&&(e.element=this.element),null!=t&&(e.name=t),e=new Ul(e),this.animations.push(e),null!=this.element&&this.element.animateNextFrame(),e}},{key:"setTimeSpeed",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;this.animations.forEach((function(n){n.setTimeSpeed(t.animationSpeed,e,t.timeKeeper.now()/1e3)})),this.animationSpeed=e}},{key:"builder",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Bl(Ul,[this.element,{customSteps:this.customSteps,timeKeeper:this.timeKeeper}].concat(e))}},{key:"rotation",value:function(t){return t="number"==typeof t||Array.isArray(t)?{target:t}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"RotationAnimationStep")}},{key:"scale",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return t="number"==typeof t&&null==e?{target:[t,t,t]}:"number"==typeof t?{target:[t,e,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0]}:Te(t)?{target:Ae(t)}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ScaleAnimationStep")}},{key:"trigger",value:function(t){return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="function"==typeof t||"string"==typeof t?{callback:t}:t),new ja(t)}},{key:"custom",value:function(t){return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="string"==typeof t||"function"==typeof t?{callback:t}:t),new Na(t)}},{key:"delay",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),new rs(t)}},{key:"translation",value:function(t){this.position(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)}},{key:"position",value:function(t){return t="number"==typeof t?{target:[t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0]}:Te(t)?{target:Ae(t)}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"PositionAnimationStep")}},{key:"color",value:function(t){return t=Array.isArray(t)?{target:t}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ColorAnimationStep")}},{key:"opacity",value:function(t){return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="number"==typeof t?{target:t}:t),this.getStep(t,"OpacityAnimationStep")}},{key:"transform",value:function(t){return t=tn(t)?{target:rn(t)}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"TransformAnimationStep")}},{key:"pulseTransform",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{element:this.element,timeKeeper:this.timeKeeper}].concat(e));return this.getStep(r,"PulseTransformAnimationStep")}},{key:"pulse",value:function(t){return(t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="number"==typeof t?{scale:t}:t)).centerOn?new Aa(t):this.getStep(t,"PulseAnimationStep")}},{key:"dissolveIn",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DissolveInAnimationStep")}},{key:"dissolveOut",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DissolveOutAnimationStep")}},{key:"dim",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"DimAnimationStep")}},{key:"undim",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.getStep(t,"UndimAnimationStep")}},{key:"getStep",value:function(t,e){if(t.timeKeeper=this.timeKeeper,"string"==typeof t.element&&null!=this.element&&(t.element=this.element.getElement(t.element)),null==t.elements||null==t.element)return new h[e](t);var n=t.element.getElements(t.elements),r=[];return t.elements=void 0,n.forEach((function(n){t.element=n,r.push(new h[e](t))})),new fo(t,{steps:r})}},{key:"scenario",value:function(t){return t="string"==typeof t||void 0!==t.transform||void 0!==t.position||void 0!==t.rotation||void 0!==t.scale||void 0!==t.translation||void 0!==t.color||void 0!==t.isShown?{target:t}:t,t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t),this.getStep(t,"ScenarioAnimationStep")}},{key:"scenarios",value:function(t){var e="string"==typeof t?{target:t}:t,n=(e=(t=ft({},{element:this.element,timeKeeper:this.timeKeeper},e)).element.getAllElementsWithScenario(t.target),[]),r={};return dt(t,r,["steps","element"]),e.forEach((function(t){n.push(t.animations.scenario(r))})),new fo(r,{steps:n})}},{key:"_state",value:function(t){return Ci(this,["animations","state","options","element"],t)}},{key:"setTimeDelta",value:function(t){this.animations.forEach((function(e){e.setTimeDelta(t)}))}},{key:"willStartAnimating",value:function(){if("animating"===this.state)return!0;var t=!1;return this.animations.forEach((function(e){"waitingToStart"!==e.state&&"animating"!==e.state||(t=!0)})),t}},{key:"isAnimating",value:function(){if("animating"===this.state||"waitingToStart"===this.state)return!0;for(var t=0;t<this.animations.length;t+=1){var e=this.animations[t];if("waitingToStart"===e.state||"animating"===e.state)return!0}return!1}},{key:"nextFrame",value:function(t){var e=this,n=[],r=null,i=!1;this.animations.forEach((function(o,a){var s,l=!1;"waitingToStart"!==o.state&&"animating"!==o.state||((s=o.nextFrame(t,e.animationSpeed))<(r=null===r?s:r)&&(r=s),l=!0),"finished"===o.state&&o.removeOnFinish&&(l=!1,n.push(a)),l&&(i=!0)}));var o=null;i?this.state="animating":("animating"===this.state&&(this.state="idle",o=this.finishedCallback,this.notifications.publish("finished")),this.state="idle",null===r&&(r=0));for(var a=n.length-1;0<=a;--a)this.animations.splice(n[a],1);return this.fnMap.exec(o),r}},{key:"cleanAnimations",value:function(){for(var t=[],e=!1,n=0;n<this.animations.length;n+=1){var r=this.animations[n];"finished"===r.state&&r.removeOnFinish?t.push(n):"animating"!==r.state&&"waitingToStart"!==r.state||(e=!0)}for(var i=t.length-1;0<=i;--i)this.animations.splice(t[i],1);e?this.state="animating":("animating"===this.state&&(this.state="idle",this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),this.state="idle")}},{key:"cancel",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(null==t)this.cancelAll(e);else{for(var n=0;n<this.animations.length;n+=1){var r=this.animations[n];r.name===t&&r.cancel(e)}this.cleanAnimations()}}},{key:"get",value:function(t){for(var e=0;e<this.animations.length;e+=1)if(this.animations[e].name===t)return this.animations[e];return null}},{key:"cancelAll",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=0;n<this.animations.length;n+=1)!e&&this.animations[n].name.startsWith("_noStop_")||this.animations[n].cancel(t);this.cleanAnimations()}},{key:"getFrameTime",value:function(t){this.timeKeeper.getWhen(t)}},{key:"start",value:function(t){var e=(t=ft({},t,{name:null,startTime:"nextFrame"})).name,n=(t=t.startTime,this.getFrameTime(t));if(null==e)this.startAll(t);else for(var r=0;r<this.animations.length;r+=1){var i=this.animations[r];i.name===e&&"animating"!==i.state&&(i.start(n),i.finishIfZeroDuration(),"animating"===i.state&&(this.state="animating"))}"idle"===this.state&&(this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),null!=this.element&&this.element.animateNextFrame()}},{key:"startAll",value:function(t){t=ft({},t,{startTime:"nextFrame"}).startTime;for(var e=this.getFrameTime(t),n=0;n<this.animations.length;n+=1){var r=this.animations[n];"animating"!==r.state&&(r.start(e),r.finishIfZeroDuration(),"animating"===r.state&&(this.state="animating"))}"idle"===this.state&&(this.fnMap.exec(this.finishedCallback),this.notifications.publish("finished")),null!=this.element&&this.element.animateNextFrame()}},{key:"getTotalDuration",value:function(){for(var t=0,e=0;e<this.animations.length;e+=1){var n=this.animations[e].getTotalDuration();if(null==n)return null;t<n&&(t=n)}return t}},{key:"getRemainingTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.timeKeeper.now()/1e3,n=0,r=[];return r="string"==typeof t?[t]:t,this.animations.forEach((function(t){0<r.length&&-1===r.indexOf(t.name)||(t=t.getRemainingTime(e),n<t&&(n=t))})),n}},{key:"getNextAnimationFinishTime",value:function(){for(var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3,n=!1,r=0;r<this.animations.length;r+=1){var i=this.animations[r].getRemainingTime(e);null===i?n=!0:(0<i&&void 0===t||0<i&&i<t)&&(t=i)}return void 0===t?n?null:0:t}},{key:"addTo",value:function(t){for(var e=0;e<this.animations.length;e+=1){var n=this.animations[e];if(n.name===t)return n}return this.new(t)}},{key:"newFromStep",value:function(t){return this.animations.push(t),t}},{key:"_dup",value:function(){var e=new t;return dt(this,e,["element","recorder","timeKeeper"]),e.element=this.element,e.recorder=this.recorder,e.timeKeeper=this.timeKeeper,e}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Dl(t){return(Dl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ll(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function zl(t,e,n){return(zl="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Hl(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Wl(t,e){return(Wl=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Nl(t,e){if(e&&("object"===Dl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return ql(t)}function ql(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Hl(t){return(Hl=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ul=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Wl(t,e)}(i,Xa);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Hl(e);return Nl(this,n?(t=Hl(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);for(var n,o={customSteps:[]},a=arguments.length,s=new Array(1<a?a-1:0),l=1;l<a;l++)s[l-1]=arguments[l];return e instanceof Cl?(n=ft.apply(void 0,[{},o].concat(s))).element=e:n=ft.apply(void 0,[{},o,e].concat(s)),(t=r.call(this,n)).element=n.element,t._stepType="builder",n.customSteps.forEach((function(e){t[e.name]=function(){for(var n={element:t.element},r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=ft.apply(void 0,[{},n].concat(i)),t.then(e.step(n)),ql(t)}})),Nl(t,ql(t))}return t=[{key:"fnExec",value:function(t){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return null==this.element?(e=this.fnMap).exec.apply(e,[t].concat(r)):(e=this.fnMap).execOnMaps.apply(e,[t,[this.element.fnMap.map]].concat(r))}},{key:"_getStateProperties",value:function(){return[].concat(function(t){if(Array.isArray(t))return Ll(t)}(t=zl(Hl(i.prototype),"_getStateProperties",this).call(this))||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Ll(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ll(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["element"]);var t}},{key:"_getStateName",value:function(){return"animationBuilder"}},{key:"custom",value:function(t){return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="string"==typeof t||"function"==typeof t?{callback:t}:t),this.then(new Na(t)),this}},{key:"rotation",value:function(t){return this.addStep("rotation",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)}},{key:"position",value:function(t){return this.addStep("position",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)}},{key:"translation",value:function(t){return this.position(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)}},{key:"scale",value:function(t){return this.addStep("scale",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)}},{key:"transform",value:function(t){return this.addStep("transform",t)}},{key:"pulseTransforms",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.addStep.apply(this,["pulseTransform"].concat(e))}},{key:"scenario",value:function(t){return this.addStep("scenario",t)}},{key:"scenarios",value:function(t){return this.addStep("scenarios",t)}},{key:"color",value:function(t){return this.addStep("color",t)}},{key:"opacity",value:function(t){return this.addStep("opacity",t)}},{key:"dissolveOut",value:function(){return this.addStep("dissolveOut",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dissolveIn",value:function(){return this.addStep("dissolveIn",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"addStep",value:function(t){if(null!=this.element){for(var e,n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.then((e=this.element.animations)[t].apply(e,r))}return this}},{key:"dim",value:function(){return this.addStep("dim",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"undim",value:function(){return this.addStep("undim",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}},{key:"delay",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t=ft({},{timeKeeper:this.timeKeeper},"number"==typeof t?{duration:t}:t),this.then(is(t)),this}},{key:"trigger",value:function(t){return t=ft({},{element:this.element,timeKeeper:this.timeKeeper},t="function"==typeof t||"string"==typeof t?{callback:t}:t),this.then(Ra(t)),this}},{key:"inParallel",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return this.then(po.apply(h,[t,{timeKeeper:this.timeKeeper}].concat(n))),this}},{key:"inSerial",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return this.then($a.apply(h,[t,{timeKeeper:this.timeKeeper}].concat(n))),this}},{key:"pulse",value:function(t){return this.addStep("pulse",t)}},{key:"reset",value:function(){this.steps=[],this.state="idle"}},{key:"_dup",value:function(){var t=new i;return dt(this,t,["element"]),dt(this,t,["element","timeKeeper"]),t.timeKeeper=this.timeKeeper,t.element=this.element,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();const Kl=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.figure=e,this.start=this.figure.touchDownHandlerClient.bind(this.figure),this.end=this.figure.touchUpHandler.bind(this.figure),this.move=this.figure.touchMoveHandlerClient.bind(this.figure),this.free=this.figure.touchFreeHandler.bind(this.figure),this.toggleCursor=this.figure.toggleCursor.bind(this.figure),this.binds={mouseDownHandler:this.mouseDownHandler.bind(this),mouseUpHandler:this.mouseUpHandler.bind(this),mouseMoveHandler:this.mouseMoveHandler.bind(this),touchStartHandler:this.touchStartHandler.bind(this),touchEndHandler:this.touchEndHandler.bind(this),touchMoveHandler:this.touchMoveHandler.bind(this)},this.addEvent("mousedown",this.binds.mouseDownHandler,!1),this.addWindowEvent("mouseup",this.binds.mouseUpHandler,!1),this.addEvent("mousemove",this.binds.mouseMoveHandler,!1),this.addEvent("touchstart",this.binds.touchStartHandler,!1),this.addWindowEvent("touchend",this.binds.touchEndHandler,!1),this.addEvent("touchmove",this.binds.touchMoveHandler,!1),this.enable=!0}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,[{key:"addEvent",value:function(t,e,n){this.figure.gestureCanvas.addEventListener(t,e.bind(this),n)}},{key:"addWindowEvent",value:function(t,e,n){window.addEventListener(t,e.bind(this),n)}},{key:"removeEvent",value:function(t,e,n){this.figure.gestureCanvas.removeEventListener(t,e.bind(this),n)}},{key:"startHandler",value:function(t){return!!this.enable&&(this.mouseDown=!0,this.previousPoint=t,this.start(t))}},{key:"endHandler",value:function(){this.mouseDown=!1,this.end(!1,!0)}},{key:"moveHandler",value:function(t,e){this.enable&&this.mouseDown?(this.move(this.previousPoint,e)&&t.preventDefault(),this.previousPoint=e):this.free(e)}},{key:"touchStartHandler",value:function(t){var e=t.touches[0];this.startHandler(new Oe(e.clientX,e.clientY))&&t.preventDefault()}},{key:"mouseDownHandler",value:function(t){this.startHandler(new Oe(t.clientX,t.clientY))&&t.preventDefault()}},{key:"touchMoveHandler",value:function(t){var e=t.touches[0];this.moveHandler(t,new Oe(e.clientX,e.clientY))}},{key:"mouseMoveHandler",value:function(t){this.moveHandler(t,new Oe(t.clientX,t.clientY))}},{key:"mouseUpHandler",value:function(){this.endHandler()}},{key:"touchEndHandler",value:function(){this.endHandler()}},{key:"destroy",value:function(){this.removeEvent("mousedown",this.binds.mouseDownHandler,!1),this.removeEvent("mouseup",this.binds.mouseUpHandler,!1),this.removeEvent("mousemove",this.binds.mouseMoveHandler,!1),this.removeEvent("touchstart",this.binds.touchStartHandler,!1),this.removeEvent("touchend",this.binds.touchEndHandler,!1),this.removeEvent("touchmove",this.binds.touchMoveHandler,!1)}}]),t}(),Vl=function(){function t(e){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.canvas=e,this.ctx=this.canvas.getContext("2d");var n=this.ctx.webkitBackingStorePixelRatio||this.ctx.mozBackingStorePixelRatio||this.ctx.msBackingStorePixelRatio||this.ctx.oBackingStorePixelRatio||this.ctx.backingStorePixelRatio||1;1===(e=window.devicePixelRatio||1)&&(e=2),this.ratio="number"==typeof n?e/n:1,this.resize()}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,[{key:"resize",value:function(){this.ctx.setTransform(1,0,0,1,0,0),this.canvas.width=this.canvas.clientWidth*this.ratio,this.canvas.height=this.canvas.clientHeight*this.ratio,this.ctx.scale(this.ratio,this.ratio)}},{key:"_dup",value:function(){return this}}]),t}();function Gl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Yl(t,e){var n="",r="";return null!=(e=1<arguments.length&&void 0!==e?e:null)&&(r=' style="margin-top:'.concat(e,'%"')),Array.isArray(t)?t.forEach((function(t,e){t.startsWith("<")?n+=t:n+=(0===e?'<p style="margin-top:'.concat(r,'">'):"<p>").concat(t,"</p>")})):n=t,n}function Xl(){var t=Yl(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",0);return'<div style="display: table; height: 100%; width: 100%;">\n <div style="display: table-cell; vertical-align: middle; height: 100%; width: 100%;">\n '.concat(t,"</div></div>")}function $l(){var t=Yl(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"");return'<div style="text-align:center;">\n '.concat(t,"</div>")}var Jl=function(t,e){return'<span class="figureone__unit_deg">'.concat(t,'</span><span class="figureone__unit_rad">').concat(e,"</span>\n ")};function Zl(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i="";return e&&(i=' id="'.concat(e,'"')),e="",n&&(e=' class="'.concat(n,'"')),n="",r&&(n=' style="color:'.concat(no(r),';"')),{replacementText:"<span".concat(i).concat(e,'"').concat(n,">").concat(t.replace(RegExp(/_/,"gi")," ").trim(),"</span>")}}function Ql(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r="action_word",i=null,o=s={color:null,id:"figureone__id_".concat(mt()),interactive:!0,classes:"",text:null};Array.isArray(n)?i=n:null!=n&&(o=ft(s,n));var a=o,s=a.interactive,l=(n=a.color,a.id),u=(o=a.classes,a.text);return null!=n&&(i=n),s&&(r="".concat(r," interactive_word")),""!==o&&(r="".concat(r," ").concat(o)),{replacementText:function(t){return Zl(u||t,l,r,i)},id:function(){return l},actionMethod:t,bind:e}}function tu(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",i=document.getElementById(t);i&&(i.classList.add("action_word_enabled"),r.split(" ").forEach((function(t){t&&i.classList.add(t)})),i.onclick=function(){var t;e.bind.apply(e,function(t){if(Array.isArray(t))return Gl(t)}(t=n)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Gl(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Gl(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())()})}function eu(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"highlight_word",r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],i=t;return Object.keys(e).forEach((function(t){var n=e[t],r=i,o=t,a=n;t=new RegExp("\\|".concat(o,"\\|"),"gi"),n="string"==typeof a?a:("string"==typeof a.replacementText?a:a.replacementText(o)).replacementText,i=r.replace(t,n)})),t=RegExp(/\|([^|]*)\|/gi),i=i.replace(t,'<span class="'.concat(n,'">$1</span>')),r&&(r=RegExp(/style="color:rgba\([^)]*\);"/gi),i=i.replace(r,""),r=RegExp(/highlight_word/gi),i=i.replace(r,""),r=RegExp(/interactive_word/gi),i=i.replace(r,""),r=RegExp(/id="[^"]*"/gi),i=i.replace(r,"")),i}function nu(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";Object.keys(t).forEach((function(n){var r=t[n];"string"!=typeof r&&"actionMethod"in r&&tu("string"==typeof r.id?r.id:r.id(n),r.actionMethod,r.bind,e)}))}function ru(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";e=eu(e,n),t.innerHTML=e,nu(n,r)}function iu(t){return(iu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ou(t,e){return(ou=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function au(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function su(t){return(su=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var lu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ou(t,e)}(r,jl);var t,e,n=(t=r,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,r=su(t);return function(t,e){if(e&&("object"===iu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return au(t)}(this,e?(n=su(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))});function r(){var t;!function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this);for(var e,i,o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return i=function(e){return"string"==typeof e?t.shapeNameMap[e]:e},"getIndex"in(e=au(t=n.call.apply(n,[this].concat(a))))?Object.defineProperty(e,"getIndex",{value:i,enumerable:!0,configurable:!0,writable:!0}):e.getIndex=i,t}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,[{key:"setPointsBetween",value:function(t,e,n){this.drawingObject.updateUniform("u_from",this.getIndex(t)),this.drawingObject.updateUniform("u_to",this.getIndex(e)),this.drawingObject.updateUniform("u_percent",n)}},{key:"setPoints",value:function(t){this.drawingObject.updateUniform("u_from",this.getIndex(t)),this.drawingObject.updateUniform("u_to",this.getIndex(t)),this.drawingObject.updateUniform("u_percent",0)}}]),r}();function uu(t){return(uu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function cu(t,e){return(cu=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function hu(t){return(hu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const fu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&cu(t,e)}(i,Us);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=hu(e);return function(t,e){if(e&&("object"===uu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=hu(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){var n;return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),(n=r.call(this,t,"withTexture","text")).glPrimitive=t.gl.TRIANGLE_FAN,e=ft({},{text:"DEFAULT_TEXT",size:"20px",family:"Helvetica",style:"normal",weight:400,xAlign:"center",yAlign:"alphabetic",id:mt("vertexText")},e),n.size=e.size,n.text=e.text,n.family=e.family,n.xAlign=e.xAlign,n.yAlign=e.yAlign,n.style=e.style,n.weight=e.weight,n.canvas=document.createElement("canvas"),n.canvas.id=e.id,n.ctx=n.canvas.getContext("2d"),n.texture={id:e.id,mapTo:new En(-1,-1,2,2),mapFrom:new En(0,0,1,1),repeat:!1,src:"",points:[],buffer:n.gl.createBuffer(),type:"image",data:null},n.type="vertexText",n.drawTextIntoBuffer(),n}return t=[{key:"resizeText",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(1,1),n=this.canvas.width*e.x,r=this.canvas.height*e.y,i=new Oe(0,0);"center"===this.xAlign?i.x=-n/2:"right"===this.xAlign&&(i.x=-n),"baseline"===this.yAlign?i.y=.25*-r:"top"===this.yAlign?i.y=-r:"middle"===this.yAlign&&(i.y=-r/2),e=[i,new Oe(i.x,i.y+r),new Oe(i.x+n,i.y+r),new Oe(i.x+n,i.y)],this.width=n,this.height=r,this.calcAscentDescent(),this.points=[],e.forEach((function(e){t.points.push(e.x),t.points.push(e.y)})),this.border=[[new Oe(i.x,-this.descent),new Oe(i.x,this.ascent),new Oe(i.x+n,this.ascent),new Oe(i.x+n,-this.descent)]],null!=(n=this.texture)&&(n.points=[0,0,0,1,1,1,1,0],n.data=this.ctx.canvas,n.buffer&&this.resetBuffers())}},{key:"calcAscentDescent",value:function(){var t=.75,e=0,n=this.text.match(/[,.]/g);Array.isArray(n)&&n.length===this.text.length&&(t=.1),n=this.text.match(/[acemnorsuvwxz*gyq:><;p=]/g),Array.isArray(n)&&n.length===this.text.length&&(t=.5),n=this.text.match(/[;,$]/g),Array.isArray(n)&&0<n.length&&(e=.1),n=this.text.match(/[gjyqp@Q(){}[\]|]/g),Array.isArray(n)&&0<n.length&&(e=.25),this.ascent=t*this.height,this.descent=e*this.height}},{key:"drawTextIntoBuffer",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(1,1),e=20;(e="string"==typeof this.size&&this.size.endsWith("px")?parseInt(this.size,10):m(("string"==typeof this.size?parseFloat(this.size):this.size)/t.x,0))<1&&(e=1),this.ctx.font="".concat(this.style," ").concat(this.weight," ").concat(e,"px ").concat(this.family);var n=this.ctx.measureText(this.text).width+.3*e,r=1.15*e;this.canvas.width=Math.max(n,1),this.canvas.height=Math.max(r,1),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.font="".concat(this.style," ").concat(this.weight," ").concat(e,"px ").concat(this.family),this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",this.ctx.fillStyle="white",r=.75*this.canvas.height,this.ctx.fillText(this.text,.3*e/2,r),this.resizeText(t)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function du(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function pu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return mu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function yu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function vu(t,e,n,r){var i=!(2<arguments.length&&void 0!==n)||n,o=3<arguments.length&&void 0!==r?r:"negative";if("number"!=typeof e)return e;if(0===e)return t;var a=[];return t.forEach((function(t){for(var n,r=[],s=[],l=0;l<t.length;l+=1){var u=0===l?t[t.length-1]:t[l-1];u=je(l===t.length-1?(function(t){if(Array.isArray(t))return t}(n=t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,r,i=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(i.push(n.value),1!==i.length);o=!0);}catch(t){a=!0,r=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw r}}return i}}(n)||function(t){if(t){if("string"==typeof t)return yu(t,1);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?yu(t,1):void 0}}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]:t[l+1],t[l],u),(i&&u<Math.PI||!1===i)&&(0===r.length||t[l].isNotEqualTo(r[r.length-1]))&&(r.push(t[l]),s.push(l))}for(var c=[],h=[],f=0;f<r.length;f+=1){var d=void 0;d=0===f?new Ie(r[r.length-1],r[0]):new Ie(r[f-1],r[f]),h.push(d.offset(o,e))}for(var p=0;p<h.length;p+=1){var m,y=void 0,v=(y=0===p?h[h.length-1]:h[p-1],h[p]),g=v.intersectsWith(y);null!=g.intersect&&(m=void 0,m=0===p?r[r.length-1]:r[p-1],g.intersect.distance(m)>1.2*e?(m=new Ie(m,g.intersect),m=new Ie({p1:m.pointAtLength(1.2*e),length:1,angle:m.angle()+Math.PI/2}),y=y.intersectsWith(m),m=v.intersectsWith(m),null!=y.intersect&&null!=m.intersect?(c.push(y.intersect),c.push(m.intersect)):c.push(g.intersect)):c.push(g.intersect))}a.push(c)})),a}function gu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||wu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bu(t){return function(t){if(Array.isArray(t))return xu(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||wu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function wu(t,e){if(t){if("string"==typeof t)return xu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xu(t,e):void 0}}function xu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Su(t,e){function n(e){var n,r=t[e];null!=r&&"string"!=typeof r&&"number"!=typeof r&&(n=function t(e){for(var n=0;n<e.length;n+=1)Array.isArray(e[n])&&"number"!=typeof e[n][0]?e[n]=t(e[n]):e[n]=Ae(e[n]);return e},Array.isArray(r)&&"number"!=typeof r[0]?t[e]=n(r):t[e]=Ae(r))}"string"==typeof e?n(e):e.forEach(n)}function Tu(t,e){null!=e.pulse&&"function"!=typeof t.pulseDefault&&"string"!=typeof t.pulseDefault&&("number"==typeof e.pulse?t.pulseDefault.scale=e.pulse:t.pulseDefault=ft({},t.pulseDefault,e.pulse))}var Au=function(){function t(e,n,r,i,o,a,s,l,u,c,h,f){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),Array.isArray(e)?this.webgl=e:this.webgl=[e],Array.isArray(n)?this.draw2D=n:this.draw2D=[n],this.htmlCanvas=r,this.scene=i,this.animateNextFrame=o,this.defaultColor=a,this.defaultDimColor=s,this.defaultFont=l,this.defaultLineWidth=u,this.defaultLength=c,this.timeKeeper=h,this.recorder=f}var e=[{key:"gl",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{}].concat(e)),i={glPrimitive:"TRIANGLES",vertexShader:{dimension:2},fragmentShader:{color:"uniform"},attributes:[],texture:{src:"",mapTo:new En(-1,-1,2,2),mapFrom:new En(0,0,1,1),mapToAttribute:"a_vertex",repeat:!1,onLoad:this.animateNextFrame,coords:[],loadColor:[0,0,1,.5]},name:mt("primitive_"),color:this.defaultColor,transform:[["s",1],["r",0,0,0,1],["t",0,0,0]],dimension:2};null!=r.texture&&(i.vertexShader.color="texture",i.fragmentShader.color="texture"),null!=r.dimension&&(i.vertexShader.dimension=r.dimension),"LINES"===r.glPrimitive&&(i.vertexShader.light=null,i.fragmentShader.light=null),null!=r.light&&(i.vertexShader.light=r.light,i.fragmentShader.light=r.light),null!=r.colors&&(i.vertexShader.color="vertex",i.fragmentShader.color="vertex"),(r=ft({},i,r)).transform=rn(r.transform),null!=r.position&&(r.position=Ae(r.position),r.transform.updateTranslation(r.position));var o=new Cs(this.webgl[0],r.vertexShader,r.fragmentShader);o.setPrimitive(r.glPrimitive.toUpperCase()),null!=r.vertices&&(Array.isArray(r.vertices)?r.attributes.push({name:"a_vertex",data:r.vertices,size:r.dimension}):r.attributes.push({name:"a_vertex",data:r.vertices.data,size:r.vertices.size||r.dimension,usage:r.vertices.usage})),null!=r.normals&&null!==r.light&&"ambient"!==r.light&&(Array.isArray(r.normals)?r.attributes.push({name:"a_normal",data:r.normals,size:3}):r.attributes.push({name:"a_normal",data:r.normals.data,size:3,usage:r.normals.usage})),null!=r.colors&&(Array.isArray(r.colors)?r.attributes.push({name:"a_color",data:r.colors,size:4}):r.colors.normalize?r.attributes.push({name:"a_color",data:r.colors.data,size:r.colors.size||4,usage:r.colors.usage,type:"UNSIGNED_BYTE",normalize:!0}):r.attributes.push({name:"a_color",data:r.colors.data,size:r.colors.size||4,usage:r.colors.usage,type:"UNSIGNED_BYTE",normalize:!1})),null!=r.attributes&&r.attributes.forEach((function(t){t=ft({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:2},t),o.addAttribute(t.name,t.size,t.data,t.type,t.normalize,t.stride,t.offset,t.usageIn)})),null!=r.uniforms&&r.uniforms.forEach((function(t){t=ft({},{type:"FLOAT",length:1},t),o.addUniform(t.name,t.length,t.type,t.value)})),""!==r.texture.src&&(a=r.texture,o.addTexture(a.src,Mn(a.mapFrom),Mn(a.mapTo),a.mapToAttribute,a.coords||[],a.repeat,a.onLoad,a.loadColor));var a=new jl(o,r.transform,r.color,null,r.name);return a.custom.updateAttribute=a.drawingObject.updateAttribute.bind(a.drawingObject),a.custom.updateVertices=a.drawingObject.updateVertices.bind(a.drawingObject),a.custom.updateUniform=a.drawingObject.updateUniform.bind(a.drawingObject),a.custom.getUniform=a.drawingObject.getUniform.bind(a.drawingObject),a.dimColor=this.defaultDimColor.slice(),null!=r.move&&!1!==r.move&&(a.setTouchable(),a.setMovable(),a.setMove(r.move)),null!=r.touch&&a.setTouchable(r.touch),null!=r.dimColor&&(a.dimColor=r.dimColor),null!=r.defaultColor&&(a.defaultColor=r.dimColor),null!=r.scenarios&&(a.scenarios=r.scenarios),null!=r.scene&&(r.scene instanceof Pi?a.scene=r.scene:a.setScene(r.scene)),a.timeKeeper=this.timeKeeper,a.recorder=this.recorder,Tu(a,r),a}},{key:"generic3",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];function r(t,e){if(null==t.usage&&(t.usage=e),null!=t.points&&(t.vertices=t.points),null!=t.copy){if(null!=t.vertices&&(t.vertices=Ls(t.vertices,t.copy,"points")),null!=t.normals&&(t.normals=Ls(t.normals,t.copy,"normals")),null!=t.colors){for(var n=zs(t.copy),r=[],i=0;i<n;i+=1)r.push.apply(r,bu(t.colors.map((function(t){return t.slice()}))));t.colors=r}if(null!=t.texture&&null!=t.texture.coords){for(var a=zs(t.copy),s=[],l=0;l<a;l+=1)s.push.apply(s,bu(t.texture.coords.slice()));t.texture.coords=s}}null!=t.points&&(t.vertices=Vn(ke(t.vertices),o),t.vertices={data:t.vertices,usage:t.usage,size:o}),null!=t.normals&&Array.isArray(t.normals)&&(t.normals=Vn(ke(t.normals),o),t.normals={data:t.normals,usage:t.usage,size:o}),null!=t.colors&&(t.colors=Vn(t.colors,o)),null!=t.drawType&&(t.glPrimitive=t.drawType.toUpperCase())}var i=ft.apply(void 0,[{}].concat(e)),o=(i=ft({},{dimension:3,light:i.lines?null:"directional",usage:"STATIC"},i)).dimension;r(i,"STATIC");var a=i.usage,s=this.gl(i);return s.custom.updateGeneric3=function(t){r(t,a),t.vertices&&(s.custom.updateVertices(t.vertices.data),null!=t.texture&&null!=t.texture.coords?s.drawingObject.updateTextureMap(t.texture.coords):null!=t.texture&&null!=s.drawingObject.texture&&(null!=s.drawingObject.texture.points?s.drawingObject.updateTextureMap(s.drawingObject.texture.points):s.drawingObject.updateTextureMap([]))),t.normals&&null!=s.drawingObject.attributes.a_normal&&s.custom.updateAttribute("a_normal",t.normals.data),t.colors&&s.custom.updateAttribute("a_color",t.colors),null!=t.drawType&&s.drawingObject.setPrimitive(t.drawType.toUpperCase()),null!=t.touchScale&&(s.touchScale=_e(t.touchScale))},s.custom.updatePoints=s.custom.updateGeneric3,s.timeKeeper=this.timeKeeper,s.recorder=this.recorder,Tu(s,i),s}},{key:"generic3DBase",value:function(t,e,n){e=ft({},t,e);var r=this.generic3(ft({},e,{points:[],normals:e.lines?null:[],glPrimitive:e.lines?"LINES":void 0}));return r.custom.options=e,r.custom.getPoints=n,r.custom.updatePoints=function(t){var e=ft({},r.custom.options,{transform:[],position:[0,0]},t);null!=(r.custom.options=e).transformPoints&&(e.transform=e.transformPoints),t=(n=gu(r.custom.getPoints(e),2))[0];var n=n[1];null==e.lines||!1===e.lines?r.custom.updateGeneric3(ft({},e,{points:t,normals:n})):r.custom.updateGeneric3(ft({},e,{points:t,normals:null}))},r.custom.updatePoints(),r}},{key:"sphere",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({radius:this.defaultLength,sides:10,normals:"flat",center:[0,0,0]},ft.apply(void 0,[{}].concat(e)),Dn)}},{key:"cube",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({side:this.defaultLength},ft.apply(void 0,[{}].concat(e)),$n)}},{key:"prism",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({length:this.defaultLength/3},ft.apply(void 0,[{}].concat(e)),Qn)}},{key:"cylinder",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({radius:this.defaultLength/20,sides:10,normals:"flat"},ft.apply(void 0,[{}].concat(e)),qn)}},{key:"cone",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({radius:this.defaultLength/20,sides:10,normals:"flat",length:1},ft.apply(void 0,[{}].concat(e)),Wn)}},{key:"line3",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({width:this.defaultLength/40,sides:10,normals:"curve"},ft.apply(void 0,[{}].concat(e)),Nn)}},{key:"revolve",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({sides:10,normals:"flat"},ft.apply(void 0,[{}].concat(e)),zn)}},{key:"surface",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.generic3DBase({normals:"flat",lines:!1},ft.apply(void 0,[{}].concat(e)),In)}},{key:"morph",value:function(){for(var t=this,e={name:mt("primitive_"),color:this.defaultColor,points:[],glPrimitive:"TRIANGLES",transform:(new Qe).scale(1,1).rotate(0).translate(0,0),position:[0,0]},n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var o=ft.apply(void 0,[{},e].concat(r));o.transform=rn(o.transform),null!=o.position&&(o.position=Ae(o.position),o.transform.updateTranslation(o.position));var a=!1;e="simple",Array.isArray(o.color[0])&&(a=!0,e="vertexColor");var s=new Cs(this.webgl[0],["morpher",o.points.length,a],e);s.setPrimitive(o.glPrimitive.toUpperCase());var l={};null!=o.names&&o.names.forEach((function(t,e){l[t]=e})),o.points.forEach((function(t,e){var n="a_pos".concat(e);s.numVertices=t.length/2,e=ft({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:2}),s.addAttribute(n,e.size,t,e.type,e.normalize,e.stride,e.offset,e.usageIn)})),a&&(o.color.forEach((function(t,e){if(4===(n=t).length)for(var n=Array(4*s.numVertices),r=0;r<n.length;r+=4)n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2],n[r+3]=t[3];var i="a_col".concat(e);e=ft({},{type:"FLOAT",normalize:!1,stride:0,offset:0,usage:"STATIC",size:4}),s.addAttribute(i,e.size,n,e.type,e.normalize,e.stride,e.offset,e.usageIn)})),o.color=this.defaultColor),s.addUniform("u_from",1,"INT"),s.addUniform("u_to",1,"INT"),s.addUniform("u_percent",1,"FLOAT");var u=new lu(s,o.transform,o.color,null,o.name);return u.shapeNameMap=l,u.setPoints(0),u.fnMap.add("_morphCallback",(function(t,e){var n=e.start;e=e.target,u.setPointsBetween(n,e,t)})),u.animations.morph=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},{progression:"easeinout",element:u}].concat(n));return i.customProperties={start:null==i.start?0:i.start,target:null==i.target?1:i.target},i.callback="_morphCallback",i.timeKeeper=t.timeKeeper,new Na(i)},u.animations.customSteps.push({step:u.animations.morph.bind(this),name:"morph"}),u.timeKeeper=this.timeKeeper,u.recorder=this.recorder,Tu(u,o),u}},{key:"generic",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];function r(t){null!=t.drawBorder?o.drawBorder=vr(t.drawBorder):null!=t.points&&(o.drawBorder=[ke(t.points)]),null!=t.drawBorderBuffer?o.drawBorderBuffer=vr(t.drawBorderBuffer):o.drawBorderBuffer=o.drawBorder,null!=t.border&&(o.border=vr(t.border)),null!=t.touchBorder&&(o.touchBorder=vr(t.touchBorder))}var i=ft.apply(void 0,[{}].concat(e)),o=this.generic3.apply(this,[{dimension:2,light:null,points:[]}].concat(e));return o.custom.updateGeneric=function(t){o.custom.updateGeneric3(t),r(t)},o.custom.updatePoints=o.custom.updateGeneric,r(i),o}},{key:"getPolylineTris",value:function(t){var e,n,r,i=ft({},{points:[[0,0],[1,0]],width:this.defaultLineWidth,color:this.defaultColor,close:!1,widthIs:"mid",cornerStyle:"auto",cornerSize:.01,cornerSides:10,cornersOnly:!1,cornerLength:.1,minAutoCornerAngle:Math.PI/7,dash:[],linePrimitives:!1,lineNum:1,drawBorder:"negative",drawBorderBuffer:0,simple:!1},t);!1===i.linePrimitives&&(i.lineNum=2),Su(i,["points","border","touchBorder"]),r=i.simple?(e=(t=gu(ai(i.points,i.width,i.close),3))[0],n=t[1],t[2]):i.cornersOnly?(e=(r=gu(ii(i.points,i.width,i.close,i.cornerLength,i.widthIs,i.cornerStyle,i.cornerSize,i.cornerSides,i.minAutoCornerAngle,i.linePrimitives,i.lineNum,i.drawBorderBuffer),3))[0],n=r[1],r[2]):(e=(o=gu(ri(i.points,i.width,i.close,i.widthIs,i.cornerStyle,i.cornerSize,i.cornerSides,i.minAutoCornerAngle,i.dash,i.linePrimitives,i.lineNum,i.drawBorder,i.drawBorderBuffer,i.arrow),3))[0],n=o[1],o[2]),Array.isArray(i.drawBorderBuffer)&&(r=vr(i.drawBorderBuffer)),Array.isArray(i.drawBorder)&&(n=vr(i.drawBorder)),null==r&&(r=n);var o="TRIANGLES";return i.linePrimitives&&(o="LINES"),[i,e,n,r,o=i.simple?"STRIP":o]}},{key:"polyline",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{}].concat(n)),o=this.generic.apply(this,[{transform:(new Qe).scale(1).rotate(0).translate(),border:"draw",touchBorder:"border"}].concat(n));return o.custom.options={points:[[0,0],[1,0]],width:this.defaultLineWidth,color:this.defaultColor,close:!1,widthIs:"mid",cornerStyle:"auto",cornerSize:.01,cornerSides:10,cornersOnly:!1,cornerLength:.1,minAutoCornerAngle:Math.PI/7,dash:[],linePrimitives:!1,lineNum:1,drawBorder:"line",drawBorderBuffer:0},o.custom.updatePoints=function(e){var n=(a=gu(t.getPolylineTris(ft({},o.custom.options,e)),5))[0],r=a[1],i=a[2],a=(e=a[3],a[4]);o.custom.options=n,o.custom.updateGeneric(ft({},n,{points:r,drawBorder:i,drawBorderBuffer:e,drawType:a}))},o.custom.updatePoints(i),o}},{key:"getPolygonBorder",value:function(t){var e=t;Su(e,["offset"]),null!=e.angleToDraw&&(e.sidesToDraw=Math.floor(e.angleToDraw/(2*Math.PI/e.sides))),null==e.sidesToDraw&&(e.sidesToDraw=e.sides),e.sidesToDraw>e.sides&&(e.sidesToDraw=e.sides);var n,r,i=Mr(e),o=0;return null!=e.line?(e.line=ft({},{width:this.defaultLineWidth,widthIs:"mid"},e.line),"inside"===e.line.widthIs&&1===e.direction?e.line.widthIs="positive":"inside"===e.line.widthIs&&-1===e.direction&&(e.line.widthIs="negative"),"outside"===e.line.widthIs&&1===e.direction?e.line.widthIs="negative":"outside"===e.line.widthIs&&-1===e.direction&&(e.line.widthIs="positive"),r=(n=e.line).width,t=n.widthIs,1===(n=e.direction)&&("negative"===t||"outside"===t)||-1===n&&("positive"===t||"inside"===t)?o=r:"mid"===t&&(o=r/2),0<o&&(r=(e.sides-2)*Math.PI/e.sides,o/=Math.sin(r/2)),e.sidesToDraw===e.sides?e.line.close=!0:e.line.close=!1):e.sidesToDraw!==e.sides&&null==e.line&&i.push(e.offset),[e,i,0===o?[i]:[Mr(ft({},e,{radius:e.radius+o}))],"TRIANGLES"]}},{key:"genericBase",value:function(t,e,n){var r=this,i=this.generic({transform:(new Qe).scale(1).rotate(0).translate(),border:"draw",touchBorder:"border"},n);return i.custom.options=e,i.custom.getFill=function(){return[]},i.custom.close=!0,i.custom.skipConcave=!0,i.custom.bufferOffset="negative",i.custom.getLine=function(t){return i.custom.close||null!=t.drawBorder||(t.drawBorder="line"),r.getPolylineTris(t)},i.custom.getBorder=function(){return[]},i.custom.updatePoints=function(t){var e,n,r,o=ft({},i.custom.options,t),a=gu(i.custom.getBorder(o),2);t=a[0],o=a[1],null==t.line?(e=(r=gu(i.custom.getFill(o,t),2))[0],n=r[1],i.custom.options=t,i.custom.updateGeneric(ft({},t,{points:e,drawBorder:o,drawBorderBuffer:vu([o],t.drawBorderBuffer,i.custom.skipConcave,i.custom.bufferOffset),drawType:n}))):(null==t.line.widthIs&&(t.line.widthIs="mid"),i.custom.close&&(t.line.close=!0),a="negative","positive"===i.custom.bufferOffset&&t.line.close&&(a=t.line.drawBorder="positive"),e=(r=gu(i.custom.getLine(ft({},t.line,{points:o})),5))[0],n=r[1],o=r[2],r=r[4],i.custom.options=t,i.custom.options.line=e,"positive"===i.custom.bufferOffset&&o.reverse(),a=vu(o,t.drawBorderBuffer,i.custom.skipConcave,a),i.custom.updateGeneric(ft({},t,{points:n,drawBorder:o,drawBorderBuffer:a,drawType:r})))},i}},{key:"polygon",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=this.genericBase("polygon",{radius:1,sides:4,direction:1,rotation:0,offset:new Oe(0,0)},ft.apply(void 0,[{}].concat(n)));return i.custom.getBorder=function(e){var n=t.getPolygonBorder(e);return e.sidesToDraw!==e.sides?i.custom.close=!1:i.custom.close=!0,i.custom.skipConcave=!1,-1===e.direction?i.custom.bufferOffset="positive":i.custom.bufferOffset="negative",n},i.custom.getFill=function(t,e){return[Cr(e.offset,t,e.sides,e.sidesToDraw),"TRIANGLES"]},i.drawingObject.getPointCountForAngle=function(t){var e=i.custom.options;return t=Math.floor(m(t,8)/m(2*Math.PI,8)*e.sides),null==e.line?3*t:e.line&&e.line.linePrimitives?t*e.line.lineNum*2:6*t},i.custom.updatePoints(ft.apply(void 0,[{}].concat(n))),i}},{key:"star",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=this.genericBase("star",{radius:1,sides:5,direction:1,rotation:0,offset:new Oe(0,0)},ft.apply(void 0,[{}].concat(n)));return i.custom.getBorder=function(e){return null==e.innerRadius&&(e.innerRadius=e.radius/3),e.rotation+=Math.PI/2,e.sidesToDraw=e.sides,(e=t.getPolygonBorder(e))[0].rotation-=Math.PI/2,e},i.custom.getFill=function(t,e){return[Cr(e.offset,t,e.sides,e.sidesToDraw),"TRIANGLES"]},i.custom.updatePoints(ft.apply(void 0,[{}].concat(n))),i}},{key:"rectangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.genericBase("rectangle",{width:this.defaultLength,height:this.defaultLength/2,xAlign:"center",yAlign:"middle",corner:{radius:0,sides:1},offset:[0,0]},ft.apply(void 0,[{}].concat(e)));return r.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),null!=t.offset&&(t.offset=Ae(t.offset)),[t,(e=t.width,n=t.height,r=t.xAlign,i=t.yAlign,a=o=0,"center"===r?o=-e/2:"right"===r?o=-e:"number"==typeof r&&(o=-e*r),"middle"===i?a=-n/2:"top"===i?a=-n:"number"==typeof i&&(a=-n*i),i=(r=t.corner).radius,function(t,e,n,r,i,o,a){var s=6<arguments.length&&void 0!==a?a:new Oe(0,0);if(r<1e-9)return[new Oe(i+s.x,o+s.y),new Oe(i+t+s.x,o+s.y),new Oe(i+t+s.x,o+e+s.y),new Oe(i+s.x,o+e+s.y)];var l=[],u=Math.PI/2/n,c=Math.min(t/2,e/2,r);return[[i+c,o+c,Math.PI],[i-c+t,o+c,Math.PI/2*3],[i-c+t,o-c+e,0],[i+c,o-c+e,Math.PI/2]].forEach((function(t){for(var e,r=(t=function(t){if(Array.isArray(t))return t}(e=t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,r,i=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(i.push(n.value),3!==i.length);o=!0);}catch(t){a=!0,r=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw r}}return i}}(e)||function(t){if(t){if("string"==typeof t)return du(t,3);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?du(t,3):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],i=t[1],o=t[2],a=0;a<n+1;a+=1)l.push(new Oe(r+c*Math.cos(a*u+o),i+c*Math.sin(a*u+o)).add(s))})),l}(e,n,r.sides,i,o,a,t.offset))];var e,n,r,i,o,a},r.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"TRIANGLES"]},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"cameraControl",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{left:0,bottom:0,width:1,height:1,scene:null,color:[0,0,0,0],axis:[0,1,0],sensitivity:5,xSensitivity:1,ySensitivity:1}].concat(e)),i=this.rectangle({width:r.width,height:r.height,position:[r.left,r.bottom],xAlign:"left",yAlign:"bottom",move:!0,color:r.color});return i.custom.sceneToChange=r.scene,i.scene=new Pi({style:"2D",left:0,right:1,bottom:0,top:1}),i.notifications.add("beforeMove",(function(){i.custom.position=i.getPosition(),i.custom.moving=!0})),i.notifications.add("beforeMoveFreely",(function(){i.custom.position=i.getPosition(),i.custom.moving=!0})),i.notifications.add("setTransform",(function(){var t,e,n,o,a,s,l,u;!1!==i.custom.moving&&(null!=i.custom.sceneToChange&&"string"!=typeof i.custom.sceneToChange||null!=i.figure&&(null==i.custom.sceneToChange&&null!=i.parent&&(i.custom.sceneToChange=i.parent.getScene()),"string"==typeof i.custom.sceneToChange&&(null==(o=i.getRootElement())||null!=(a=o.getElement(i.custom.sceneToChange))&&(i.custom.sceneToChange=a.getScene()))),t=i.custom.sceneToChange,u=-(l=i.getPosition().sub(i.custom.position)).x*r.sensitivity*r.xSensitivity,s=l.y*r.sensitivity*r.ySensitivity,e=Ae(t.camera.lookAt),n=Ae(t.camera.position),o=u,a=s,s=(u=l=Ae(r.axis)).crossProduct(n.sub(e)).normalize(),l=Math.abs(Math.acos(n.sub(e).normalize().dotProduct(e.add(l).normalize()))),0<(a=a<0&&l<Math.PI/2&&a<.001-l?.001-l:a)&&l>Math.PI/2&&(l=Math.PI-l,a=m(Math.min(l-.001,a),4)),u=rn([["r",a].concat(bu(s.toArray())),["r",o].concat(bu(u.toArray()))]).matrix(),u=n.transformBy(u),t.setCamera({position:u}),i.transform.updateTranslation(i.custom.position),i.custom.moving=!1)})),i}},{key:"ellipse",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.genericBase("ellipse",{width:this.defaultLength,height:this.defaultLength/2,xAlign:"center",yAlign:"middle",sides:20},ft.apply(void 0,[{}].concat(e)));return r.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),[t,(e=t.width,n=t.height,o=i=0,"left"===(r=t.xAlign)?i=e/2:"right"===r?i=-e/2:"number"==typeof r&&(i=e/2-e*r),"bottom"===(r=t.yAlign)?o=n/2:"top"===r?o=-n/2:"number"==typeof r&&(o=n/2-n*r),function(t,e,n,r,i){for(var o=[],a=2*Math.PI/n,s=0;s<n;s+=1)o.push(new Oe(t/2*Math.cos(a*s)+r,e/2*Math.sin(a*s)+i));return o}(e,n,t.sides,i,o))];var e,n,r,i,o},r.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"TRIANGLES"]},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"arc",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.genericBase("arc",{radius:this.defaultLength/2,sides:20,startAngle:0,angle:1,offset:[0,0],fillCenter:!1},ft.apply(void 0,[{}].concat(e)));return r.custom.getBorder=function(t){return null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative"),null!=t.offset&&(t.offset=Ae(t.offset)),r.custom.close=!1,[t,function(t){var e=[],n=t.radius,r=t.startAngle,i=t.angle,o=t.offset,a=t.sides,s=a/i*Math.PI*2,l=n*Math.cos(Math.PI/s),u=(s=i/a,0<=i?r:r+i),c=0<=i?s:-s;null==t.line&&t.fillCenter&&e.push(o._dup()),e.push(new Oe(l*Math.cos(u),l*Math.sin(u)).add(o));for(var h=0;h<a;h+=1)e.push(new Oe(n*Math.cos(u+c/2+c*h)+o.x,n*Math.sin(u+c/2+c*h)+o.y));return e.push(new Oe(l*Math.cos(u+c*a),l*Math.sin(u+c*a)).add(o)),e}(t)]},r.custom.getFill=function(t){return[function(t){for(var e=[t[0]._dup(),t[1]._dup(),t[2]._dup()],n=2;n<t.length-1;n+=1)e.push(t[0]),e.push(t[n]),e.push(t[n+1]);return e}(t),"TRIANGLES"]},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"triangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.genericBase("triangle",{width:this.defaultLength,height:this.defaultLength,top:"center",direction:1,rotation:0},ft.apply(void 0,[{}].concat(e)));return r.custom.getBorder=function(t){null==t.xAlign&&(null!=t.points?t.xAlign="points":t.xAlign="centroid"),null==t.yAlign&&(null!=t.points?t.yAlign="points":t.yAlign="centroid");var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x,S,T,A,k,_,O=(_=(e=t).direction,null!=e.points?b=ke(e.points):null!=e.ASA?(l=_,u=(f=pu(s=e.ASA,3))[0],c=f[1],h=f[2],s=[new Oe(0,0),new Oe(c,0)],f=Math.PI-u-h,u=c/Math.sin(f)*Math.sin(u),s.push(new Oe(c+u*Math.cos((Math.PI-h)*l),0+u*Math.sin((Math.PI-h)*l))),b=s):null!=e.SAS?(i=_,s=(o=pu(l=e.SAS,3))[0],a=o[1],l=o[2],(o=[new Oe(0,0),new Oe(s,0)]).push(new Oe(s+l*Math.cos((Math.PI-a)*i),0+l*Math.sin((Math.PI-a)*i))),b=o):null!=e.AAS?(n=_,i=(r=pu(a=e.AAS,3))[0],o=r[1],a=r[2],r=Math.PI-i-o,i=a/Math.sin(i)*Math.sin(r),(r=[new Oe(0,0),new Oe(i,0)]).push(new Oe(i+a*Math.cos((Math.PI-o)*n),0+a*Math.sin((Math.PI-o)*n))),b=r):null!=e.SSS?(p=_,n=(d=pu(O=e.SSS,3))[0],r=d[1],O=d[2],d=Math.acos((n*n+r*r-O*O)/(2*n*r)),(O=[new Oe(0,0),new Oe(n,0)]).push(new Oe(n+r*Math.cos((Math.PI-d)*p),0+r*Math.sin((Math.PI-d)*p))),b=O):(v=e.width,g=e.height,m=e.top,b=[new Oe(0,0),new Oe(v,0)],"left"===m?b.push(new Oe(0,g*_)):"center"===m?b.push(new Oe(v/2,g*_)):"right"===m&&b.push(new Oe(v,g*_))),d=b,p=e.xAlign,O=e.yAlign,m=e.rotation,y="number"==typeof m?(new Qe).rotate(m).matrix():(x="s1",S=0,"string"==typeof m?x=m:(x=(w=ft({},{side:"s1",angle:0},m)).side,S=w.angle),T=0,"s1"===x?T=Pe(S,new Ie(d[0],d[1]).angle()):"s2"===x?T=Pe(S,new Ie(d[1],d[2]).angle()):"s3"===x&&(T=Pe(S,new Ie(d[2],d[0]).angle())),(new Qe).rotate(T).matrix()),v=d.map((function(t){return t.transformBy(y)})),g=Math.min(v[0].x,v[1].x,v[2].x),_=Math.min(v[0].y,v[1].y,v[2].y),m=(b=Math.max(v[0].x,v[1].x,v[2].x))-g,w=(e=Math.max(v[0].y,v[1].y,v[2].y))-_,x=yr(v[0],v[1],v[2]),S=new Ie(v[0],v[1]).midPoint(),T=new Ie(v[1],v[2]).midPoint(),d=new Ie(v[2],v[0]).midPoint(),k=A=0,"left"===p?A=-g:"center"===p?A=m/2-b:"right"===p?A=-b:"centroid"===p?A=-x.x:"a2"===p?A=-v[1].x:"a3"===p?A=-v[2].x:"s1"===p?A=-S.x:"s2"===p?A=-T.x:"s3"===p?A=-d.x:"number"==typeof p&&(A=-g-m*p),"bottom"===O?k=-_:"middle"===O?k=w/2-e:"top"===O?k=-e:"centroid"===O?k=-x.y:"a2"===O?k=-v[1].y:"a3"===O?k=-v[2].y:"s1"===O?k=-S.y:"s2"===O?k=-T.y:"s3"===O?k=-d.y:"number"==typeof O&&(k=-_-w*O),v.map((function(t){return new Oe(t.x+A,t.y+k)})));return-1!==t.direction&&-1!=(je((v=pu(v=O,3))[0],v[1],v[2])>Math.PI?1:-1)||O.reverse(),[t,O]},r.custom.getFill=function(t){return[t,"TRIANGLES"]},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"arrow",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.genericBase("arrow",{length:this.defaultLength/2,width:this.defaultLength/2,head:"triangle",sides:20,radius:this.defaultLength/4,rotation:0,angle:0,tail:!1,drawPosition:new Oe(0,0)},ft.apply(void 0,[{}].concat(e)));return r.custom.getBorder=function(t){null!=t.line&&"inside"===t.line.widthIs&&(t.line.widthIs="positive"),null!=t.line&&"outside"===t.line.widthIs&&(t.line.widthIs="negative");var e=Ur(t);return[e,(t=gu(qr(e),2))[0],t[1]]},r.custom.getFill=function(t,e){return[Hr(t,e),"TRIANGLES"]},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"grid",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.generic.apply(this,[{transform:(new Qe).scale(1).rotate(0).translate(),border:"draw",touchBorder:"border"}].concat(e));function i(t){return ri(t,r.custom.options.line.width,!1,"mid","auto",.1,1,Math.PI/7,r.custom.options.line.dash,r.custom.options.line.linePrimitives,r.custom.options.line.lineNum,[[]],0)}return r.custom.options={bounds:new En(this.scene.left,this.scene.bottom,this.scene.right-this.scene.left,this.scene.top-this.scene.bottom),line:{linePrimitives:!1,width:this.defaultLineWidth,lineNum:2,dash:[]}},r.custom.updatePoints=function(t){var e=ft({},r.custom.options,t),n=Mn((r.custom.options=e).bounds),o=e.step,a=e.num,s=e.xStep,l=e.xNum,u=e.yStep,c=e.yNum;null==u&&(u=o),null==l&&(l=a),null==c&&(c=a);var h=e.line.width;e.line.linePrimitives&&1===e.line.lineNum&&(h=0);var f=n.width,d=n.height,p=(s=(l=null==(l=null!=(s=null==s?o:s)&&null==l?0===s?1:1+Math.floor((f+.1*s)/s):l)?2:l)<2?0:f/(l-1),u=(c=null==(c=null!=u&&null==c?0===u?1:1+Math.floor((d+.1*u)/u):c)?2:c)<2?0:d/(c-1),new Oe(n.left,n.bottom)),m=p.add(-h/2,0),y=p.add(f+h/2,0);t=p.add(0,-h/2),a=p.add(0,d+h/2),o=[],n=[],0<l&&(n=Ls(gu(i([t,a]),1)[0],[{along:"x",num:l-1,step:s}])),0<c&&(o=Ls(gu(i([m,y]),1)[0],[{along:"y",num:c-1,step:u}])),f=[p.add(-h/2,-h/2),p.add(f+h/2,-h/2),p.add(f+h/2,d+h/2),p.add(-h/2,d+h/2)],p=null!=e.drawBorder?vr(e.drawBorder):[f],d=e.drawBorderBuffer,"number"==typeof e.drawBorderBuffer&&(d=p,0!==e.drawBorderBuffer&&(h=e.drawBorderBuffer,d=[[f[0].add(-h,-h),f[1].add(h,-h),f[2].add(h,h),f[3].add(-h,h)]])),r.custom.updateGeneric(ft({},e,{points:[].concat(bu(o),bu(n)),drawBorder:p,drawBorderBuffer:d,drawType:e.line.linePrimitives?"LINES":"TRIANGLES"}))},r.custom.updatePoints(ft.apply(void 0,[{}].concat(e))),r}},{key:"line",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this.polyline(ft.apply(void 0,[{},{transform:(new Qe).scale(1).rotate(0).translate()}].concat(e,[{points:[[0,0],[0,1]],dash:[],arrow:null}]))),i=ft.apply(void 0,[{}].concat(e));return r.custom.options=ft({},r.custom.options,{p1:[0,0],angle:0,length:this.defaultLength,width:this.defaultLineWidth}),r.custom.updatePolyline=r.custom.updatePoints,r.custom.updatePoints=function(t){var e=ft({},r.custom.options,t),n=(i=gu(function(t){var n,r=e.p1,i=e.p2,o=e.length,a=e.width,s=e.angle,l=e.border,u=e.touchBorder;return t=e.widthIs,r=[Ae(r)],null==i?r.push(new Oe(r[0].x+o*Math.cos(s),r[0].y+o*Math.sin(s))):r.push(Ae(i)),i="outline"===l?"line":l,"number"==typeof u&&(l=new Ie(r[0],r[1]),l=new Ie(l.pointAtLength(-u),l.pointAtLength(l.length()+u)),a="positive"===t?(n=l.offset("negative",u),l.offset("positive",a+u)):"negative"===t?(n=l.offset("negative",a+u),l.offset("positive",u)):(n=l.offset("negative",a/2+u),l.offset("positive",a/2+u)),u=[[n.p1,n.p2,a.p2,a.p1]]),[r,i,u]}(),3))[0],i=(t=i[1],i[2]);r.custom.updatePolyline(ft({},e,{points:n,border:t,touchBorder:i}))},r.custom.updatePoints(i),r}},{key:"textGL",value:function(t){return e=this.webgl[0],null==(t=ft({},{position:new Oe(0,0),color:[1,0,0,1]},t)).transform&&(t.transform=(new Qe).translate(0,0)),null!=t.position&&t.transform.updateTranslation(t.position),e=new fu(e,t),new jl(e,t.transform,t.color);var e}},{key:"parseTextOptions",value:function(){for(var t={text:"",font:{family:this.defaultFont.family,style:this.defaultFont.style,size:this.defaultFont.size,weight:this.defaultFont.weight},xAlign:"left",yAlign:"baseline",border:"draw",touchBorder:"buffer",defaultTextTouchBorder:0},e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==(t=ft.apply(void 0,[{},t].concat(n))).color&&null!=t.font.color&&(t.color=t.font.color),null==t.font.color&&null!=t.color&&(t.font.color=t.color),null==t.color&&(t.color=this.defaultFont.color),null==t.text||Array.isArray(t.text)||(t.text=[t.text]),null==t.line||Array.isArray(t.line)||(t.line=[t.line]),null==t.lines||Array.isArray(t.lines)||(t.lines=[t.lines]),null!=t.touchBorder&&Array.isArray(t.touchBorder)&&(t.touchBorder=vr(t.touchBorder)),null!=t.border&&Array.isArray(t.border)&&(t.border=vr(t.border)),t}},{key:"genericTextPrimitive",value:function(t,e){var n=e;null==n.transform?n.transform=(new Qe).scale(1).rotate(0).translate():n.transform=rn(n.transform),null!=n.position&&(e=Ae(n.position),n.transform.updateTranslation(e));var r=new jl(t,n.transform,n.color);return r.timeKeeper=this.timeKeeper,r.recorder=this.recorder,Tu(r,n),null!=n.mods&&n.mods!=={}&&r.setProperties(n.mods),r.custom.updateBorders=function(t){r.drawBorder=r.drawingObject.textBorder,null!=t.drawBorder&&(r.drawBorder=t.drawBorder),r.drawBorderBuffer=r.drawingObject.textBorderBuffer,null!=t.drawBorderBuffer&&(r.drawBorderBuffer=t.drawBorderBuffer),null!=t.border&&(r.border=t.border),null!=t.touchBorder&&(r.touchBorder=t.touchBorder)},r.getBorderPointsSuper=r.getBorderPoints,r.getBorderPoints=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border";return"border"===t?r.getBorderPointsSuper(t):"draw"===r.touchBorder?r.drawBorder:"buffer"===r.touchBorder?r.drawBorderBuffer:"border"===r.touchBorder?r.getBorderPoints("border"):"rect"===r.touchBorder?[fr(r.drawBorderBuffer)]:cr(r.touchBorder)?[fr(r.drawBorderBuffer,r.touchBorder)]:r.touchBorder},r.custom.setText=function(t){r.drawingObject.setText(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0),r.custom.updateBorders({})},r}},{key:"textLine",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=this.parseTextOptions.apply(this,[{border:"rect",touchBorder:"rect"}].concat(n)),o=new dl(this.draw2D);o.loadText(i);var a=this.genericTextPrimitive(o,i);return a.custom.options=o,a.custom.updateText=function(e){a.drawingObject.clear(),e=t.parseTextOptions({border:"rect",touchBorder:"rect"},a.custom.options,e),a.drawingObject.loadText(e),a.custom.options=e,a.custom.updateBorders({})},a.custom.updateBorders(i),a}},{key:"textLines",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},{color:this.defaultColor}].concat(n)),o=new pl(this.draw2D),a=this.genericTextPrimitive(o,i);return a.custom.options=i,a.custom.updateText=function(e){a.drawingObject.clear();var r=e;1===e.length&&"string"==typeof e[0]&&(r=[{text:[n[0]]}]),null==(r=t.parseTextOptions({border:"rect",touchBorder:"rect"},a.custom.options,r)).justify&&(r.justify="left"),null==r.lineSpace&&(r.lineSpace=1.2*r.font.size),a.custom.options=r,a.drawingObject.loadText(r),a.custom.updateBorders(r)},a.custom.updateText(i),a}},{key:"text",value:function(){var t=this,e=this.parseTextOptions.apply(this,arguments),n=new cl(this.draw2D);n.loadText(e);var r=this.genericTextPrimitive(n,e);return r.custom.options=e,r.custom.updateText=function(e){r.drawingObject.clear(),r.drawingObject.loadText(t.parseTextOptions(r.custom.options,e)),r.custom.updateBorders({}),r.animateNextFrame()},r.custom.updateBorders(e),r}},{key:"html",value:function(t){var e;(r=ft({},{classes:"",position:[0,0],xAlign:"center",yAlign:"middle",wrap:!0,id:"id__temp_".concat(Math.round(1e4*Math.random()))},t)).element=t.element,null==(n=r.wrap||Array.isArray(r.element)?((e=document.createElement("div")).setAttribute("id",r.id),Array.isArray(r.element)?r.element.forEach((function(t){return e.appendChild(t)})):e.appendChild(r.element),this.htmlCanvas.appendChild(e),this.htmlCanvas):(""===(n=(e=r.element).getAttribute("id"))?e.setAttribute("id",r.id):r.id=n,e.parentElement))&&(n=this.htmlCanvas);var n=new ks(n,r.id,new Oe(0,0),r.yAlign,r.xAlign),r=Ae(r.position);return(r=new jl(n,(new Qe).scale(1,1).translate(r.x,r.y),[1,1,1,1])).timeKeeper=this.timeKeeper,r.recorder=this.recorder,r}},{key:"htmlElement",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"id__temp_".concat(Math.round(1e4*Math.random())),n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new Oe(0,0),i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"middle",o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"left",a=document.createElement("div");return n&&a&&n.split(" ").forEach((function(t){return a.classList.add(t.trim())})),Array.isArray(t)?t.forEach((function(t){return a.appendChild(t)})):a.appendChild(t),a.style.position="absolute",a.setAttribute("id",e),this.htmlCanvas.appendChild(a),o=new ks(this.htmlCanvas,e,new Oe(0,0),i,o),(r=new jl(o,(new Qe).scale(1,1).translate(r.x,r.y),[1,1,1,1])).timeKeeper=this.timeKeeper,r.recorder=this.recorder,r}},{key:"htmlImage",value:function(){for(var t={id:mt("id__html_image_"),classes:"",position:new Oe(0,0),yAlign:"middle",xAlign:"left",src:""},e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},t].concat(n)),o=document.createElement("img");o.src=i.src;var a=i.id,s=i.classes,l=i.position,u=i.yAlign;return t=i.xAlign,t=this.htmlElement(o,a,s,Ae(l),u,t),null!=i.color&&t.setColor(i.color),Tu(t,i),t}},{key:"htmlText",value:function(){for(var t={text:"",id:mt("id__html_text_"),classes:"",position:new Oe(0,0),yAlign:"middle",xAlign:"left"},e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},t].concat(n)),o=document.createElement("div");ru(o,i.text,i.modifiers);var a=i.id,s=i.classes,l=i.position,u=i.yAlign;return t=i.xAlign,t=this.htmlElement(o,a,s,Ae(l),u,t),null!=i.color&&t.setColor(i.color),Tu(t,i),t}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}(),ku=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),e=ft({width:0,height:0,ascent:0,descent:0,left:0,right:0,top:0,bottom:0},e),this.copyFrom(e)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,[{key:"toRect",value:function(){return new En(this.left,this.bottom,this.width,this.height)}},{key:"copyFrom",value:function(t){null!=t.width&&(this.width=t.width),null!=t.height&&(this.height=t.height),null!=t.ascent&&(this.ascent=t.ascent),null!=t.descent&&(this.descent=t.descent),null!=t.left&&(this.left=t.left),null!=t.right&&(this.right=t.right),null!=t.top&&(this.top=t.top),null!=t.bottom&&(this.bottom=t.bottom)}},{key:"leftOffset",value:function(t){this.left+=t,this.width=this.right-this.left}},{key:"rightOffset",value:function(t){this.right+=t,this.width=this.right-this.left}},{key:"topOffset",value:function(t){this.top+=t,this.ascent+=t,this.height=this.ascent+this.descent}},{key:"bottomOffset",value:function(t){this.bottom+=t,this.descent-=t,this.height=this.ascent+this.descent}},{key:"offset",value:function(t,e,n,r){this.left+=r,this.right+=e,this.top+=t,this.ascent+=t,this.descent-=n,this.bottom+=n,this.width=this.right-this.left,this.height=this.ascent+this.descent}},{key:"growWithSameBaseline",value:function(t){var e=this.bottom+this.descent;t.left<this.left&&(this.left=t.left),t.right>this.right&&(this.right=t.right),t.top>this.top&&(this.top=t.top),t.bottom<this.bottom&&(this.bottom=t.bottom),this.width=this.right-this.left,this.height=this.top-this.bottom,this.ascent=this.top-e,this.descent=e-this.bottom}}]),t}();function _u(t){return function(t){if(Array.isArray(t))return Ou(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Ou(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ou(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ou(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Pu(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Eu(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Mu(t,e,n){return e&&Eu(t.prototype,e),n&&Eu(t,n),t}var Cu=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.03,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;Pu(this,t),this.width=e,this.ascent=n,this.descent=r,this.height=this.ascent+this.descent}return Mu(t,[{key:"_dup",value:function(){return new t(this.width,this.ascent,this.descent)}}]),t}(),ju=function(){function t(e){Pu(this,t),this.content=e,this.ascent=0,this.descent=0,this.width=0,this.location=new Oe(0,0),this.scale=1,this.height=0,this.fullSize={leftOffset:0,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent},this.fnMap=new X,this.showContent=!0}return Mu(t,[{key:"calcSize",value:function(t,e){var n=this.content;n instanceof Cu&&(this.width=n.width*e,this.height=n.height*e,this.ascent=n.ascent*e,this.descent=n.descent*e,this.location=t._dup(),this.scale=e),(n instanceof Rl||n instanceof jl)&&(null!=n.drawingObject&&null!=n.drawingObject.text&&(n.drawingObject.text[0].measureAndAlignText(),n.drawingObject.text[0].calcBorderAndBounds(),n.drawingObject.setBorder(),n.drawingObject.setTouchBorder(),n.custom.updateBorders({})),n.transform.updateTranslation([t.x,t.y]),n.transform.updateScale([e,e]),null!=n.internalSetTransformCallback&&this.fnMap.exec(n.internalSetTransformCallback,n.transform),n=n.getRelativeBoundingRect("draw"),this.location=t._dup(),this.scale=e,this.ascent=n.top*e,this.descent=-n.bottom*e,this.height=n.height*e,this.width=n.width*e),this.fullSize={leftOffset:0,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent}}},{key:"_dup",value:function(e){return(e=this.content instanceof Cu?new t(this.content):new t(e?e[this.content.name]:this.content)).ascent=this.ascent,e.descent=this.descent,e.width=this.width,e.location=this.location._dup(),e.height=this.height,e.scale=this.scale,e}},{key:"getAllElements",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&!arguments[0]&&!this.showContent||this.content instanceof Cu?[]:[this.content]}},{key:"setPositions",value:function(){var t=this.content;(t instanceof Rl||t instanceof jl)&&(t.transform.updateTranslation([this.location.x,this.location.y]),t.transform.updateScale([this.scale,this.scale]))}},{key:"offsetLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);this.location=this.location.add(t)}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new ku({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new ku({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}]),t}(),Ru=function(){function t(e){Pu(this,t);var n=[];e.forEach((function(t){null!==t&&n.push(t)})),this.content=n,this.ascent=0,this.descent=0,this.width=0,this.location=new Oe(0,0),this.height=0,this.fnMap=new X,this.showContent=!0}return Mu(t,[{key:"_dup",value:function(e){var n=[];this.content.forEach((function(t){return n.push(t._dup(e))}));var r=new t(n);return dt(this,r,["content"]),r}},{key:"calcSize",value:function(t,e){var n=0,r=0,i=t._dup(),o=null;this.content.forEach((function(t){t.calcSize(i,e),i.x+=t.width,t.descent>n&&(n=t.descent),t.ascent>r&&(r=t.ascent),t=t.getBounds(!0),null==o&&(o=new ku).copyFrom(t)})),null===o&&((o=new ku).left=t.x,o.top=t.y,o.bottom=t.y),this.width=i.x-t.x,this.ascent=r,this.descent=n,this.location=t._dup(),this.height=this.descent+this.ascent,this.fullSize={leftOffset:this.location.x-o.left,width:o.width,ascent:o.ascent,descent:o.descent,height:o.height}}},{key:"getAllElements",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=[];return t||this.showContent?(this.content.forEach((function(n){e=[].concat(_u(e),_u(n.getAllElements(t)))})),e):[]}},{key:"setPositions",value:function(){this.content.forEach((function(t){t.setPositions()}))}},{key:"offsetLocation",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);this.location=this.location.add(t),this.content.forEach((function(e){e.offsetLocation(t)}))}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new ku({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new ku({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}]),t}();function Bu(t){return(Bu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Iu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Iu(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Iu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Du(t,e){return(Du=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Lu(t){return(Lu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var zu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Du(t,e)}(i,jl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Lu(e);return function(t,e){if(e&&("object"===Bu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Lu(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e,n,o){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),t=new Us(t),n=n instanceof Qe?n:(new Qe).scale(1,1).translate(0,0);var a=r.call(this,t,n,e);return null!=o.touchBorder&&(a.touchBorder=o.touchBorder),null!=o.border&&(a.border=o.border),null!=o.onClick&&(a.onClick=o.onClick),null!=o.isTouchable&&(a.isTouchable=o.isTouchable),a._custom.options=o,"dynamic"===a._custom.options.draw&&(a._custom.scale=new Oe(1,1),a.internalSetTransformCallback=function(){var t,e,n,r,i=a.getScale();a._custom.scale.isNotEqualTo(i,8)&&(t=(r=Fu(a.getPoints(a._custom.options,i.x,i.y),4))[0],e=r[1],n=r[2],r=r[3],a.pointsDefinition={points:ut(t),width:e,height:n,drawType:r},a.updateSymbol(t,e,n,r),a._custom.scale=i)}),a._custom.setSize=function(t,e,n){var r,i,s,l,u,c=a.transform._dup();"static"===a._custom.options.draw?(u=[],l=s=0,i="STRIP","first"===a._custom.options.staticHeight||"first"===a._custom.options.staticWidth?(u=(r=Fu(a.getPoints(o,e,n),4))[0],s=r[1],l=r[2],i=r[3]):null==a._custom.options.staticHeight&&null==a._custom.options.staticWidth||(u=(r=Fu(a.getPoints(o,a._custom.options.staticWidth,a._custom.options.staticHeight),4))[0],s=r[1],l=r[2],i=r[3]),a.pointsDefinition={points:ut(u),width:s,height:l,drawType:i},a.updateSymbol(u,s,l,i),a._custom.options.staticHeight=l,a._custom.options.staticWidth=s,c.updateScale([s,l])):(i=(u=Fu(a.getPoints(a._custom.options,e,n),4))[0],s=u[1],l=u[2],u=u[3],a.pointsDefinition={points:ut(i),width:s,height:l,drawType:u},a.updateSymbol(i,s,l,u),a._custom.scale=new Oe(e,n),c.updateScale([e,n])),c.updateTranslation([t.x,t.y]),a.setTransform(c)},a.setPointsFromDefinition=function(){var t,e,n,r;0!==Object.keys(a.pointsDefinition).length&&(t=(r=a.pointsDefinition).points,e=r.width,n=r.height,r=r.drawType,a.updateSymbol(t,e,n,r))},a}return t=[{key:"updateSymbol",value:function(t,e,n,r){this.drawingObject.change({points:t,drawType:r}),this.drawBorder=[[new Oe(0,0),new Oe(e,0),new Oe(e,n),new Oe(0,n)]],"number"==typeof this._custom.options.drawBorderBuffer||Array.isArray(this._custom.options.drawBorderBuffer)&&"number"==typeof this._custom.options.drawBorderBuffer[0]?this.drawBorderBuffer=[fr(this.drawBorder,this._custom.options.drawBorderBuffer)]:Array.isArray(this._custom.options.drawBorderBuffer)?this.drawBorderBuffer=vr(this._custom.options.drawBorderBuffer):this.drawBorderBuffer=this.drawBorder}},{key:"getTransform",value:function(){if("static"!==this._custom.options.draw)return(t=this.transform._dup()).updateScale([1,1]),t;var t=this.transform._dup(),e=t.s();return null!=e&&t.updateScale([e.x/this._custom.options.staticWidth,e.y/this._custom.options.staticHeight]),t}},{key:"getWidth",value:function(t,e){if("static"!==t.draw)return n=t.width,this.getDefaultValues(e,n,t).width;var n,r=t.staticHeight,i=t.staticWidth;return(n=null==(n=this.getDefaultValues(r="first"===r?e:r,i,t).width)?e:n)/r*e}},{key:"getHeight",value:function(t,e){if("static"!==t.draw)return n=t.height,this.getDefaultValues(n,e,t).height;var n,r=t.staticWidth,i=t.staticHeight;return(n=null==(n=this.getDefaultValues(i,r="first"===r?e:r,t).height)?e:n)/r*e}},{key:"getBounds",value:function(t,e,n,r,i,o){i=(a=this.getDefaultValues(i,r,t)).width,t=a.height;var a=new ku;return"left"===o?(a.left=e-i,a.bottom=n,a.top=a.bottom+t):"right"===o?(a.left=e,a.bottom=n,a.top=a.bottom+t):("top"===o?(a.bottom=n,a.top=n+t):(a.top=n,a.bottom=n-t),a.left=e+r/2-i/2),a.right=a.left+i,a.width=i,a.height=t,a.ascent=t,a.descent=0,a}},{key:"getPoints",value:function(t,e,n){return[[new Oe(0,0),new Oe(e,0),new Oe(e,n),new Oe(0,n)],e,n,"STRIP"]}},{key:"getDefaultValues",value:function(t,e,n){return{}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Wu(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||qu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nu(t){return function(t){if(Array.isArray(t))return Hu(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||qu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qu(t,e){if(t){if("string"==typeof t)return Hu(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hu(t,e):void 0}}function Hu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Uu(t,e){var n=[];return t.forEach((function(t){var r;n.push((r=e,{xPosition:t.xPosition,yPosition:t.yPosition,xAlign:t.xAlign,yAlign:t.yAlign,offset:t.offset._dup(),scale:t.scale,content:t.content._dup(r),inSize:t.inSize,fullContentBounds:t.fullContentBounds}))})),n}function Ku(t){var e=[];return t.forEach((function(t){e=[].concat(Nu(e),Nu(t.content.getAllElements()))})),e}function Vu(t){t.forEach((function(t){t.content.setPositions()}))}function Gu(t,e){t.forEach((function(t){t.content.offsetLocation(e)}))}var Yu=function(){function t(e,n,r,i){var o=!(4<arguments.length&&void 0!==arguments[4])||arguments[4];!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.glyphs=r,this.content=e,this.annotations=n,this.options=i,this.fnMap=new X,this.showContent=o,this.scale=1}var e=[{key:"_dup",value:function(t){var e,n,r=this.content._dup(t),i=(e=this.glyphs,n={},Object.keys(e).forEach((function(t){var r,i;null!=e[t]&&(dt(r=e[t],i={},["glyph","annotations"]),i.glyph=r.glyph,i.annotations=Uu(r.annotations,void 0),n[t]=i)})),n);return t=Uu(this.annotations),dt(this,i=new this.constructor(r,t,i,this.options),["content","glyphs","annotations"]),i}},{key:"getAllElements",value:function(){var t,e,n=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];return n||this.showContent?[].concat(Nu(this.content.getAllElements(n)),Nu(Ku(this.annotations)),Nu((t=this.glyphs,e=[],Object.keys(t).forEach((function(n){null!=(n=t[n])&&(e=[].concat(Nu(e),[n.glyph],Nu(Ku(n.annotations))))})),e))):[]}},{key:"setPositions",value:function(){var t;this.content.setPositions(),Vu(this.annotations),t=this.glyphs,Object.keys(t).forEach((function(e){var n;null!=t[e]&&((e=(n=t[e]).glyph.transform._dup()).updateScale([null==n.width?1:n.width,null==n.height?1:n.height]),e.updateTranslation([null==n.location?0:n.location.x,null==n.location?0:n.location.y]),n.glyph.setTransform(e),Vu(n.annotations))}))}},{key:"offsetLocation",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);this.location=this.location.add(n),this.content.offsetLocation(n),Gu(this.annotations,n),t=this.glyphs,e=n,Object.keys(t).forEach((function(n){null!=t[n]&&((n=t[n]).location=n.location.add(e),Gu(n.annotations,e))}))}},{key:"calcSize",value:function(t,e){var n=this;this.location=t._dup();var r,i=t._dup(),o=this.content,a=this.annotations,s=(p=this.options).inSize,l=p.space,u=p.topSpace,c=p.bottomSpace,h=p.leftSpace,f=p.rightSpace,d=p.contentScale,p=(t=p.useFullBounds,p.fullContentBounds),m=new ku,y=new ku,v=new ku;o.calcSize(i._dup(),e*d),v.copyFrom(o.getBounds(p)),m.copyFrom(v),y.copyFrom(v),a.forEach((function(t,r){t.content.calcSize(i,e*t.scale),n.setAnnotationPosition(v,t,e);var o=t.content.getBounds();m.growWithSameBaseline(o),t=t.content.getBounds(!0),y.growWithSameBaseline(t),null!=n.glyphs.line&&n.glyphs.line.annotationIndex===r&&n.setLineGlyph(o,v)})),p=(d=Wu(this.setEncompassGlyph(e,v),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=(p=Wu(this.setVerticalGlyph(e,v,"left"),2))[0],p=p[1],m.growWithSameBaseline(d),y.growWithSameBaseline(p),p=(d=Wu(this.setVerticalGlyph(e,v,"right"),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=(p=Wu(this.setHorizontalGlyph(e,v,"top"),2))[0],p=p[1],m.growWithSameBaseline(d),y.growWithSameBaseline(p),p=(d=Wu(this.setHorizontalGlyph(e,v,"bottom"),2))[0],d=d[1],m.growWithSameBaseline(p),y.growWithSameBaseline(d),d=0,m.offset((null!=u?u:l||0)*e,(null!=f?f:l||0)*e,-(null!=c?c:l||0)*e,-(null!=h?h:l||0)*e),y.growWithSameBaseline(m),t&&m.copyFrom(y),s?(this.width=m.width,this.ascent=m.ascent,this.descent=m.descent,this.height=m.height,d=i.x-m.left):(this.width=v.width,this.ascent=v.ascent,this.descent=v.descent,this.height=v.height),this.fullSize={leftOffset:this.location.x-y.left,width:y.width,ascent:y.ascent,descent:y.descent,height:y.height},0!==d&&null!=o&&(r=new Oe(d,0),o.offsetLocation(r),a.forEach((function(t){t.content.offsetLocation(r)})),Object.keys(this.glyphs).forEach((function(t){null!=(t=n.glyphs[t])&&(t.location=t.location.add(r),t.glyph._custom.setSize(t.location,t.width,t.height),t.annotations.forEach((function(t){t.content.offsetLocation(r)})))})))}},{key:"setEncompassGlyph",value:function(t,e){var n=this;if(null==this.glyphs.encompass)return(a=new ku).copyFrom(e),[e,a];var r=(s=this.glyphs.encompass).leftSpace,i=s.rightSpace,o=s.bottomSpace,a=s.topSpace,s=s.space,l=this.glyphs.encompass;s=null!=s?s:0,r=null!=r?r:s,i=null!=i?i:s,a=null!=a?a:s,o=null!=o?o:s,(s=new ku).copyFrom(e),s.offset(a*t,i*t,-o*t,-r*t);var u=l.glyph.getBounds(l.glyph._custom.options,s.left,s.bottom,s.width,s.height),c=new ku,h=new ku;return c.copyFrom(s),c.growWithSameBaseline(u),h.copyFrom(c),l.width=u.width,l.height=u.height,l.location=new Oe(u.left,u.bottom),l.glyph._custom.setSize(l.location,l.width,l.height),l.annotations.forEach((function(e){e.content.calcSize(l.location,t*e.scale),n.setAnnotationPosition(u,e,t);var r=e.content.getBounds();c.growWithSameBaseline(r),e=e.content.getBounds(!0),h.growWithSameBaseline(e)})),[c,h]}},{key:"setLineGlyph",value:function(t,e){var n,r,i;null!=this.glyphs.line&&(n=(r=this.glyphs.line).content,i=r.annotation,r=this.glyphs.line,e=gr(e.toRect(),n.xAlign,n.yAlign),t=gr(t.toRect(),i.xAlign,i.yAlign),t=new Ie(e,t),i=new Ie(t.pointAtLength(n.space),t.pointAtLength(t.length()-i.space)),r.width=i.angle(),r.height=i.length(),r.location=i.p1._dup(),r.glyph._custom.setSize(r.location,r.width,r.height))}},{key:"setVerticalGlyph",value:function(t,e,n){var r=this;if(null==this.glyphs[n])return(b=new ku).copyFrom(e),[e,b];var i=(w=this.glyphs[n]).space,o=w.overhang,a=w.topSpace,s=w.bottomSpace,l=w.minContentHeight,u=w.minContentDescent,c=w.minContentAscent,h=w.descent,f=w.height,d=w.yOffset,p=w.annotationsOverContent,m=this.glyphs[n],y=e.height,v=e.left,g=e.bottom,b=e.descent,w=e.ascent;null!=u&&(b=Math.max(u,b),y=e.ascent+b),null!=c&&(y=(w=Math.max(c,w))+b),null!=l&&(w=-b+Math.max(l,y)),b+=t*(null!=s?s:o),y=(b=null!=h?h:b)+(w+=t*(null!=a?a:o)),null!=f&&(w=(y=f)-b),g=e.bottom-(b-e.descent),"left"===n?v-=i*t:v=e.left+e.width+i*t,null==h&&null==s&&null!=f&&(g=e.bottom+e.height/2-f/2);var x=m.glyph.getBounds(m.glyph._custom.options,v,g+d,null,y,n),S=new ku,T=new ku;S.copyFrom(e),S.growWithSameBaseline(x),T.copyFrom(S);var A,k=new ku;return k.copyFrom(x),m.width=x.width,m.height=x.height,m.location=new Oe(x.left,x.bottom),m.glyph._custom.setSize(m.location,m.width,m.height),m.annotations.forEach((function(e){e.content.calcSize(m.location,t*e.scale),r.setAnnotationPosition(x,e,t);var n=e.content.getBounds();S.growWithSameBaseline(n),k.growWithSameBaseline(n),e=e.content.getBounds(!0),T.growWithSameBaseline(e)})),y=0,"left"===n&&k.right>v&&!1===p&&(y=v-k.right),0!==(y="right"===n&&k.left<v&&!1===p?v-k.left:y)&&(A=new Oe(y,0),m.location=m.location.add(A),m.glyph._custom.setSize(m.location,m.width,m.height),m.annotations.forEach((function(t){t.content.offsetLocation(A)})),S.left+=y,S.right=Math.max(S.right+y,e.right),T.left+=y,T.right=Math.max(S.right+y,e.right)),[S,T]}},{key:"setHorizontalGlyph",value:function(t,e,n){var r=this;if(null==this.glyphs[n])return(g=new ku).copyFrom(e),[e,g];var i=this.glyphs[n],o=i.space,a=i.overhang,s=i.width,l=i.leftSpace,u=i.rightSpace,c=i.xOffset,h=i.annotationsOverContent,f=this.glyphs[n];(g=new ku).copyFrom(e),i=g.width,e=g.left,null!=a&&(i+=2*a*t,e=g.left-a*t),null!=s&&(i=s),null==l&&null==u||(i=(l||0)*t+g.width+(u||0)*t,null!=l&&(e=g.left-l*t)),null==l&&null==u&&null!=s?e=g.left+(g.width-s)/2:null==l&&null!=u&&null!=s&&(e=g.right+u*t-s),o="top"===n?g.top+o*t:g.bottom-o*t;var d=f.glyph.getBounds(f.glyph._custom.options,e+c,o,i,null,n),p=new ku,m=new ku;p.copyFrom(g),p.growWithSameBaseline(d),m.copyFrom(p);var y=new ku;y.copyFrom(d),f.width=d.width,f.height=d.height,f.location=new Oe(d.left,d.bottom),f.glyph._custom.setSize(f.location,f.width,f.height),f.annotations.forEach((function(e){e.content.calcSize(f.location,t*e.scale),r.setAnnotationPosition(d,e,t);var n=e.content.getBounds();p.growWithSameBaseline(n),y.growWithSameBaseline(n),e=e.content.getBounds(!0),m.growWithSameBaseline(e)}));var v,g=0;return"top"===n&&y.bottom<o&&!1===h&&(g=o-y.bottom),0!==(g="bottom"===n&&y.top>o&&!1===h?o-y.top:g)&&(v=new Oe(0,g),f.location=f.location.add(v),f.glyph._custom.setSize(f.location,f.width,f.height),f.annotations.forEach((function(t){t.content.offsetLocation(v)})),p.top+=g,p.bottom+=g,m.top+=g,m.bottom+=g),[p,m]}},{key:"setAnnotationPosition",value:function(t,e,n){var r,i=e.xPosition,o=e.yPosition,a=e.xAlign,s=e.yAlign,l=Ae(l=e.offset),u=e.content,c=e.fullContentBounds,h=new Oe(t.left,t.bottom+t.descent);null!=t.annotations&&null!=e.reference&&(null!=(e=t.annotations[e.reference]).xPosition&&(i=e.xPosition),null!=e.yPosition&&(o=e.yPosition),null!=e.xAlign&&(a=e.xAlign),null!=e.yAlign&&(s=e.yAlign),null!=e.offset&&(l=l.add(Ae(e.offset)))),i=(i="right"===i?1:"center"===i?.5:"number"==typeof i?i:0)*t.width+h.x,r=(r="bottom"===o?0:"middle"===o?.5:"top"===o?1:"number"==typeof o?o:"string"==typeof o&&"a"===o.slice(-1)[0]?(r=parseFloat(o),t.ascent/t.height*r+t.descent/t.height):t.descent/t.height)*t.height+h.y-t.descent,c=u.getBounds(c),"center"===a?i-=.5*c.width:"right"===a?i-=c.width:"number"==typeof a&&(i-=c.width*a),"bottom"===s?r+=c.descent:"middle"===s?r=r+c.descent-c.height/2:"top"===s?r-=c.ascent:"string"==typeof s&&"a"===s.slice(-1)[0]?(a=parseFloat(s),r-=c.ascent*a):"number"==typeof s&&(r+=c.descent-c.height*s),i+=(l=Ae(l)).x*n,r+=l.y*n,c=new Oe(i,r).sub(c.left,c.bottom+c.descent),u.offsetLocation(c)}},{key:"getBounds",value:function(){return 0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&null!=this.fullSize?new ku({left:this.location.x+this.fullSize.leftOffset,right:this.location.x+this.fullSize.leftOffset+this.fullSize.width,top:this.location.y+this.fullSize.ascent,bottom:this.location.y-this.fullSize.descent,width:this.fullSize.width,height:this.fullSize.height,ascent:this.fullSize.ascent,descent:this.fullSize.descent}):new ku({left:this.location.x,right:this.location.x+this.width,top:this.location.y+this.ascent,bottom:this.location.y-this.descent,width:this.width,height:this.height,ascent:this.ascent,descent:this.descent})}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Xu(t){return(Xu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $u(t,e,n){return($u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Zu(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Ju(t,e){return(Ju=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Zu(t){return(Zu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Qu=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ju(t,e)}(i,Ru);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Zu(e);return function(t,e){if(e&&("object"===Xu(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Zu(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){var n;return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),(n=r.call(this,[])).elements=t,n.collectionMethods=e,n.description=null,n.modifiers={},n.elementMods={},n.onShow=null,n.onTransition=null,n.fromForm={},n.positionsSet=!1,n.layout="always",n}return t=[{key:"getNamedElements",value:function(){var t={};return this.collectionMethods.getAllElements().forEach((function(e){t[e.name]=e})),t}},{key:"setPositions",value:function(){0<arguments.length&&void 0!==arguments[0]&&arguments[0]||"always"!==this.layout&&!1!==this.positionsSet||this.arrange(this.arranged.scale,this.arranged.xAlign,this.arranged.yAlign,this.arranged.fixTo),$u(Zu(i.prototype),"setPositions",this).call(this)}},{key:"_dup",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.elements,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.collectionMethods,n=(t=new i(t,e),{});e.getAllElements().forEach((function(t){n[t.name]=t}));var r=[];return this.content.forEach((function(t){r.push(t._dup(n))})),t.content=r,dt(this,t,["content","collectionMethods","form","elements"]),t}},{key:"arrange",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"left",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"baseline",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new Oe(0,0);this.arranged={scale:t,xAlign:e,yAlign:n,fixTo:r};var o=this.collectionMethods.getAllElements().filter((function(t){return t.isShown}));this.collectionMethods.hideAll(),this.collectionMethods.show(),this.positionsSet=!0,$u(Zu(i.prototype),"calcSize",this).call(this,new Oe(0,0),t),this.setPositions(!0);var a=new Oe(0,0);r instanceof jl||r instanceof Rl?null!=(s=r.transform.t())&&(a=s._dup()):a=new Oe(-r.x,-r.y);var s,l=this.width,u=this.height,c=this.ascent,h=this.descent,f=this.location._dup();(r instanceof jl||r instanceof Rl)&&(t=r.transform.t(),s=r.transform.s(),null!=t&&null!=s&&(l=(r=r.getBoundingRect("draw")).width*s.x,u=r.height*s.y,c=r.top*s.y-t.y,h=t.y-r.bottom*s.y,f=t._dup())),"right"===e?a.x+=l:"center"===e?a.x+=l/2:"number"==typeof e?a.x+=e*l:null!=e&&"o"===e.slice(-1)[0]&&(e=parseFloat(e),a.x+=e),"top"===n?a.y+=f.y+c:"bottom"===n?a.y+=f.y-h:"middle"===n?a.y+=f.y-h+u/2:"number"==typeof n?a.y+=f.y-h+n*u:null!=n&&"o"===n.slice(-1)[0]&&(n=parseFloat(n),a.y+=f.y+n),0===(a=new Oe(0,0).sub(a)).x&&0===a.y||(this.offsetLocation(a),this.setPositions(!0)),this.collectionMethods.showOnly(o)}},{key:"lazyArrange",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"left",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"baseline",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:new Oe(0,0);this.arranged={scale:t,xAlign:e,yAlign:n,fixTo:r},this.positionsSet=!1}},{key:"dissolveElements",value:function(t){var e,n,r,i=this,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"in",a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.01,s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1,l=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;0===t.length&&l?this.fnMap.exec(l,!1):(e=t.length,n=0,r=function(t){(n+=1)===e&&l&&i.fnMap.exec(l,t)},t.forEach((function(t){t.animations.addTo("_EquationColor").opacity({dissolve:o,onFinish:r,duration:s,delay:a,completeOnCancel:!0}).start()})))}},{key:"getElementsToShowAndHide",value:function(){var t=this.collectionMethods.getAllElements().filter((function(t){return t.isShown})),e=this.getAllElements(!1),n=t.filter((function(t){return-1===e.indexOf(t)}));return{show:e.filter((function(e){return-1===t.indexOf(e)})),hide:n}}},{key:"render",value:function(){this.hideShow(),this.setPositions()}},{key:"showHide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;3<arguments.length&&void 0!==arguments[3]&&!arguments[3]||this.collectionMethods.stop(),this.collectionMethods.show();var r=(i=this.getElementsToShowAndHide()).show,i=i.hide;0===t?r.forEach((function(t){t.showAll()})):this.dissolveElements(r,"in",.01,t,null),0===e?i.forEach((function(t){return t.hide()})):this.dissolveElements(i,"out",t,e,n)}},{key:"hideShow",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;3<arguments.length&&void 0!==arguments[3]&&!arguments[3]||this.collectionMethods.stop(),this.collectionMethods.show();var r=(i=this.getElementsToShowAndHide()).show,i=i.hide;0===e?i.forEach((function(t){return t.hide()})):this.dissolveElements(i,"out",.01,e,null),0===t?(r.forEach((function(t){t.showAll()})),null!=n&&n()):this.dissolveElements(r,"in",e,t,n)}},{key:"allHideShow",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:.5,o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;this.collectionMethods.stop();var a,s,l,u,c=this.collectionMethods.getAllElements().filter((function(t){return t.isShown})),h=this.getAllElements(!1),f=h.filter((function(t){return!t.isShown})),d=h.filter((function(t){return t.isShown})),p=e;0!==h.length||0!==c.length||null==o?(a=function(){t.setPositions()},0===h.length&&(a=function(e){t.setPositions(),null!=o&&o(e)}),0<c.length?(this.dissolveElements(c,"out",e,n,a),p+=n):this.setPositions(),this.applyElementMods(),s=h.length,l=0,u=function(t){(l+=1)===s-1&&o&&o(t)},f.forEach((function(t){t.animations.addTo("_EquationColor").dissolveIn({duration:i,onFinish:u,delay:p+r}).start()})),d.forEach((function(t){t.animations.addTo("_EquationColor").dissolveIn({duration:i,onFinish:u,delay:r}).start()}))):o(!1)}},{key:"applyElementMods",value:function(){function t(t){Object.keys(t).forEach((function(e){e=(n=t[e]).element;var n=n.mods;null!=e&&null!=n&&(e.setProperties(n),null!=n.color&&e.setColor(n.color),null!=n.opacity&&e.setOpacity(n.opacity))}))}var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;t(this.elementMods),null!=e&&0<e.length&&null!=this.fromForm[e]&&null!=this.fromForm[e].elementMods&&t(this.fromForm[e].elementMods)}},{key:"animatePositionsTo",value:function(t,e,n,r){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null,a=6<arguments.length&&void 0!==arguments[6]&&arguments[6],s=this.collectionMethods.getAllElements();this.collectionMethods.stop();var l=this.getAllElements(!1);l.forEach((function(t){.001===t.opacity&&t.hide(),t.setOpacity(1)}));var u=s.filter((function(t){return t.isShown})),c=u.filter((function(t){return-1===l.indexOf(t)})),h=l.filter((function(t){return-1===u.indexOf(t)})),f=this.collectionMethods.getElementTransforms();this.setPositions();var d=this.collectionMethods.getElementTransforms(),p=[],m=[],y=[];Object.keys(d).forEach((function(t){var e=f[t],n=d[t];e.isEqualTo(n)||(p.push(t),m.push(e),y.push(n))}));var v,g={};h.forEach((function(t){g[t.name]=t.transform._dup()})),v=null===n?pr(m,y,0,new Oe(.35,.35),new Oe(0,0,2*Math.PI/6),new Oe(.4,.4)):n,this.collectionMethods.setElementTransforms(f),this.collectionMethods.setElementTransforms(g);var b=t,w=null;s=null,n=null,a?0===p.length&&0===h.length?n=i:0===p.length?s=i:w=i:0===p.length&&0===h.length?n=i:0===h.length?w=i:s=i,0<c.length?(this.dissolveElements(c,"out",t,e,n),b+=e):null!=n&&this.fnMap.exec(n),this.applyElementMods(o);var x="string"==typeof o&&0!==o.length&&null!=this.fromForm&&null!=this.fromForm[o]&&void 0!==this.fromForm[o].translation?ft({},this.translation,this.fromForm[o].translation):ft({},this.translation);return Object.keys(x).forEach((function(t){var e=(r=x[t]).element,n=r.style,r=(t=r.direction,r.mag);e&&(null!=n&&(e.animations.options.translation.style=n),null!=t&&(e.animations.options.translation.direction=t),null!=r&&(e.animations.options.translation.magnitude=r))})),a&&0<h.length&&(this.dissolveElements(h,"in",b,r,s),b+=r+.001),0<(w=this.collectionMethods.animateToTransforms(d,v,b,0,w,"_Equation"))&&(b=w),a||0<h.length&&(this.dissolveElements(h,"in",b,r,s),b+=r+.001),b}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function tc(t){return(tc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ec(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nc(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function rc(t,e){return(rc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ic(t){return(ic=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var oc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&rc(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=ic(e);return function(t,e){if(e&&("object"===tc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ic(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r,i,o,a=t.side,s="left"===a||"right"===a?(u=(r=ec(this.getLeftPoints(t,e,n),4))[0],i=r[1],o=r[2],r[3]):(u=(s=ec(this.getLeftPoints(t,n,e),4))[0],i=s[1],o=s[2],s[3]),l="right"===a?(new Qe).scale(-1,1).translate(o,0):"top"===a?(new Qe).translate(0,-s/2).rotate(-Math.PI/2).translate(s/2,o):"bottom"===a?(new Qe).translate(0,-s/2).rotate(Math.PI/2).translate(s/2,0):new Qe,u=u.map((function(t){return t.transformBy(l.m())})),c=i.map((function(t){return t.transformBy(l.m())})),h=[];return u.forEach((function(t,e){e=c[e],h.push(t),h.push(e)})),"top"===a||"bottom"===a?[h,s,o,"STRIP"]:[h,o,s,"STRIP"]}},{key:"getLeftPoints",value:function(t,e,n){for(var r=t.sides,i=(o=this.getVerticalDefaultValues(n,e,t)).lineWidth,o=(e=o.width,t=o.tipWidth,e-i),a=(Math.pow(o,2)+Math.pow(n/2,2))/(2*o),s=(t=e-t,(Math.pow(t,2)+Math.pow(n/2,2))/(2*t)),l=Math.asin(n/2/a),u=2*l/r,c=Math.asin(n/2/s),h=2*c/r,f=[],d=[],p=0;p<r+1;p+=1)f.push(Ke(a,l-u*p+Math.PI).add(a+i,n/2)),d.push(Ke(s,c-h*p+Math.PI).add(s,n/2));return[d,f,f[0].x,n]}},{key:"getDefaultValues",value:function(t,e,n){var r={};return"left"===n.side||"right"===n.side?(r=this.getVerticalDefaultValues(t,e,n)).height=t:(n=(r=this.getVerticalDefaultValues(e,t,n)).width,r.width=e,r.height=n),r}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==e&&null==n.width&&(r.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(r.width=e),null!=n.width&&(r.width=n.width),null==n.lineWidth?r.lineWidth=.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041)):r.lineWidth=n.lineWidth,null==n.tipWidth?r.tipWidth=r.lineWidth/3:r.tipWidth=n.tipWidth,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function ac(t){return(ac="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function sc(t,e){return(sc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function lc(t){return(lc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var uc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&sc(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=lc(e);return function(t,e){if(e&&("object"===ac(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=lc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r=t.fill;return e=(n=this.getDefaultValues(n,e,t)).lineWidth,t=n.width,n=n.height,[e=r?[new Oe(0,0),new Oe(t,0),new Oe(0,n),new Oe(t,n)]:[new Oe(0,0),new Oe(e,e),new Oe(0,n),new Oe(e,n-e),new Oe(t,n),new Oe(t-e,n-e),new Oe(t,0),new Oe(t-e,e),new Oe(0,0),new Oe(e,e)],t,n,"STRIP"]}},{key:"getBounds",value:function(t,e,n,r,i){var o=this.getDefaultValues(i,r,t),a=o.lineWidth,s=o.width,l=o.height,u=new ku;return"static"===t.draw?(o=t.staticWidth,t=a/(null==(t="first"===(t=t.staticHeight)?l+2*a:t)?1:t),o=a/(null==(o="first"===o?s+2*a:o)?1:o),u.width=s/(1-2*o),u.height=l/(1-2*t),o=u.width*o,t=u.height*t,u.left=e-o,u.right=u.left+u.width,u.bottom=n-t,u.top=u.bottom+u.height,u.ascent=u.height,u.descent=0):(u.left=e+r/2-s/2-a,u.bottom=n+i/2-l/2-a,u.width=s+2*a,u.height=l+2*a,u.right=u.left+u.width,u.top=u.bottom+u.height,u.descent=0,u.ascent=u.height),u}},{key:"getDefaultValues",value:function(t,e,n){var r={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?r.lineWidth=n.lineWidth:r.lineWidth=.01,!0===n.fill&&(r.lineWidth=0),null!=n.height&&"number"==typeof n.height?r.height=n.height:r.height=null!=t?t:1,null!=n.width&&"number"==typeof n.width?r.width=n.width:r.width=null!=e?e:1,r}},{key:"surround",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"local",i=[t];0!==(i=null!=e&&0!==e.length?t.getElements(e):i).length&&(n=Ae("number"==typeof n?[n,n]:n),(r=t instanceof Rl?t.getBoundingRect(r,"border",e):t.getBoundingRect(r)).left-=n.x,r.bottom-=n.y,r.width+=2*n.x,r.height+=2*n.y,r.right=r.left+r.width,r.top=r.bottom+r.height,this._custom.setSize(new Oe(r.left,r.bottom),r.width,r.height))}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function cc(t){return(cc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function hc(t,e){return(hc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function fc(t){return(fc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var dc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&hc(t,e)}(i,oc);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=fc(e);return function(t,e){if(e&&("object"===cc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=fc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){for(var r=t.sides,i=(s=this.getVerticalDefaultValues(n,e,t)).lineWidth,o=s.width,a=o/2+i/2,s=(t=a-(e=s.tipWidth),a-i),l=(Math.pow(s,2)+Math.pow(t,2))/(2*s),u=[],c=[],h=Math.PI/2/r,f=Math.asin(t/l)/r,d=[],p=[],m=0;m<r+1;m+=1){var y=m*h,v=m*f;p.push(new Oe(a*Math.cos(y),a*Math.sin(y))),d.push(new Oe(l*Math.cos(v)-l+a-i,l*Math.sin(v)))}for(var g=(new Qe).scale(-1,1).translate(o,n-a).m(),b=0;b<r+1;b+=1)u.push(p[r-b].transformBy(g)),c.push(d[r-b].transformBy(g));g=(new Qe).scale(1,-1).translate(0,n/2-e/2+a).m();for(var w=0;w<r+1;w+=1)u.push(d[w].transformBy(g)),c.push(p[w].transformBy(g));g=(new Qe).translate(0,n/2+e/2-a).m();for(var x=0;x<r+1;x+=1)u.push(d[r-x].transformBy(g)),c.push(p[r-x].transformBy(g));g=(new Qe).scale(-1,-1).translate(o,a).m();for(var S=0;S<r+1;S+=1)u.push(p[S].transformBy(g)),c.push(d[S].transformBy(g));return[u,c,o,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==e&&null==n.width&&(r.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(r.width=e),null!=n.width&&(r.width=n.width),null==n.lineWidth?r.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):r.lineWidth=n.lineWidth,null==n.tipWidth?r.tipWidth=r.lineWidth/3:r.tipWidth=n.tipWidth,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function pc(t){return(pc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function mc(t,e){return(mc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function yc(t){return(yc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var vc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mc(t,e)}(r,oc);var t,e,n=(t=r,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,r=yc(t);return function(t,e){if(e&&("object"===pc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=yc(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,[{key:"getLeftPoints",value:function(t,e,n){var r=t.sides,i=t.radius,o=(e=(o=this.getVerticalDefaultValues(n,e,t)).lineWidth,t=o.width,o.tipWidth);if(0===i)return[[new Oe(t,0),new Oe(0,0),new Oe(0,n),new Oe(t,n)],[new Oe(t,o),new Oe(e,o),new Oe(e,n-o),new Oe(t,n-o)],t,n];for(var a=i=Math.min(i,t,n/2),s=i-e,l=[new Oe(t,0)],u=[new Oe(t,e)],c=new Oe(a,a),h=new Oe(a,n-a),f=0;f<=r;f+=1){var d=Math.PI/2/r*f;l.push(Ke(a,Math.PI/2*3-d).add(c)),u.push(Ke(s,Math.PI/2*3-d).add(c))}for(var p=0;p<=r;p+=1){var m=Math.PI/2/r*p;l.push(Ke(a,Math.PI-m).add(h)),u.push(Ke(s,Math.PI-m).add(h))}return l.push(new Oe(t,n)),u.push(new Oe(t,n-e)),[l,u,t,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==e&&null==n.width&&(r.width=.8*(97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909)))),null!=e&&(r.width=e),null!=n.width&&(r.width=n.width),null==n.lineWidth?r.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):r.lineWidth=n.lineWidth,null==n.tipWidth?r.tipWidth=.7*r.lineWidth:r.tipWidth=n.tipWidth,r}}]),r}();function gc(t){return(gc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function bc(t,e){return(bc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function wc(t){return(wc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var xc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&bc(t,e)}(r,oc);var t,e,n=(t=r,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,r=wc(t);return function(t,e){if(e&&("object"===gc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=wc(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,[{key:"getLeftPoints",value:function(t,e,n){e=(r=this.getVerticalDefaultValues(n,e,t)).lineWidth,t=r.width;var r=new Ie(new Oe(0,0),new Oe(t,n/2));return e=Math.acos(e/r.length()),e=Math.PI/2-e,e=r.angle()+e,e=t-n/2/Math.tan(e),[[new Oe(t-e,0),new Oe(0,n/2),new Oe(t-e,n)],[new Oe(t,0),new Oe(e,n/2),new Oe(t,n)],t,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==e&&null==n.width&&(r.width=97570.78+-97570.775041292/(1+Math.pow(t/2399858,.9383909))),null!=e&&(r.width=e),null!=n.width&&(r.width=n.width),null==n.lineWidth?r.lineWidth=.7*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):r.lineWidth=n.lineWidth,r}}]),r}();function Sc(t){return(Sc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Tc(t,e){return(Tc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ac(t){return(Ac=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var kc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Tc(t,e)}(i,oc);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Ac(e);return function(t,e){if(e&&("object"===Sc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ac(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){return t=(e=this.getVerticalDefaultValues(n,e,t)).lineWidth,e=e.width,[[new Oe(0,0),new Oe(0,n)],[new Oe(t,0),new Oe(t,n)],e,n]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==n.lineWidth?r.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):r.lineWidth=n.lineWidth,r.width=r.lineWidth,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function _c(t){return(_c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Oc(t,e){return(Oc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Pc(t){return(Pc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Ec=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Oc(t,e)}(r,zu);var t,e,n=(t=r,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var n,r=Pc(t);return function(t,e){if(e&&("object"===_c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=Pc(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))});function r(){return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),n.apply(this,arguments)}return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,[{key:"getPoints",value:function(t,e,n){var r=t.sides,i=(b=this.getDefaultValues(n,e,t)).lineWidth,o=b.width,a=Math.PI/2*.9,s=Math.PI/2*.95,l=.431*o,u=n/2-i,c=.176*n,h=.153*n,f=c/Math.tan(a),d=h/Math.tan(s),p=i,m=2*i,y=3*i,v=.6*i,g=new Ie(new Oe(0,0),new Oe(l,u)),b=(e=p/Math.sin(g.angle()),t=new Ie({p1:new Oe(e,0),length:n,angle:g.angle()}),new Ie(new Oe(0,n),new Oe(l,u))),w=(i=-y/Math.sin(b.angle()),e=new Ie({p1:new Oe(i,n),length:n,angle:b.angle()}),i=t.intersectsWith(e).intersect,t=new Oe(o,c),e=new Oe(o-v,c),new Oe(o-f,0)),x=(f=new Oe(e.x-(c-m)/Math.tan(a),m),a=new Oe(0,0),g=new Oe(p/Math.sin(g.angle())+m/Math.tan(g.angle()),m),l=new Oe(l,u),u=i,i=new Oe(0,n),b=new Oe(-y/Math.sin(b.angle())-p/Math.tan(b.angle()),n-p),new Oe(o-d,n)),S=(d=new Oe(o,n-h),v=new Oe(o-v,n-h),s=new Oe(v.x-(h-p)/Math.tan(s),n-p),m=mr(e,f,new Oe(f.x-(c-m),m),r),[]);m.forEach((function(t){S.push(w),S.push(t)})),r=mr(new Oe(s.x-h+p,n-p),s,v,r);var T=[];return r.forEach((function(t){T.push(x),T.push(t)})),[[t,e].concat(S,[a,g,l,u,i,b],T,[d,v]),o,n,"STRIP"]}},{key:"getDefaultValues",value:function(t,e,n){return t={lineWidth:.88*t/(25*t+15),width:.88*t,height:t},null!=n.lineWidth&&(t.lineWidth=n.lineWidth),null!=n.width&&(t.width=n.width),t}}]),r}();function Mc(t){return(Mc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Cc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function jc(t,e){return(jc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Rc(t){return(Rc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Bc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&jc(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Rc(e);return function(t,e){if(e&&("object"===Mc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Rc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r=t.serif,i=t.sides,o=(b=this.getDefaultValues(n,e,t)).lineWidth,a=b.width,s=i;"false"===r&&(s=2);var l=1.2*o,u=3*o,c=o/2,h=.9*u,f=new Oe(0,0),d=new Oe(u+2*h,0),p=new Oe(f.x,c),m=new Oe(d.x,c),y=new Oe(h,p.y),v=new Oe(h+u,y.y),g=(e=new Oe(y.x,n-c),new Oe(v.x,n-c)),b=(t=new Oe(p.x,n-c),new Oe(p.x,n)),w=(i=new Oe(m.x,n),r=p,o=y,c=new Oe(y.x,y.y+h),p=m,m=v,y=new Oe(v.x,y.y+h),c=mr(r,o,c,s),mr(p,m,y,s)),x=[];c.forEach((function(t,e){x.push(t),x.push(w[e])})),s=mr(new Oe(e.x,e.y-h),e,t,s);var S=[];s.forEach((function(t){S.push(t),S.push(new Oe(g.x,t.y))}));for(var T,A=[f,d].concat(x,S,[b,i]),k=[],_=A.length-1;0<_;_-=2)k.push(new Oe(a-A[_-1].x,A[_-1].y)),k.push(new Oe(a-A[_].x,A[_].y));return l=[new Oe(h+u,n),new Oe(h+u,n-l),new Oe(a-h-u,n),new Oe(a-h-u,n-l)],[[].concat(function(t){if(Array.isArray(t))return Cc(t)}(T=A)||function(){if("undefined"!=typeof Symbol&&null!=T[Symbol.iterator]||null!=T["@@iterator"])return Array.from(T)}()||function(t){if(t){if("string"==typeof t)return Cc(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Cc(t,void 0):void 0}}(T)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),l,k),a,n,"STRIP"]}},{key:"getDefaultValues",value:function(t,e,n){var r={lineWidth:n.lineWidth||1,width:e||1,height:t};return null==n.lineWidth&&null!=e?r.lineWidth=e/7/3:null==n.lineWidth&&null==e?(r.lineWidth=12902.65+-12902.648946996/(1+Math.pow(t/573148,.9938213)),r.width=1704804+-1704803.997815697/(1+Math.pow(t/2234236,.9967453))):null!=n.lineWidth&&null==e&&(r.width=7*n.lineWidth*3),r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Fc(t){return(Fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ic(t){return function(t){if(Array.isArray(t))return Dc(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Dc(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Dc(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Dc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Lc(t,e){return(Lc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function zc(t){return(zc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Wc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Lc(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=zc(e);return function(t,e){if(e&&("object"===Fc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=zc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r,i,o=t.sides,a=t.serif,s=t.num,l=t.type,u=t.serifSides,c=t.lineIntegralSides,h=(e=this.getDefaultValues(n,e,t)).lineWidth,f=(t=e.width,e.tipWidth),d=t-(s-1)*h*3,p=n,m=.7*h,y=(e=d,o=_(-(e=a?d-2*m:e)/2,e/2,e/o),-Math.log(n/(.99999999999*n)-1)/d/2),v=0,g=[];o.forEach((function(t,e){var o=1/(1+Math.exp(-y*t)),a=Math.atan(p*y*o*(1-o)),s=o*p,l=(u=(h/2-f/2)*Math.pow(Math.cos((s-n/2)/n*Math.PI),2)+f/2)*Math.cos(a+Math.PI/2),u=(o=u*Math.sin(a+Math.PI/2),new Oe(t+l+d/2,s+o));o=new Oe(t-l+d/2,s-o),0<e&&(g.push(r._dup()),g.push(i._dup()),g.push(o._dup()),g.push(r._dup()),g.push(o._dup()),g.push(u._dup())),r=u,i=o,0===e&&(v=a)}));var b=[];if(!1===a)b=g;else{for(var w=u,x=new Oe(g[1].x+m*Math.cos(v+Math.PI/2),g[1].y+m*Math.sin(v+Math.PI/2)),S=new Oe(g[g.length-1].x+m*Math.cos(v-Math.PI/2),g[g.length-1].y+m*Math.sin(v-Math.PI/2)),T=[],A=[],k=2*Math.PI/Math.max(w,3),O=new Oe(0,0),P=new Oe(0,0),E=0;E<w+1;E+=1){var M=new Oe(x.x+m*Math.cos(k*E),x.y+m*Math.sin(k*E)),C=new Oe(S.x+m*Math.cos(k*E),S.y+m*Math.sin(k*E));0<E&&(T.push(g[1]._dup()),T.push(O._dup()),T.push(M._dup()),A.push(g[g.length-2]._dup()),A.push(P._dup()),A.push(C._dup())),O=M,P=C}b=[].concat(T,g,A)}for(var j=b.length,R=1;R<s;R+=1)for(var B=0;B<j;B+=1)b.push(b[B].add(3*h*R,0));return"line"===l&&(c=this.getLineIntegralPoints(h,s,t,n,c),b=[].concat(Ic(b),Ic(c))),[b,t,n,"TRIANGLES"]}},{key:"getLineIntegralPoints",value:function(t,e,n,r,i){for(var o=6*t,a=Math.max(o,2*(3*t+(e-1)*t*3/2)),s=new Oe(n/2,r/2),l=2*Math.PI/i,u=new Oe(0,0),c=new Oe(0,0),h=t/2,f=[],d=0;d<i+1;d+=1){var p=d*l,m=new Oe((a/2-h/2)*Math.cos(p),(o/2-h/2)*Math.sin(p)).add(s);p=new Oe((a/2+h/2)*Math.cos(p),(o/2+h/2)*Math.sin(p)).add(s),0<d&&(f.push(u._dup()),f.push(c._dup()),f.push(m._dup()),f.push(u._dup()),f.push(m._dup()),f.push(p._dup())),u=p,c=m}return f}},{key:"getDefaultValues",value:function(t,e,n){var r=607.73+-607.7295779198/(1+Math.pow(t/5368595,.6370402));return t={lineWidth:r,width:12277.16+-12277.156262281/(1+Math.pow(t/36507180,.6193363))+(n.num-1)*r*3,tipWidth:.01033455+-.010329798066/(1+Math.pow(t/.2588074,2.024942)),height:t},null!=e&&(t.width=e),null!=n.lineWidth&&(t.lineWidth=n.lineWidth),null!=n.tipWidth?t.tipWidth=n.tipWidth:t.tipWidth=t.lineWidth/3,t}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Nc(t){return(Nc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qc(t,e){return(qc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Hc(t){return(Hc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Uc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&qc(t,e)}(i,oc);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Hc(e);return function(t,e){if(e&&("object"===Nc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Hc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getLeftPoints",value:function(t,e,n){var r=t.direction,i=n;null==i&&(i=t.length);var o,a=(c=this.getVerticalDefaultValues(i,e,t)).lineWidth,s=c.arrowWidth,l=c.arrowLength,u=new Oe(s/2+a/2,0),c=(n=new Oe(s/2-a/2,0),e=new Oe(u.x,i-l),t=new Oe(n.x,e.y),new Oe(s,e.y));return a=new Oe(0,e.y),l=new Oe(s/2,i),a=[n._dup(),t._dup(),a._dup(),l._dup()],l=[u._dup(),e._dup(),c._dup(),l._dup()],"down"!==r&&"left"!==r||(o=(new Qe).scale(1,-1).translate(0,i).m(),a=a.map((function(t){return t.transformBy(o)})),l=l.map((function(t){return t.transformBy(o)}))),[a,l,s,i]}},{key:"getVerticalDefaultValues",value:function(t,e,n){var r={};return null==n.lineWidth?r.lineWidth=.8*(.2933614+-.2932195822/(1+Math.pow(t/39.01413,.618041))):r.lineWidth=n.lineWidth,null==n.arrowWidth?r.arrowWidth=3*r.lineWidth:r.arrowWidth=n.arrowWidth,null==n.arrowLength?r.arrowLength=3*r.lineWidth:r.arrowLength=n.arrowLength,r.width=r.arrowWidth,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Kc(t){return(Kc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Vc(t,e){return(Vc=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Gc(t){return(Gc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Yc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Vc(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Gc(e);return function(t,e){if(e&&("object"===Kc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Gc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){return e=(n=this.getDefaultValues(n,e,t)).lineWidth,t=n.width,n=n.height,[[new Oe(0,0),new Oe(0,e),new Oe(t,0),new Oe(t,e)],t,n,"STRIP"]}},{key:"getDefaultValues",value:function(t,e,n){var r={};return null!=n.lineWidth?r.lineWidth=n.lineWidth:r.lineWidth=.01,r.height=r.lineWidth,r.width=null!=e?e:1,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Xc(t){return(Xc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $c(t,e){return($c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Jc(t){return(Jc=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Zc=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$c(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Jc(e);return function(t,e){if(e&&("object"===Xc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Jc(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r=t.style,i=(p=this.getDefaultValues(n,e,t)).lineWidth,o=p.width,a=p.height,s=Math.atan2(a,o),l=Math.PI/2-s,u=i*Math.cos(l),c=i*Math.sin(l),h=new Oe(0,c),f=new Oe(u,0),d=new Oe(0,a-c),p=(n=new Oe(u,a),e=new Oe(o-u,a),t=new Oe(o,a-c),new Oe(o-u,0));return s=new Oe(o,c),l=new Oe(0,a/2-i/2),u=new Oe(0,a/2+i/2),c=new Oe(o,a/2-i/2),i=new Oe(o,a/2+i/2),[u="forward"===r?[h,f,t,h,t,e]:"back"===r?[d,n,s,d,s,p]:"cross"===r?[h,f,t,h,t,e,d,n,s,d,s,p]:[l,c,i,l,i,u],o,a,"TRIANGLES"]}},{key:"getBounds",value:function(t,e,n,r,i){return r=(i=this.getDefaultValues(i,r,t)).width,t=i.height,(i=new ku).left=e,i.bottom=n,i.width=r,i.height=t,i.right=i.left+i.width,i.top=i.bottom+i.height,i.descent=0,i.ascent=i.height,i}},{key:"getDefaultValues",value:function(t,e,n){var r={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?r.lineWidth=n.lineWidth:r.lineWidth=.015,null!=n.height&&"number"==typeof n.height?r.height=n.height:r.height=null!=t?t:1,null!=n.width&&"number"==typeof n.width?r.width=n.width:r.width=null!=e?e:1,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Qc(t){return(Qc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function th(t,e){return(th=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function eh(t){return(eh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var nh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&th(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=eh(e);return function(t,e){if(e&&("object"===Qc(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=eh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r=(f=this.getDefaultValues(n,e,t)).lineWidth,i=f.startWidth,o=f.tickWidth,a=f.tickHeight,s=f.downWidth,l=f.startHeight,u=f.lineWidth2,c=f.height,h=f.width,f=(t=new Oe(0,l-a),new Oe(o,l));return a=new Oe(s+o,0),l=new Oe(i,c-r),s=new Oe(h,c-r),o=new Ie(t,f),i=new Ie(f,a),h=new Ie(a,l),c=new Ie(l,s),o=o.offset("top",r),i=i.offset("top",u),u=h.offset("top",r),h=c.offset("top",r),c=o.p1._dup(),o=o.intersectsWith(i).intersect,i=i.intersectsWith(u).intersect,h=u.intersectsWith(h).intersect,r=s.add(0,r),[[t,c,f,o,a,i,l,h,s,r],e,n,"STRIP"]}},{key:"getBounds",value:function(t,e,n,r,i){var o=this.getHeightFromContentHeight(i,t),a=this.getDefaultValues(o,r,t),s=a.width,l=a.startWidth,u=a.lineWidth,c=a.startHeight,h=a.downWidth,f=a.tickWidth,d=a.lineWidth2;return i=new ku,"static"===t.draw?(a=t.staticWidth,u/=t=null==(t="first"===(t=t.staticHeight)?o+u:t)?1:t,a=l/(null==(a="first"===a?s+l:a)?1:a),t=c/t,i.width=s/(1-a),i.height=o/(1-u),a=i.width*a,t=i.height*t,u=i.height*u,i.left=e-a,i.right=i.left+i.width,i.bottom=n,i.top=i.bottom+i.height,i.ascent=i.height,i.descent=0,i.annotations={root:{xPosition:"left",yPosition:"bottom",xAlign:"right",yAlign:"bottom",offset:new Oe(.5*a,t+2*u)}}):(i.left=e+r/2-s/2-l,i.bottom=n,i.width=s+l,i.height=o,i.right=i.left+i.width,i.top=i.bottom+i.height,i.descent=0,i.ascent=i.height,i.annotations={root:{xPosition:"left",yPosition:"bottom",xAlign:"right",yAlign:"bottom",offset:new Oe(h+f,c+d)}}),i}},{key:"getHeightFromContentHeight",value:function(t,e){return(t=null!=t?t:1)+(null!=e.lineWidth&&"number"==typeof e.lineWidth?e.lineWidth:.01)}},{key:"getDefaultValues",value:function(t,e,n){var r={};return null!=n.lineWidth&&"number"==typeof n.lineWidth?r.lineWidth=n.lineWidth:r.lineWidth=.01,null!=n.lineWidth2&&"number"==typeof n.lineWidth2?r.lineWidth2=n.lineWidth2:r.lineWidth2=2*r.lineWidth,null!=n.height&&"number"==typeof n.height?r.height=n.height:r.height=null!=t?t:1,null!=n.startHeight&&"number"==typeof n.startHeight?(r.startHeight=n.startHeight,n.proportionalToHeight&&(r.startHeight=n.startHeight*r.height)):r.startHeight=r.height/3,null!=n.maxStartHeight&&n.maxStartHeight<r.startHeight&&(r.startHeight=n.maxStartHeight),null!=n.tickHeight&&"number"==typeof n.tickHeight?(r.tickHeight=n.tickHeight,n.proportionalToHeight&&(r.tickHeight=n.tickHeight*r.startHeight)):r.tickHeight=.1*r.startHeight,null!=n.startWidth&&"number"==typeof n.startWidth?(r.startWidth=n.startWidth,n.proportionalToHeight&&(r.startWidth=n.startWidth*r.height)):r.startWidth=r.startHeight/2,null!=n.maxStartWidth&&n.maxStartWidth<r.startWidth&&(r.startWidth=n.maxStartWidth),null!=n.tickWidth&&"number"==typeof n.tickWidth?(r.tickWidth=n.tickWidth,n.proportionalToHeight&&(r.tickWidth=n.tickWidth*r.startWidth)):r.tickWidth=r.startWidth/5,null!=n.downWidth&&"number"==typeof n.downWidth?(r.downWidth=n.downWidth,n.proportionalToHeight&&(r.downWidth=n.downWidth*r.startWidth)):r.downWidth=r.startWidth/5*2,null!=n.width&&"number"==typeof n.width?r.width=n.width:r.width=null!=e?e:1,r}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function rh(t){return(rh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ih(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function oh(t,e){return(oh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ah(t){return(ah=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var sh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&oh(t,e)}(i,zu);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=ah(e);return function(t,e){if(e&&("object"===rh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=ah(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"getPoints",value:function(t,e,n){var r=new Ie({p1:[0,0],length:n,angle:e});return[(r=ri([new Oe(0,0),r.p2],t.width,!1,"mid","none",.1,1,0,t.dash,!1,2,[[]],0,t.arrow),t=1,(function(t){if(Array.isArray(t))return t}(r)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(r,t)||function(t,e){if(t){if("string"==typeof t)return ih(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ih(t,e):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),e,n,"TRIANGLES"]}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}(),lh=function(){function t(e,n){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.shapes=e,this.defaultColor=n}var e=[{key:"get",value:function(t,e){return"vinculum"===t?this.vinculum(e):"strike"===t?this.strike(e):"bracket"===t?this.bracket(e):"squareBracket"===t?this.squareBracket(e):"brace"===t?this.brace(e):"bar"===t?this.bar(e):"tBox"===t?this.touchBox(e):"box"===t?this.box(e):"angleBracket"===t?this.angleBracket(e):"radical"===t?this.radical(e):"sum"===t?this.sum(e):"prod"===t?this.product(e):"int"===t?this.integral(e):"arrow"===t?this.arrow(e):"line"===t?this.line(e):null}},{key:"vinculum",value:function(t){return t=ft({color:this.defaultColor,lineWidth:null,staticHeight:null,draw:"dynamic",staticWidth:"first",drawBorderBuffer:0,touchBorder:0},t),new Yc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"box",value:function(t){return t=ft({color:this.defaultColor,fill:!1,width:null,height:null,lineWidth:.01,draw:"dynamic",staticHeight:"first",staticWidth:"first"},t),new uc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"line",value:function(t){return t=ft({color:this.defaultColor,width:.01,dash:[],arrow:null,draw:"dynamic",staticHeight:"first",staticWidth:"first"},t),new sh(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"touchBox",value:function(t){return t=ft({color:[0,0,0,1e-4],fill:!1,width:null,height:null,lineWidth:.01,draw:"static",staticHeight:"first",staticWidth:"first",isTouchable:!0},t),new uc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"arrow",value:function(t){return"left"===(t=ft({color:this.defaultColor,direction:"right",lineWidth:.01,arrowWidth:.03,arrowLength:.04,length:.1,staticHeight:"first",draw:"dynamic",staticWidth:null},t)).direction||"right"===t.direction?t.side="top":t.side="left",new Uc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"sum",value:function(t){return t=ft({color:this.defaultColor,lineWidth:null,sides:5,staticHeight:"first",draw:"static",staticWidth:null,drawBorderBuffer:0,touchBorder:0},t),new Ec(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"product",value:function(t){return t=ft({color:this.defaultColor,lineWidth:null,sides:5,staticHeight:"first",draw:"static",staticWidth:null},t),new Bc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"integral",value:function(t){return t=ft({color:this.defaultColor,lineWidth:null,width:null,tipWidth:null,sides:30,serif:!0,staticHeight:"first",draw:"static",staticWidth:null,num:1,type:"generic",serifSides:10,lineIntegralSides:20},t),new Wc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"radical",value:function(t){var e={color:this.defaultColor,lineWidth:.01,staticSize:null,startHeight:.5,startWidth:.5,maxStartWidth:.15,maxStartHeight:.15,proportionalToHeight:!0,draw:"dynamic",staticHeight:"first",staticWidth:"first"};return null!=t.proportionalToHeight&&!1===t.proportionalToHeight&&(e.startHeight=.15,e.startWidth=.15),t=ft(e,t),new nh(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"strike",value:function(t){return t=ft({style:"cross",color:this.defaultColor,lineWidth:null,draw:"dynamic",staticHeight:"first",width:null,height:null,staticWidth:"first"},t),new Zc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"bracket",value:function(t){return t=ft({side:"left",color:this.defaultColor,lineWidth:null,sides:10,draw:"dynamic",staticHeight:"first",width:null,tipWidth:null,staticWidth:null},t),new oc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"angleBracket",value:function(t){return t=ft({side:"left",lineWidth:null,width:null,color:this.defaultColor,draw:"dynamic",staticHeight:"first"},t),new xc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"brace",value:function(t){return t=ft({side:"left",color:this.defaultColor,lineWidth:null,sides:10,draw:"dynamic",staticHeight:"first",width:null,tipWidth:null,staticWidth:null},t),new dc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"bar",value:function(t){return t=ft({side:"left",lineWidth:.01,color:this.defaultColor,draw:"dynamic",staticHeight:"first"},t),new kc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}},{key:"squareBracket",value:function(t){return t=ft({side:"left",lineWidth:null,color:this.defaultColor,width:null,draw:"dynamic",staticHeight:"first",radius:0,sides:5,tipWidth:null},t),new vc(this.shapes.webgl[0],t.color,(new Qe).scale(1,1).translate(0,0),t)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function uh(t){return(uh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ch(t){return function(t){if(Array.isArray(t))return hh(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return hh(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?hh(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function hh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function fh(t,e){return(fh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function dh(t){return(dh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var ph=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&fh(t,e)}(i,Ru);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=dh(e);return function(t,e){if(e&&("object"===uh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=dh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e,n){var o=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var a=[];Array.isArray(e)?e.forEach((function(t){a.push(null!=t?new ju(t):null)})):a.push(null!=e?new ju(e):null);var s=[];return Array.isArray(e)?s=e:s.push(e),e=[],Array.isArray(t)?e=t:e.push(t),(t=r.call(this,[].concat(a,ch(e)))).glyphs=s,t.contents=e,t.glyphLocations=a.map((function(){return new Oe(0,0)})),t.glyphWidths=a.map((function(){return 1})),t.glyphHeights=a.map((function(){return 1})),t.options=n,t.showContent=o,t}return t=[{key:"_dup",value:function(t){var e,n=this.contents.map((function(e){return null==e?null:e._dup(t)})),r=this.glyphs;return t&&(e=[],this.glyphs.forEach((function(n){null!=n?e.push(t[n.name]):e.push(n)})),r=e),dt(this,r=new this.constructor(n,r,this.options),["content","contents","glyphs"]),r}},{key:"getAllElements",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!t&&!this.showContent)return[];var e=[];return this.contents.forEach((function(n){null!=n&&(e=[].concat(ch(e),ch(n.getAllElements(t))))})),this.glyphs.forEach((function(t){null!=t&&(e=[].concat(ch(e),[t]))})),e}},{key:"setPositions",value:function(){var t=this;this.glyphs.forEach((function(e,n){var r;null!=e&&((r=e.getTransform()._dup()).updateTranslation([t.glyphLocations[n].x,t.glyphLocations[n].y]),r.updateScale([t.glyphWidths[n],t.glyphHeights[n]]),e.setTransform(r))})),this.contents.forEach((function(t){null!=t&&t.setPositions()}))}},{key:"offsetLocation",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Oe(0,0);this.location=this.location.add(e),this.glyphLocations.forEach((function(n,r){null!=t.glyphs[r]&&(t.glyphLocations[r]=n.add(e))})),this.contents.forEach((function(t){null!=t&&t.offsetLocation(e)}))}},{key:"calcSize",value:function(t,e){}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function mh(t){return(mh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function yh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return vh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?vh(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function gh(t,e){return(gh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function bh(t){return(bh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var wh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&gh(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=bh(e);return function(t,e){if(e&&("object"===mh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=bh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),r=yh(this.glyphs,1)[0],i=(m=yh(this.contents,2))[0],o=m[1],a=(y=this.options).scaleModifier,s=y.numeratorSpace,l=y.denominatorSpace,u=y.overhang,c=y.offsetY,h=y.fullContentBounds,f=y.baseline,d=e*a,p=new ku,m=new ku,y=new ku;e=new ku,null!=i&&(i.calcSize(n._dup(),d),m.copyFrom(i.getBounds(h))),null!=o&&(o.calcSize(n._dup(),d),y.copyFrom(o.getBounds(h))),this.location=t._dup(),p.width=Math.max(m.width,y.width)+2*u*d,null!=r&&(p.height=r.getHeight(r._custom.options,p.width)),s=new Oe(n.x+(p.width-m.width)/2,n.y+(a=d*c/a)+p.height+s*d+m.descent),l=new Oe(n.x+(p.width-y.width)/2,n.y+a-l*d-y.ascent),d=0,"numerator"===f&&null!=i?d=n.y-s.y:"denominator"===f&&null!=o&&(d=n.y-l.y),null!=i&&i.offsetLocation(s.sub(i.location.x,i.location.y-d)),null!=o&&o.offsetLocation(l.sub(o.location.x,o.location.y-d)),this.width=p.width,this.descent=n.y-(l.y-y.descent),this.descent<0&&(this.descent=0),this.ascent=s.y+m.ascent-n.y,this.height=this.descent+this.ascent,this.glyphLocations[0]=new Oe(this.location.x,this.location.y+a+d),this.glyphWidths[0]=p.width,this.glyphHeights[0]=p.height,e.copyFrom(p),e.left=this.glyphLocations[0].x,e.bottom=this.glyphLocations[0].y,null!=i&&e.growWithSameBaseline(i.getBounds(!0)),null!=o&&e.growWithSameBaseline(o.getBounds(!0)),r&&r._custom.setSize(this.glyphLocations[0],p.width,p.height),this.fullSize={leftOffset:this.location.x-e.left,width:e.width,ascent:e.ascent,descent:e.descent,height:e.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function xh(t){return(xh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Sh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Th(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Th(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Th(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ah(t,e){return(Ah=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function kh(t){return(kh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var _h=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ah(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=kh(e);return function(t,e){if(e&&("object"===xh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=kh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();for(var n=t._dup(),r=.07*e,i=this.options,o=i.order,a=(t=i.fit,i.space),s=i.contentScale,l=i.yAlign,u=i.fullContentBounds,c=(o=Sh(o,2))[0],h=o[1],f=[],d=[],p=0,m=[],y=0;y<c;y+=1){m.push([]),f.push([]),d.push([]);for(var v=0;v<h;v+=1){var g=new ku,b=this.contents[p];null!=b&&(b.calcSize(n._dup(),e*s),g.copyFrom(b.getBounds(u))),m[y].push(b),f[y].push(g),d[y].push(new Oe(0,0)),p+=1}}var w=function(t,e,n){for(var r=[],i=[],o=[],a=0,s=0,l=0,u=0;u<t;u+=1){for(var c=0,h=0,f=0;f<e;f+=1){var d=n[u][f];(d.ascent>c||0===f)&&(c=d.ascent),(d.descent>h||0===f)&&(h=d.descent)}(a<c||0===u)&&(a=c),(s<h||0===u)&&(s=h);var p=h+c;(l<p||0===u)&&(l=p),o.push(p),r.push(c),i.push(h)}return{ascents:r,descents:i,heights:o,maxAscent:a,maxDescent:s,maxHeight:l}}(c,h,f),x=(o=Sh(function(t,e,n){for(var r=[],i=0,o=0;o<e;o+=1){for(var a=0,s=0;s<t;s+=1){var l=n[s][o].width;a<l&&(a=l),i<l&&(i=l)}r.push(a)}return[r,i]}(c,h,f),2))[0];if(o=o[1],o=Math.max(o,w.maxHeight),"min"!==t){for(var S="max"===t?new Oe(o,o):Te(t)?Ae(t):new Oe(0,0),T=0;T<c;T+=1)w.heights[T]=S.y;for(var A=0;A<h;A+=1)x[A]=S.x}for(var k=0,_=0,O=c-1;0<=O;--O){_=0;for(var P=0;P<h;P+=1){var E=f[O][P],M=_+x[P]/2-E.width/2;E=k+w.heights[O]/2-(E.ascent-E.descent)/2,"baseline"===l&&(E=k+w.descents[O]),_+=x[P]+a.x*e,d[O][P]=new Oe(M,E)}k+="baseline"===l?w.descents[O]+w.ascents[O]+a.y*e:w.heights[O]+a.y*e}for(var C=k-a.y*e,j=(t=_-a.x*e,new ku),R=0;R<c;R+=1)for(var B=0;B<h;B+=1){d[R][B].x+=n.x,d[R][B].y=n.y-C/2+d[R][B].y+r;var F=m[R][B];null!=F&&(F.offsetLocation(d[R][B].sub(F.location)),0===j.width&&j.copyFrom(F.getBounds(!0)),j.growWithSameBaseline(F.getBounds(!0)))}this.width=t,this.height=C,this.descent=C/2-r,this.ascent=C/2+r,this.fullSize={leftOffset:this.location.x-j.left,width:j.width,ascent:j.ascent,descent:j.descent,height:j.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Oh(t){return(Oh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ph(t,e){return(Ph=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Eh(t){return(Eh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Mh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ph(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Eh(e);return function(t,e){if(e&&("object"===Oh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Eh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();for(var n=t._dup(),r=this.options,i=r.lineOptions,o=(t=r.yAlign,r.fullContentBounds),a=r.justify,s=i.length,l=[],u=[],c=0,h=0;h<s;h+=1){var f=new ku,d=this.contents[h];null!=d&&(d.calcSize(n._dup(),e),f.copyFrom(d.getBounds(o))),l.push(f),u.push(new Oe(0,0)),f.width>c&&(c=f.width)}for(var p=u[0].y+l[0].ascent,m=u[0].y-l[0].descent,y=1;y<s;y+=1){var v=u[y-1].y,g=i[y],b=g.space;null!=(g=g.baselineSpace)?u[y].y=v-g:(w=l[y-1].descent,g=l[y].ascent,u[y].y=v-g-w-b);var w=u[y].y+l[y].ascent;p<w&&(p=w),(b=u[y].y-l[y].descent)<m&&(m=b)}var x=0;"top"===t?x=-p:"middle"===t?x=(p-m)/2-p:"bottom"===t?x-=m:"number"==typeof t&&t<s&&(x-=u[t].y);for(var S=0,T=0;T<s;T+=1)"right"===a?u[T].x=-l[T].width:"center"===a?u[T].x=-l[T].width/2:"element"===a&&null!=i[T].justify&&(u[T].x=-i[T].justify.transform.t().x),u[T].x+=i[T].offset,u[T].x<S&&(S=u[T].x);for(var A=0;A<s;A+=1)u[A].x-=S;for(var k=new ku,_=new ku,O=0;O<s;O+=1){var P=this.content[O];null!=P&&(P.offsetLocation(u[O].add(0,x)),0===k.width&&k.copyFrom(P.getBounds(!0)),k.growWithSameBaseline(P.getBounds(!0)),0===_.width&&_.copyFrom(P.getBounds(!1)),_.growWithSameBaseline(P.getBounds(!1)))}this.width=_.width,this.height=_.height,this.descent=_.descent,this.ascent=_.ascent,this.fullSize={leftOffset:this.location.x-k.left,width:k.width,ascent:k.ascent,descent:k.descent,height:k.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Ch(t){return(Ch="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function jh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Rh(t,e){return(Rh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Bh(t){return(Bh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Fh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Rh(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Bh(e);return function(t,e){if(e&&("object"===Ch(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Bh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n,r=t._dup(),i=(s=this.options).scaleModifier,o=s.fullContentBounds,a=(a=1,(function(t){if(Array.isArray(t))return t}(n=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(n,a)||function(t,e){if(t){if("string"==typeof t)return jh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jh(t,e):void 0}}(n,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),s=(t=new ku,new ku);null!=a&&(a.calcSize(r._dup(),e*i),t.copyFrom(a.getBounds(o)),s.copyFrom(a.getBounds(!0))),this.width=t.width,this.height=t.height,this.descent=t.descent,this.ascent=t.ascent,this.fullSize={leftOffset:this.location.x-s.left,width:s.width,ascent:s.ascent,descent:s.descent,height:s.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Ih(t){return(Ih="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Dh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Lh(t,e){return(Lh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function zh(t){return(zh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Wh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Lh(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=zh(e);return function(t,e){if(e&&("object"===Ih(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=zh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),r=(p=this.options).width,i=p.descent,o=p.ascent,a=p.xAlign,s=p.yAlign,l=p.fit,u=p.scaleModifier,c=p.inSize,h=p.fullContentBounds,f=(d=1,(function(t){if(Array.isArray(t))return t}(f=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(f,d)||function(t,e){if(t){if("string"==typeof t)return Dh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dh(t,e):void 0}}(f,d)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),d=new ku,p=(t=new ku,new ku);null!=f&&(f.calcSize(n._dup(),e*u),d.copyFrom(f.getBounds(h)),t.copyFrom(d)),null!=r&&(t.width=r,t.right=t.left+r),null!=i&&(t.descent=i),null!=o&&(t.ascent=o),t.height=t.descent+t.ascent,null!=f&&("width"===l?f.calcSize(n._dup(),t.width/d.width):"height"===l?f.calcSize(n._dup(),t.height/d.height):"contain"===l&&(m=Math.min(t.width/d.width,t.height/d.height),f.calcSize(n._dup(),m)),d.copyFrom(f));var m=n._dup();"center"===a?m.x=n.x+t.width/2-d.width/2:"right"===a?m.x=n.x+t.width-d.width:"number"==typeof a&&(m.x=n.x+t.width*a),"bottom"===s?m.y=n.y-t.descent+d.descent:"middle"===s?m.y=n.y-t.descent+t.height/2-d.height/2+d.descent:"top"===s?m.y=n.y+t.ascent-d.height+d.descent:"number"==typeof s&&(m.y=n.y-t.descent+t.height*s+d.descent),null!=f&&f.offsetLocation(m.sub(f.location)),null!=f?(p.copyFrom(f.getBounds(!0)),p.growWithSameBaseline(t)):p.copyFrom(t),c?(this.width=t.width,this.height=t.height,this.descent=t.descent,this.ascent=t.ascent):(this.width=0,this.height=0,this.descent=0,this.ascent=0),this.fullSize={leftOffset:this.location.x-p.left,width:p.width,ascent:p.ascent,descent:p.descent,height:p.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Nh(t){return(Nh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Hh(t,e){return(Hh=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Uh(t){return(Uh=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Kh=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Hh(t,e)}(i,ph);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Uh(e);return function(t,e){if(e&&("object"===Nh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Uh(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(){return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),r.apply(this,arguments)}return t=[{key:"calcSize",value:function(t,e){this.location=t._dup();var n=t._dup(),r=(s=this.options).offset,i=s.fullContentBounds,o=(a=1,(function(t){if(Array.isArray(t))return t}(o=this.contents)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(o,a)||function(t,e){if(t){if("string"==typeof t)return qh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qh(t,e):void 0}}(o,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]),a=new ku,s=new ku;null!=o&&(o.calcSize(n._dup(),e),a.copyFrom(o.getBounds(i))),null!=o&&(o.offsetLocation(r),s.copyFrom(o.getBounds(!0))),this.width=0,this.height=0,this.descent=0,this.ascent=0,this.fullSize={leftOffset:t.x-s.left,width:s.width,ascent:s.ascent,descent:s.descent,height:s.height}}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Vh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Yh(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gh(t){return function(t){if(Array.isArray(t))return Xh(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||Yh(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yh(t,e){if(t){if("string"==typeof t)return Xh(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xh(t,e):void 0}}function Xh(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function $h(t,e){return"string"!=typeof e?e:t instanceof Rl?t&&"_".concat(e)in t?t["_".concat(e)]:null:t&&e in t?t[e]:null}var Jh=function(){function t(e,n,r){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.elements=e,this.phrases={},this.fullLineHeight=null,this.addElementFromKey=n,this.getExistingOrAddSymbol=r,this.phraseElements={}}var e=[{key:"stringToElement",value:function(t){if(0===t.length)return null;if(t.startsWith("space")){var e=parseFloat(t.replace(/space[_]*/,""))||.03;return new ju(new Cu(e))}if(t.startsWith(" ")){var n=.03*t.length;return new ju(new Cu(n))}return(n=$h(this.elements,t))?new ju(n):t in this.phrases?this.parseContent(this.phrases[t]):null!=(t=this.addElementFromKey(t,{}))?new ju(t):null}},{key:"parseContent",value:function(t){var e,n=this;if(null==t)return null;if("number"==typeof t)return null;if(t instanceof Ru)return t;if(t instanceof Yu)return t;if("string"==typeof t)return null==(o=this.stringToElement(t))||null!=this.phraseElements[t]||(null!=o.getAllElements?this.phraseElements[t]=o.getAllElements():(e=[],o.forEach((function(t){null!=t.getAllElements?e.push.apply(e,Gh(t.getAllElements())):e.push(t)})),this.phraseElements[t]=e)),o;if(Array.isArray(t)){var r=[];return t.forEach((function(t){t=n.parseContent(t),Array.isArray(t)?r=[].concat(Gh(r),Gh(t)):r.push(t)})),r}var i=Vh(Object.entries(t)[0],2),o=i[0];return t=i[1],null!=(i=this.eqnMethod(o,t))?i:(t=this.addElementFromKey(o,t),new ju(t))}},{key:"contentToElement",value:function(t){return t instanceof Ru?t._dup():t instanceof Rl||t instanceof jl?new Ru([new ju(t)]):(t=this.parseContent(t),Array.isArray(t)||(t=[t]),new Ru(t))}},{key:"eqnMethod",value:function(t,e){return"frac"===t?this.frac(e):"strike"===t?this.strike(e):"box"===t?this.box(e):"tBox"===t?this.touchBox(e):"root"===t?this.root(e):"brac"===t?this.brac(e):"sub"===t?this.sub(e):"sup"===t?this.sup(e):"supSub"===t?this.supSub(e):"topBar"===t?this.topBar(e):"bottomBar"===t?this.bottomBar(e):"annotate"===t?this.annotate(e):"bottomComment"===t?this.bottomComment(e):"topComment"===t?this.topComment(e):"bar"===t?this.bar(e):"topStrike"===t?this.topStrike(e):"bottomStrike"===t?this.bottomStrike(e):"pad"===t?this.pad(e):"int"===t?this.int(e):"sumOf"===t||"prodOf"===t?this.sumProd(e):"matrix"===t?this.matrix(e):"lines"===t?this.lines(e):"scale"===t?this.scale(e):"container"===t?this.container(e):"offset"===t?this.offset(e):null}},{key:"container",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h,f=Array.isArray(t)?(n=(e=Vh(t,11))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],e[10]):(n=t.content,r=t.width,i=t.inSize,o=t.descent,a=t.ascent,s=t.xAlign,l=t.yAlign,u=t.fit,c=t.scale,h=t.fullContentBounds,t.showContent),d=ft({scaleModifier:1,fit:null,width:null,ascent:null,descent:null,xAlign:"center",yAlign:"baseline",inSize:!0,fullContentBounds:!1,showContent:!0},{scaleModifier:c,fit:u,width:r,ascent:a,descent:o,xAlign:s,yAlign:l,inSize:i,fullContentBounds:h});return new Wh([this.contentToElement(n)],[],d,null==f||f)}catch(t){throw new Error("FigureOne Equation Container Error: ".concat(t.message))}}},{key:"offset",value:function(t){try{var e,n,r,i=Array.isArray(t)?(r=(n=Vh(t,3))[0],e=n[1],n[2]):(r=t.content,e=t.offset,t.fullContentBounds),o=ft({offset:[0,0],fullContentBounds:!1},{offset:Ae(e||[0,0]),fullContentBounds:i});return new Kh([this.contentToElement(r)],[],o)}catch(t){throw new Error("FigureOne Equation Offset Error: ".concat(t.message))}}},{key:"brac",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m=Array.isArray(t)?(n=(e=Vh(t,14))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],f=e[10],d=e[11],p=e[12],e[13]):(n=t.left,r=t.content,i=t.right,o=t.inSize,a=t.insideSpace,s=t.outsideSpace,l=t.topSpace,u=t.bottomSpace,c=t.minContentHeight,h=t.minContentDescent,f=t.height,d=t.descent,p=t.fullContentBounds,t.useFullBounds),y=ft({},{insideSpace:.03,outsideSpace:.03,topSpace:.05,bottomSpace:.05,minContentHeight:null,minContentDescent:null,descent:null,height:null,inSize:!0,useFullBounds:!1,fullContentBounds:!1},{insideSpace:a,outsideSpace:s,topSpace:l,bottomSpace:u,minContentHeight:c,minContentDescent:h,descent:d,height:f,inSize:o,useFullBounds:m,fullContentBounds:p}),v={};return n&&(v.left={symbol:n,space:y.insideSpace,topSpace:y.topSpace,bottomSpace:y.bottomSpace,minContentHeight:y.minContentHeight,minContentDescent:y.minContentDescent,descent:y.descent,height:y.height}),i&&(v.right={symbol:i,space:y.insideSpace,topSpace:y.topSpace,bottomSpace:y.bottomSpace,minContentHeight:y.minContentHeight,minContentDescent:y.minContentDescent,descent:y.descent,height:y.height}),this.annotate({content:r,glyphs:v,inSize:y.inSize,leftSpace:y.outsideSpace,rightSpace:y.outsideSpace,useFullBounds:y.useFullBounds,fullContentBounds:y.fullContentBounds})}catch(t){throw new Error("FigureOne Equation Brackert Error: ".concat(t.message))}}},{key:"bar",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};try{var n,r,i,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b=Array.isArray(t)?(r=(n=Vh(t,17))[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],f=n[9],d=n[10],p=n[11],m=n[12],y=n[13],v=n[14],g=n[15],n[16]):(r=t.content,i=t.symbol,o=t.inSize,a=t.space,s=t.overhang,l=t.length,u=t.left,c=t.right,h=t.top,f=t.bottom,d=t.side,p=t.minContentHeight,m=t.minContentDescent,y=t.minContentAscent,v=t.descent,g=t.fullContentBounds,t.useFullBounds),w=ft({},{inSize:!0,space:.03,overhang:0,length:null,left:null,right:null,top:null,bottom:null,side:"top",minContentHeight:null,minContentDescent:null,minContentAscent:null,descent:null,fullContentBounds:!1,useFullBounds:!1},{side:d,space:a,overhang:s,length:l,left:u,right:c,top:h,bottom:f,inSize:o,minContentHeight:p,minContentDescent:m,minContentAscent:y,descent:v,fullContentBounds:g,useFullBounds:b},e),x={};return"top"===w.side&&(x.top={symbol:i,space:w.space,overhang:w.overhang,leftSpace:w.left,rightSpace:w.right,width:w.length}),"bottom"===w.side&&(x.bottom={symbol:i,space:w.space,overhang:w.overhang,leftSpace:w.left,rightSpace:w.right,width:w.length}),"left"===w.side&&(x.left={symbol:i,space:w.space,overhang:w.overhang,topSpace:w.top,bottomSpace:w.bottom,height:w.length,minContentHeight:w.minContentHeight,minContentDescent:w.minContentDescent,minContentAscent:w.minContentAscent,descent:w.descent}),"right"===w.side&&(x.right={symbol:i,space:w.space,overhang:w.overhang,topSpace:w.top,bottomSpace:w.bottom,height:w.length,minContentHeight:w.minContentHeight,minContentDescent:w.minContentDescent,minContentAscent:w.minContentAscent,descent:w.descent}),this.annotate({content:r,glyphs:x,inSize:w.inSize,fullContentBounds:w.fullContentBounds,useFullBounds:w.useFullBounds})}catch(t){throw new Error("FigureOne Equation Bar Error: ".concat(t.message))}}},{key:"annotate",value:function(t){var e=this,n={inSize:!0,useFullBounds:!1,fullContentBounds:!1,space:0,contentScale:1,encompass:{space:0},left:{space:0,overhang:0,yOffset:0,annotationsOverContent:!1},right:{space:0,overhang:0,yOffset:0,annotationsOverContent:!1},top:{space:0,overhang:0,xOffset:0,annotationsOverContent:!1},bottom:{space:0,overhang:0,xOffset:0,annotationsOverContent:!1},line:{content:{xAlign:"left",yAlign:"bottom",space:0},annotation:{xAlign:"left",yAlign:"bottom",space:0},annotationIndex:0}},r=t.content,i=t.annotation,o=t.annotations,a=t.glyphs,s={xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:new Oe(0,0),scale:1,inSize:!0,fullContentBounds:!1},l=[];null!=i?l.push(i):null!=o&&(l=o);var u=function(t){if(null==t||!Array.isArray(t))return[];var n=[];return t.forEach((function(t){n.push(function(t){var n=ft({},s,t);return n.offset=Ae(n.offset),n.content=e.contentToElement(t.content),n}(t))})),n},c=(o=u(l),{});return(l=function(t){if(null!=a){var r=a[t];if(null!=r){c[t]={};var i=r.annotations;if(null!=r.annotation&&(i=[r.annotation]),i=u(i),c[t]=ft({},n[t],r),c[t].annotations=i,c[t].glyph=e.getExistingOrAddSymbol(r.symbol||""),null==c[t].glyph)throw new Error("Equation glyph identifier '".concat(JSON.stringify(r.symbol||""),"' is not a glyph, or does not exist"))}}})("encompass"),l("left"),l("right"),l("top"),l("bottom"),l("line"),t=ft(n,t),new Yu(this.contentToElement(r),o,c,t)}},{key:"scale",value:function(t){try{var e,n,r,i=Array.isArray(t)?(r=(n=Vh(t,3))[0],e=n[1],n[2]):(r=t.content,e=t.scale,t.fullContentBounds),o=ft({scaleModifier:1,fullContentBounds:!1},{scaleModifier:e,fullContentBounds:i});return new Fh([this.contentToElement(r)],[],o)}catch(t){throw new Error("FigureOne Equation Scale Error: ".concat(t.message))}}},{key:"frac",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h=Array.isArray(t)?(n=(e=Vh(t,10))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.numerator,r=t.symbol,i=t.denominator,o=t.scale,a=t.numeratorSpace,s=t.denominatorSpace,l=t.overhang,u=t.offsetY,c=t.baseline,t.fullContentBounds),f=ft({scaleModifier:1,numeratorSpace:.05,denominatorSpace:.05,offsetY:.07,overhang:.05,fullContentBounds:!1,baseline:"vinculum"},{scaleModifier:o,overhang:l,numeratorSpace:a,denominatorSpace:s,offsetY:u,fullContentBounds:h,baseline:c});return new wh([this.contentToElement(n),this.contentToElement(i)],this.getExistingOrAddSymbol(r),f)}catch(t){throw new Error("FigureOne Equation Fraction Error: ".concat(t.message))}}},{key:"root",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h,f,d=!0,p=Array.isArray(t)?(a=(o=Vh(t,13))[0],s=o[1],d=o[2],l=o[3],u=o[4],c=o[5],h=o[6],f=o[7],e=o[8],r=o[9],n=o[10],i=o[11],o[12]):(a=t.symbol,s=t.content,d=t.inSize,l=t.space,u=t.topSpace,c=t.rightSpace,h=t.bottomSpace,f=t.leftSpace,e=t.root,r=t.rootOffset,n=t.rootScale,i=t.fullContentBounds,t.useFullBounds),m=ft({space:.02,rootScale:.6,rootOffset:[0,.06],inSize:!0,fullContentBounds:!1,useFullBounds:!1},{leftSpace:f,topSpace:u,bottomSpace:h,rightSpace:c,space:l,rootScale:n,rootOffset:r,inSize:d,fullContentBounds:i,useFullBounds:p});m.rootOffset=Ae(m.rootOffset);var y=[];return null!=e&&y.push({content:e,offset:m.rootOffset,scale:m.rootScale,reference:"root"}),this.annotate({content:s,inSize:m.inSize,useFullBounds:m.useFullBounds,fullContentBounds:m.fullContentBounds,glyphs:{encompass:{symbol:a,annotations:y,space:m.space,leftSpace:m.leftSpace,rightSpace:m.rightSpace,topSpace:m.topSpace,bottomSpace:m.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation Root Error: ".concat(t.message))}}},{key:"supSub",value:function(t){var e,n,r=null,i=null,o=null,a=null,s=null;return t=Array.isArray(t)?(n=(e=Vh(t,7))[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],e[6]):(n=t.content,r=t.superscript,i=t.subscript,o=t.scale,s=t.superscriptOffset,a=t.subscriptOffset,t.inSize),s=ft({scale:.5,subscriptOffset:[0,0],superscriptOffset:[0,0],inSize:!0},{superscript:r,subscript:i,scale:o,subscriptOffset:a,superscriptOffset:s,inSize:t}),t=[],null!=r&&t.push({content:s.superscript,xPosition:"right",yPosition:"0.7a",xAlign:"left",yAlign:"baseline",offset:Ae(s.superscriptOffset).add(new Oe(.04*s.scale,0)),scale:s.scale}),null!=i&&t.push({content:s.subscript,xPosition:"right",yPosition:"baseline",xAlign:"left",yAlign:"0.7a",offset:s.subscriptOffset,scale:s.scale}),this.annotate({content:n,annotations:t,inSize:s.inSize})}},{key:"sup",value:function(t){try{var e,n,r,i,o,a=Array.isArray(t)?(n=(e=Vh(t,5))[0],r=e[1],i=e[2],o=e[3],e[4]):(n=t.content,r=t.superscript,i=t.scale,o=t.offset,t.inSize);return this.supSub({content:n,superscript:r,superscriptOffset:o,inSize:a,scale:i})}catch(t){throw new Error("FigureOne Equation Superscript Error: ".concat(t.message))}}},{key:"sub",value:function(t){try{var e,n,r,i,o,a=Array.isArray(t)?(n=(e=Vh(t,5))[0],r=e[1],i=e[2],o=e[3],e[4]):(n=t.content,r=t.subscript,i=t.scale,o=t.offset,t.inSize);return this.supSub({content:n,subscript:r,subscriptOffset:o,inSize:a,scale:i})}catch(t){throw new Error("FigureOne Equation Subscript Error: ".concat(t.message))}}},{key:"touchBox",value:function(t){try{var e,n,r,i,o,a,s,l=Array.isArray(t)?(n=(e=Vh(t,7))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],e[6]):(n=t.content,r=t.symbol,i=t.space,o=t.topSpace,a=t.rightSpace,s=t.bottomSpace,t.leftSpace),u=ft({inSize:!1,space:0,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null},{content:n,symbol:r,space:i,topSpace:o,rightSpace:a,bottomSpace:s,leftSpace:l});return this.annotate({content:n,inSize:!1,fullContentBounds:!1,useFullBounds:!1,glyphs:{encompass:{symbol:r,space:u.space,leftSpace:u.leftSpace,rightSpace:u.rightSpace,topSpace:u.topSpace,bottomSpace:u.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation TouchBox Error: ".concat(t.message))}}},{key:"box",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h=Array.isArray(t)?(n=(e=Vh(t,10))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.content,r=t.symbol,i=t.inSize,o=t.space,a=t.topSpace,s=t.rightSpace,l=t.bottomSpace,u=t.leftSpace,c=t.fullContentBounds,t.useFullBounds),f=ft({inSize:!1,space:0,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null,fullContentBounds:!1,useFullBounds:!1},{content:n,symbol:r,inSize:i,space:o,topSpace:a,rightSpace:s,bottomSpace:l,leftSpace:u,fullContentBounds:c,useFullBounds:h});return this.annotate({content:n,inSize:f.inSize,fullContentBounds:f.fullContentBounds,useFullBounds:f.useFullBounds,glyphs:{encompass:{symbol:r,space:f.space,leftSpace:f.leftSpace,rightSpace:f.rightSpace,topSpace:f.topSpace,bottomSpace:f.bottomSpace}}})}catch(t){throw new Error("FigureOne Equation Box Error: ".concat(t.message))}}},{key:"pad",value:function(t){try{var e,n,r,i,o,a=Array.isArray(t)?(n=(e=Vh(t,5))[0],r=e[1],i=e[2],o=e[3],e[4]):(n=t.content,r=t.top,i=t.right,o=t.bottom,t.left),s=ft({top:0,left:0,right:0,bottom:0},{top:r,right:i,bottom:o,left:a});return this.annotate({content:n,topSpace:s.top,bottomSpace:s.bottom,rightSpace:s.right,leftSpace:s.left})}catch(t){throw new Error("FigureOne Equation Pad Error: ".concat(t.message))}}},{key:"topBar",value:function(t){try{return this.bar(t,{side:"top"})}catch(t){throw new Error("FigureOne Equation TopBar Error: ".concat(t.message))}}},{key:"bottomBar",value:function(t){try{return this.bar(t,{side:"bottom"})}catch(t){throw new Error("FigureOne Equation BottomBar Error: ".concat(t.message))}}},{key:"matrix",value:function(t){var e=this;try{var n,r,i,o,a,s,l,u,c,h,f=Array.isArray(t)?(r=(n=Vh(t,10))[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],n[9]):(r=t.order,i=t.left,o=t.content,a=t.right,s=t.scale,l=t.fit,u=t.space,c=t.yAlign,h=t.brac,t.fullContentBounds),d=ft({},{contentScale:.7,fit:"min",space:[.05,.05],yAlign:"baseline",brac:{},fullContentBounds:!1},{space:u,fit:l,order:r,contentScale:s,brac:h,yAlign:c,fullContentBounds:f}),p=[];null!=o&&(p=o.map((function(t){return e.contentToElement(t)}))),null!=d.order&&d.order[0]*d.order[1]===p.length||(d.order=[1,p.length]),null!=d.space&&(d.space=Ae(d.space));var m=new _h(p,[],d);return null!=i&&null!=a?this.brac(ft({},d.brac,{content:m,left:i,right:a})):m}catch(t){throw new Error("FigureOne Equation Bar Error: ".concat(t.message))}}},{key:"lines",value:function(t){var e=this;try{var n,r,i,o,a,s,l=Array.isArray(t)?(r=(n=Vh(t,6))[0],i=n[1],o=n[2],a=n[3],s=n[4],n[5]):(r=t.content,i=t.justify,o=t.baselineSpace,a=t.space,s=t.yAlign,t.fullContentBounds),u=ft({},{justify:"center",yAlign:0,baselineSpace:null,space:0,fullContentBounds:!1},{justify:i,baselineSpace:o,space:a,yAlign:s,fullContentBounds:l}),c=[],h=[];return null!=r&&(r.forEach((function(t){var n=u.baselineSpace,r=u.space,i=null;Array.isArray(t)||null==t.content?c.push(e.contentToElement(t)):(c.push(e.contentToElement(t.content)),null!=t.baselineSpace&&(n=t.baselineSpace),null!=t.space&&(r=t.space),null!=t.justify&&(i=e.elements[t.justify])),h.push({baselineSpace:n,space:r,justify:i,offset:t.offset||0})})),u.lineOptions=h),new Mh(c,[],u)}catch(t){throw new Error("FigureOne Equation Lines Error: ".concat(t.message))}}},{key:"int",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y,v,g,b,w,x,S,T,A,k,_,O,P={inSize:!0,space:.01,topSpace:.1,bottomSpace:.1,height:null,yOffset:0,contentScale:1,fromScale:.5,toScale:.5,fromOffset:[0,0],toOffset:[.04,0],limitsPosition:"side",limitsAroundContent:!0,fromXPosition:.5,fromYPosition:"bottom",fromXAlign:"left",fromYAlign:"middle",toXPosition:"right",toYPosition:"top",toXAlign:"left",toYAlign:"middle",fullBoundsContent:!1,useFullBounds:!1},E=Array.isArray(t)?(n=(e=Vh(t,27))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],f=e[10],d=e[11],p=e[12],m=e[13],y=e[14],v=e[15],g=e[16],b=e[17],w=e[18],x=e[19],S=e[20],T=e[21],A=e[22],k=e[23],_=e[24],O=e[25],e[26]):(r=t.content,n=t.symbol,i=t.from,o=t.to,a=t.inSize,s=t.space,l=t.topSpace,u=t.bottomSpace,c=t.height,h=t.yOffset,f=t.scale,d=t.fromScale,p=t.toScale,m=t.fromOffset,y=t.toOffset,v=t.limitsPosition,g=t.limitsAroundContent,b=t.fromXPosition,w=t.fromYPosition,x=t.fromXAlign,S=t.fromYAlign,T=t.toXPosition,A=t.toYPosition,k=t.toXAlign,_=t.toYAlign,O=t.fullBoundsContent,t.useFullBounds);"topBottom"===v&&(P.fromXPosition=.1,P.fromYPosition="bottom",P.fromXAlign="center",P.fromYAlign="top",P.toXPosition=.9,P.toYPosition="top",P.toXAlign="center",P.toYAlign="bottom",P.fromOffset=[0,-.04],P.toOffset=[0,.04]),"topBottomCenter"===v&&(P.fromXPosition="center",P.fromYPosition="bottom",P.fromXAlign="center",P.fromYAlign="top",P.toXPosition="center",P.toYPosition="top",P.toXAlign="center",P.toYAlign="bottom",P.fromOffset=[0,-.04],P.toOffset=[0,.04]);var M=ft({},P,{space:s,topSpace:l,bottomSpace:u,height:c,yOffset:h,inSize:a,contentScale:f,fromScale:d,toScale:p,fromOffset:m,toOffset:y,limitsPosition:v,limitsAroundContent:g,fromXPosition:b,fromYPosition:w,fromXAlign:x,fromYAlign:S,toXPosition:T,toYPosition:A,toXAlign:k,toYAlign:_,fullBoundsContent:O,useFullBounds:E});M.fromOffset=Ae(M.fromOffset),M.toOffset=Ae(M.toOffset);var C=[{content:o,xPosition:M.toXPosition,yPosition:M.toYPosition,xAlign:M.toXAlign,yAlign:M.toYAlign,offset:M.toOffset,scale:M.toScale},{content:i,xPosition:M.fromXPosition,yPosition:M.fromYPosition,xAlign:M.fromXAlign,yAlign:M.fromYAlign,offset:M.fromOffset,scale:M.fromScale}];return this.annotate({content:r,inSize:M.inSize,contentScale:M.contentScale,fullBoundsContent:M.fullBoundsContent,useFullBounds:M.useFullBounds,glyphs:{left:{symbol:n,space:M.space,topSpace:M.topSpace,bottomSpace:M.bottomSpace,height:M.height,yOffset:M.yOffset,annotationsOverContent:M.limitsAroundContent,annotations:C}}})}catch(t){throw new Error("FigureOne Equation Integral Error: ".concat(t.message))}}},{key:"sumOf",value:function(t){try{return this.sumProd(t)}catch(t){throw new Error("FigureOne Equation SumOf Error: ".concat(t.message))}}},{key:"prodOf",value:function(t){try{return this.sumProd(t)}catch(t){throw new Error("FigureOne Equation ProductOf Error: ".concat(t.message))}}},{key:"sumProd",value:function(t){var e,n,r,i,o,a,s,l,u,c,h,f,d,p,m,y,v,g;t=Array.isArray(t)?(n=(e=Vh(t,19))[0],r=e[1],b=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],f=e[11],d=e[12],p=e[13],m=e[14],y=e[15],v=e[16],g=e[17],e[18]):(n=t.symbol,r=t.content,b=t.from,i=t.to,o=t.inSize,a=t.space,s=t.topSpace,l=t.bottomSpace,u=t.height,c=t.yOffset,h=t.scale,f=t.fromScale,d=t.toScale,p=t.fromSpace,m=t.toSpace,y=t.fromOffset,v=t.toOffset,g=t.fullBoundsContent,t.useFullBounds);var b=[{content:i,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:Ae((t=ft({},{inSize:!0,space:.1,topSpace:.07,bottomSpace:.07,height:null,yOffset:0,contentScale:1,fromScale:.5,toScale:.5,fromSpace:.04,toSpace:.04,fromOffset:[0,0],toOffset:[0,0],fullBoundsContent:!1,useFullBounds:!1},{space:a,topSpace:s,bottomSpace:l,height:u,yOffset:c,inSize:o,contentScale:h,fromScale:f,toScale:d,fromSpace:p,toSpace:m,fromOffset:y,toOffset:v,fullBoundsContent:g,useFullBounds:t})).toOffset).add(0,t.toSpace),scale:t.toScale},{content:b,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",offset:Ae(t.fromOffset).add(0,-t.fromSpace),scale:t.fromScale}];return this.annotate({content:r,contentScale:t.contentScale,fullBoundsContent:t.fullBoundsContent,useFullBounds:t.useFullBounds,glyphs:{left:{symbol:n,annotations:b,space:t.space,topSpace:t.topSpace,bottomSpace:t.bottomSpace,yOffset:t.yOffset,height:t.height}},inSize:t.inSize})}},{key:"processComment",value:function(t){var e,n,r,i,o,a,s,l,u,c;t=Array.isArray(t)?(n=(e=Vh(t,11))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],h=e[8],c=e[9],e[10]):(n=t.content,r=t.comment,i=t.symbol,o=t.contentSpace,a=t.commentSpace,s=t.scale,l=t.inSize,u=t.contentLineSpace,h=t.commentLineSpace,c=t.fullContentBounds,t.useFullBounds);var h=ft({contentSpace:.03,commentSpace:.03,scale:.6,inSize:!0,fullContentBounds:!1,useFullBounds:!1,contentLineSpace:.03,commentLineSpace:.03},{contentSpace:o,commentSpace:a,scale:s,inSize:l,useFullBounds:t,fullContentBounds:c,contentLineSpace:u,commentLineSpace:h});return[n,r,i,h.contentSpace,h.commentSpace,h.scale,h.inSize,h.contentLineSpace,h.commentLineSpace,h.fullContentBounds,h.useFullBounds]}},{key:"topComment",value:function(){try{var t=Vh(this.processComment.apply(this,arguments),11),e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],f=[{content:n,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",scale:a,offset:[0,o]}];return""===r||null==r?this.annotate({content:e,annotations:f,inSize:s}):this.getExistingOrAddSymbol(r)instanceof sh?(f[0].offset=[0,o+i],this.annotate({content:e,fullContentBounds:c,useFullBounds:h,annotations:f,glyphs:{line:{symbol:r,content:{xAlign:"center",yAlign:"top",space:l},annotation:{xAlign:"center",yAlign:"bottom",space:u},annotationIndex:0}},inSize:s})):this.annotate({content:e,fullContentBounds:c,useFullBounds:h,glyphs:{top:{symbol:r,annotations:f,space:i}},inSize:s})}catch(t){throw new Error("FigureOne Equation TopComment Error: ".concat(t.message))}}},{key:"bottomComment",value:function(){try{var t=Vh(this.processComment.apply(this,arguments),11),e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],f=[{content:n,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",scale:a,offset:[0,-o]}];return""===r||null==r?this.annotate({content:e,annotations:f,inSize:s}):this.getExistingOrAddSymbol(r)instanceof sh?(f[0].offset=[0,-o-i],this.annotate({content:e,fullContentBounds:c,useFullBounds:h,annotations:f,glyphs:{line:{symbol:r,content:{xAlign:"center",yAlign:"bottom",space:l},annotation:{xAlign:"center",yAlign:"top",space:u},annotationIndex:0}},inSize:s})):this.annotate({content:e,fullContentBounds:c,useFullBounds:h,glyphs:{bottom:{symbol:r,annotations:f,space:i}},inSize:s})}catch(t){throw new Error("FigureOne Equation BottomComment Error: ".concat(t.message))}}},{key:"strike",value:function(t){try{var e,n,r,i,o,a,s,l,u,c,h={inSize:!1,space:.02,topSpace:null,bottomSpace:null,leftSpace:null,rightSpace:null,fullContentBounds:!1,useFullBounds:!1},f=Array.isArray(t)?(n=(e=Vh(t,10))[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],e[9]):(n=t.content,r=t.symbol,i=t.inSize,o=t.space,a=t.topSpace,s=t.rightSpace,l=t.bottomSpace,u=t.leftSpace,c=t.fullContentBounds,t.useFullBounds),d=this.getExistingOrAddSymbol(r);null!=d&&"horizontal"===d._custom.options.style&&(h.space=0,h.leftSpace=.02,h.rightSpace=.02);var p=ft(h,{content:n,symbol:r,inSize:i,space:o,topSpace:a,rightSpace:s,bottomSpace:l,leftSpace:u,fullContentBounds:c,useFullBounds:f});return this.annotate({content:n,inSize:p.inSize,fullContentBounds:p.fullContentBounds,useFullBounds:p.useFullBounds,glyphs:{encompass:{symbol:r,topSpace:p.topSpace,bottomSpace:p.bottomSpace,leftSpace:p.leftSpace,rightSpace:p.rightSpace,space:p.space}}})}catch(t){throw new Error("FigureOne Equation Strike Error: ".concat(t.message))}}},{key:"processStrike",value:function(t){var e,n,r,i,o,a;t=Array.isArray(t)?(n=(e=Vh(t,7))[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],e[6]):(n=t.content,i=t.comment,r=t.symbol,o=t.inSize,s=t.space,a=t.scale,t.commentSpace);var s=ft({space:0,scale:.5,commentSpace:.1,inSize:!0},{inSize:o,commentSpace:t,scale:a,space:s});return[n,r,i,s.inSize,s.commentSpace,s.scale,s.space]}},{key:"topStrike",value:function(){try{var t=Vh(this.processStrike.apply(this,arguments),7),e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=[{content:r,xPosition:"center",yPosition:"top",xAlign:"center",yAlign:"bottom",offset:[0,o],scale:a}];return this.annotate({content:e,inSize:i,glyphs:{encompass:{symbol:n,space:s,annotations:l}}})}catch(t){throw new Error("FigureOne Equation TopStrike Error: ".concat(t.message))}}},{key:"bottomStrike",value:function(){try{var t=Vh(this.processStrike.apply(this,arguments),7),e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=[{content:r,xPosition:"center",yPosition:"bottom",xAlign:"center",yAlign:"top",offset:[0,-o],scale:a}];return this.annotate({content:e,inSize:i,glyphs:{encompass:{symbol:n,space:s,annotations:l}}})}catch(t){throw new Error("FigureOne Equation BottomStrike Error: ".concat(t.message))}}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Zh(t){return(Zh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Qh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||ef(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tf(t){return function(t){if(Array.isArray(t))return nf(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||ef(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ef(t,e){if(t){if("string"==typeof t)return nf(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nf(t,e):void 0}}function nf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function rf(t,e,n){return(rf="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=sf(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function of(t,e){return(of=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function af(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function sf(t){return(sf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var lf=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&of(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=sf(e);return function(t,e){if(e&&("object"===Zh(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return af(t)}(this,n?(t=sf(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var o={family:"Times New Roman",style:"normal",size:.2,weight:"200",color:a=null==(a=n.color)?t.defaultColor:a},a=ht({except:["font"]},{},{color:a,dimColor:a=null==(a=n.dimColor)?t.defaultDimColor.slice():a,position:new Oe(0,0),scale:.7,formDefaults:{alignment:{fixTo:new Oe(0,0),xAlign:"left",yAlign:"baseline"},elementMods:{},layout:"always"},elements:{},forms:{},formRestart:null,touchBorder:"rect",transform:(new Qe).scale(1,1).rotate(0).translate(0,0),timeKeeper:t.timeKeeper},n);return n.font instanceof il?a.font=n.font:null!=n.font?a.font=new il(ft({},o,n.font)):a.font=new il(o),n.textFont instanceof il?a.textFont=n.textFont:null!=n.textFont?a.textFont=new il(ft({},o,{style:"italic"},n.textFont)):a.textFont=new il(ft({},o,{style:"italic"})),null!=a.transform&&(a.transform=rn(a.transform)),Te(a.formDefaults.alignment.fixTo)&&(a.formDefaults.alignment.fixTo=Ae(a.formDefaults.alignment.fixTo)),null!=a.formRestart&&null!=a.formRestart.pulse&&(a.formRestart.pulse=ft({},{scale:1.1,duration:1},a.formRestart.pulse)),(e=r.call(this,a)).shapes=t,e.setColor(a.color),e.dimColor=a.dimColor,e.eqn={forms:{},currentForm:"",formSeries:{base:[]},currentFormSeries:[],currentFormSeriesName:"",scale:a.scale,formDefaults:{alignment:a.formDefaults.alignment,elementMods:a.formDefaults.elementMods,duration:a.formDefaults.duration,translation:a.formDefaults.translation,layout:a.formDefaults.layout},functions:new Jh(e.elements,e.addElementFromKey.bind(af(e)),e.getExistingOrAddSymbol.bind(af(e))),symbols:new lh(e.shapes,e.color),font:a.font,textFont:a.textFont,isAnimating:!1,descriptionElement:null,descriptionPosition:new Oe(0,0),formRestart:a.formRestart},null!=a.elements&&e.addElements(a.elements),null!=a.phrases&&e.addPhrases(a.phrases),null!=a.forms&&e.addForms(a.forms),null!=a.initialForm&&(e.initialForm=a.initialForm),null!=a.formSeries?Array.isArray(a.formSeries)?(e.eqn.formSeries={base:a.formSeries},e.eqn.currentFormSeries=e.eqn.formSeries.base,e.eqn.currentFormSeriesName="base"):(e.eqn.formSeries=a.formSeries,null!=a.defaultFormSeries?e.setFormSeries(a.defaultFormSeries):e.setFormSeries(Object.keys(e.eqn.formSeries)[0])):(e.eqn.formSeries={base:Object.keys(e.eqn.forms).slice()},e.eqn.currentFormSeries=e.eqn.formSeries.base,e.eqn.currentFormSeriesName="base"),e.fnMap.add("_goToForm",(function(t,n){var r=e.getCurrentForm();return null!=r&&null==n.target&&(n.target=r.name),null!=n.start&&e.showForm(n.start),e.goToForm(ft({ifAnimating:{cancelGoTo:!1}},n,{form:n.target,callback:null})),e.getRemainingAnimationTime(["_Equation","_EquationColor"])})),e.fnMap.add("_showForm",(function(t,n){e.showForm(n.target)})),e.animations.goToForm=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},{element:af(e),duration:1}].concat(n));return null!=i.callback&&(i.done=i.callback),i.customProperties={target:i.target,index:i.index,animate:i.animate,delay:i.delay,dissolveOutTime:i.dissolveOutTime,duration:i.duration,blankTime:i.blankTime,dissolveInTime:i.dissolveInTime,prioritizeFormDuration:i.prioritizeFormDuration,fromWhere:i.fromWhere,ifAnimating:i.ifAnimating,callback:i.callback},null!=i.totalDuration&&(i.duration=i.totalDuration),i.callback="_goToForm",i.delay=0,i.setToEnd="_showForm",i.timeKeeper=e.timeKeeper,new ja(i)},e.animations.customSteps.push({step:e.animations.goToForm.bind(af(e)),name:"goToForm"}),e.fnMap.add("_nextForm",(function(t,n){return e.nextForm(ft({ifAnimating:{cancelGoTo:!1}},n,{callback:null})),e.getRemainingAnimationTime(["_Equation","_EquationColor"])})),e.animations.nextForm=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},{element:af(e),duration:1}].concat(n));return null!=i.callback&&(i.done=i.callback),i.customProperties={animate:i.animate,delay:i.delay,dissolveOutTime:i.dissolveOutTime,duration:i.duration,blankTime:i.blankTime,dissolveInTime:i.dissolveInTime,prioritizeFormDuration:i.prioritizeFormDuration,fromWhere:i.fromWhere,ifAnimating:i.ifAnimating,callback:i.callback},null!=i.totalDuration&&(i.duration=i.totalDuration),i.callback="_nextForm",i.delay=0,i.setToEnd="_showForm",i.timeKeeper=e.timeKeeper,new ja(i)},e.animations.customSteps.push({step:e.animations.nextForm.bind(af(e)),name:"nextForm"}),e}return t=[{key:"stateSet",value:function(){var t=this;rf(sf(i.prototype),"stateSet",this).call(this),Object.keys(this.eqn.forms).forEach((function(e){"init"!==t.eqn.forms[e].layout&&(t.eqn.forms[e].positionsSet=!1)}))}},{key:"setFigure",value:function(t){rf(sf(i.prototype),"setFigure",this).call(this,t),null!=this.initialForm&&this.showForm(this.initialForm)}},{key:"_getStateProperties",value:function(t){return[].concat(tf(rf(sf(i.prototype),"_getStateProperties",this).call(this,t)),["eqn.currentForm","eqn.isAnimating","eqn.currentFormSeries","eqn.currentFormSeriesName"])}},{key:"_getStatePropertiesMin",value:function(){return[].concat(tf(rf(sf(i.prototype),"_getStatePropertiesMin",this).call(this)),["eqn.currentForm"])}},{key:"setFormSeries",value:function(t){null!=this.eqn.formSeries[t]&&(this.eqn.currentFormSeries=this.eqn.formSeries[t],this.eqn.currentFormSeriesName=t)}},{key:"getFormSeries",value:function(){return this.eqn.currentFormSeriesName}},{key:"layoutForms",value:function(t){var e,n=this;"none"!==t&&(e=function(t){var e=n.eqn.forms[t],r=(o=e.arranged).scale,i=o.xAlign,o=(t=o.yAlign,o.fixTo);e.arrange(r,i,t,o)},"current"!==t?(Object.keys(this.eqn.forms).forEach((function(t){e(t)})),this.showForm(this.eqn.currentForm)):e(this.eqn.currentForm))}},{key:"updateElementText",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"none";Object.keys(t).forEach((function(n){var r,i=e.getElement(n);null!=i&&(r=i.color.slice(),i.custom.updateText({text:t[n]}),i.setColor(r,!1))})),this.layoutForms(n)}},{key:"makeTextElem",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";null!=t.text&&(e=t.text);var n=this.eqn.textFont.definition(),r=n;return r=null!=t.font&&t.font instanceof il?t.font.definition():ft({},n,{style:t.style,weight:t.weight,family:t.family,size:t.size,color:t.color,width:t.width},t.font),null==t.style&&(null!=t.font&&null==t.font.style||null==t.font)&&(e.match(/[A-Z,a-z,\u0370-\u03ff]/)?r.style=this.eqn.textFont.style:r.style="normal"),null==r.color&&(r.color=this.color),r=this.shapes.text({text:{text:e,touchBorder:0},position:new Oe(0,0),font:r,xAlign:"left",yAlign:"baseline",touchBorder:"buffer",mods:{dimColor:this.dimColor.slice()}}),null!=t.touchBorder&&(r.touchBorder=t.touchBorder),null!=t.isTouchable&&(r.isTouchable=t.isTouchable),null!=t.onClick&&(r.onClick=t.onClick),null!=t.mods&&r.setProperties(t.mods),r}},{key:"getTextFromKey",value:function(t){return t.replace(/^_*/,"").replace(/_.*/,"")}},{key:"getExistingOrAddSymbol",value:function(t){if("string"==typeof t)return this.getExistingOrAddSymbolFromKey(t,{});t=(e=Qh(Object.entries(t)[0],2))[0];var e=e[1];return this.getExistingOrAddSymbolFromKey(t,e)}},{key:"getExistingOrAddSymbolFromKey",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=this.getElement(t);if(null!=n)return n;if(null!=e.symbol&&"string"==typeof e.symbol){var r=this.makeSymbolElem(e);if(null!=r)return this.add(t,r),r}return n=t.replace(/^_*/,""),null!=(r=this.eqn.symbols.get(n,e))?(.01<r.color[3]&&null==e.color&&r.setColor(this.color),null!=e.mods&&r.setProperties(e.mods),this.add(t,r),r):null!=(n=n.match(/_[^_]*$/))&&null!=(r=this.eqn.symbols.get(n[0].replace(/_/,""),e))?(.01<r.color[3]&&null==e.color&&r.setColor(this.color),null!=e.mods&&r.setProperties(e.mods),this.add(t.replace(/_[^_]*$/,""),r),r):null}},{key:"addElementFromKey",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(null!=(r=this.getExistingOrAddSymbolFromKey(t,e)))return r;var n=t.replace(/^_*/,"").replace(/_.*/,""),r=this.makeTextElem(ft({text:n},e));return this.add(t,r),r}},{key:"makeSymbolElem",value:function(t){var e=this.eqn.symbols.get(t.symbol,t);return null==e&&(e=this.makeTextElem({text:"Symbol ".concat(t.symbol," not valid")})),null==t.color&&.01<e.color[3]&&e.setColor(this.color),e.dimColor=this.dimColor.slice(),null!=t.mods&&e.setProperties(t.mods),e}},{key:"addElements",value:function(t){var e=this;Object.keys(t).forEach((function(n){var r,i=t[n];"string"==typeof i?n.startsWith("space")&&n.startsWith(" ")&&0<n.length||e.add(n,e.makeTextElem({text:i})):i instanceof jl||i instanceof Rl?e.add(n,i):null!=(r=null!=i.symbol&&"string"==typeof i.symbol?e.makeSymbolElem(i):e.makeTextElem(i,e.getTextFromKey(n)))&&(null!=i.mods&&r.setProperties(i.mods),e.add(n,r))}));var n=this.makeTextElem({text:"gh"}),r=this.createForm({elem:n});r.content=[this.eqn.functions.contentToElement(n)],r.arrange(this.eqn.scale,"left","baseline",new Oe(0,0)),this.eqn.functions.fullLineHeight=r,this.setFirstTransform(this.transform)}},{key:"addDescriptionElement",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Oe(0,0);this.eqn.descriptionElement=t,this.eqn.descriptionPosition=e,this.eqn.descriptionElement&&this.eqn.descriptionElement.setPosition(this.getPosition("local").add(e))}},{key:"setPosition",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;rf(sf(i.prototype),"setPosition",this).call(this,t,e),e=this.getPosition("local"),null!=this.eqn.descriptionElement&&this.eqn.descriptionElement.setPosition(e.add(this.eqn.descriptionPosition))}},{key:"addPhrases",value:function(t){var e=this;Object.keys(t).forEach((function(n){var r=t[n];e.eqn.functions.phrases[n]=r}))}},{key:"addForms",value:function(t){function e(t){return"string"==typeof t}function n(t){return Array.isArray(t)}var r=this;Object.keys(t).forEach((function(i){var o,a=t[i];(e(a)||n(a)||!e(o=a)&&!n(o)&&null!=o&&"object"===Zh(o)&&1===(o=Object.keys(o)).length&&o[0]in r.eqn.functions||a instanceof Ru||a instanceof Yu?function(t,e){var n;try{n=[r.eqn.functions.contentToElement(e)]}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(r.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}try{r.addForm(t,n)}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(r.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}}:function(t,e){var n;try{n=[r.eqn.functions.contentToElement(e.content)]}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(r.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}var i=e.elementMods,o=e.duration,a=e.alignment,s=e.scale,l=e.description,u=e.modifiers,c=e.translation;c={elementMods:i,alignment:a,scale:s,description:l,modifiers:u,fromForm:e.fromForm,duration:o,translation:c,onShow:e.onShow,onTransition:e.onTransition};try{r.addForm(t,n,c)}catch(n){throw new Error("\n\nFigureOne error adding form '".concat(t,"' in equation '").concat(r.getPath(),"'\n\nError: '").concat(n.message,"'\n\nForm definition: ").concat(JSON.stringify(e,null,2),"\n\n"))}})(i,a)})),null==this.initialForm&&0<Object.keys(this.eqn.forms).length&&(this.initialForm=Object.keys(this.eqn.forms)[0])}},{key:"checkFixTo",value:function(t,e){return"string"!=typeof t?t instanceof jl||t instanceof Rl||t instanceof Oe?t:null==t?new Oe(0,0):Ae(t):null!=(t=$h(this,t))&&0<=e.indexOf(t)?t:new Oe(0,0)}},{key:"createForm",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.elements;return new Qu(t,{getAllElements:this.getChildren.bind(this),hideAll:this.hideAll.bind(this),show:this.show.bind(this),showOnly:this.showOnly.bind(this),stop:this.stopEquationAnimating.bind(this),getElementTransforms:this.getElementTransforms.bind(this),setElementTransforms:this.setElementTransforms.bind(this),animateToTransforms:this.animateToTransforms.bind(this)})}},{key:"getFormElements",value:function(t){return null==this.eqn.forms[t]?[]:this.eqn.forms[t].content[0].getAllElements(1<arguments.length&&void 0!==arguments[1]&&arguments[1])}},{key:"getPhraseElements",value:function(t){var e=this;if("string"==typeof t)return null==this.eqn.functions.phraseElements[t]?[]:this.eqn.functions.phraseElements[t];var n={},r=[];return t.forEach((function(t){null!=e.eqn.functions.phraseElements[t]&&e.eqn.functions.phraseElements[t].forEach((function(t){null==n[t.name]&&(n[t.name]=!0,r.push(t))}))})),r}},{key:"getUnusedElements",value:function(){for(var t=this.getChildren().map((function(t){return t.name})),e=Object.keys(this.eqn.forms),n=0;n<e.length;n+=1)for(var r=e[n],i=this.getFormElements(r).map((function(t){return t.name})),o=0;o<i.length;o+=1){var a=i[o];if(-1<(a=t.indexOf(a))&&t.splice(a,1),0===t.length)return[]}return t}},{key:"stopEquationAnimating",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel";this.stopAnimating(t,"_Equation",!0),this.stopAnimating(t,"_EquationColor",!0),this.stopPulsing(t)}},{key:"addForm",value:function(t,e){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=u=ft({},{elementMods:{},description:"",modifiers:{},scale:this.eqn.scale,duration:void 0,onStart:null,fromForm:{},onShow:null,onTransition:null,layout:this.eqn.formDefaults.layout},this.eqn.formDefaults),o=(c=i=r?ft({},u,r):i).description,a=c.modifiers,s=c.fromForm,l=c.onShow,u=c.onTransition,c=(r=c.duration,c.translation),h=this.createForm();function f(t){var e={};return Object.keys(t).forEach((function(r){var i=t[r],o=$h(n,r);null!=o&&(e[r]={element:o,mods:i})})),e}function d(t){var e={};return Object.keys(t).forEach((function(r){var i,o,a,s=$h(n,r),l=t[r];l=Array.isArray(l)?(o=(i=Qh(l,3))[0],a=i[1],i[2]):(o=l.style,a=l.direction,l.mag),null!=s&&(e[r]={element:s,style:o,direction:a,mag:l})})),e}(this.eqn.forms[t]=h).description=o,h.modifiers=a,h.name=t,h.duration=r,h.translation=c,h.fromForm=s,h.onShow=l,h.onTransition=u,h.elementMods={},h.elementMods=f(i.elementMods),null!=h.translation&&(h.translation=d(h.translation)),null!=h.fromForm&&Object.keys(h.fromForm).forEach((function(t){null!=(t=h.fromForm[t]).elementMods&&(t.elementMods=f(t.elementMods)),null!=t.translation&&(t.translation=d(t.translation))})),h.content=e,e=h.getAllElements(),i.alignment.fixTo=this.checkFixTo(i.alignment.fixTo,e),h.layout=i.layout,"init"!==i.layout?h.lazyArrange(i.scale,i.alignment.xAlign,i.alignment.yAlign,i.alignment.fixTo):h.arrange(i.scale,i.alignment.xAlign,i.alignment.yAlign,i.alignment.fixTo),""===this.eqn.currentForm&&(this.eqn.currentForm=t)}},{key:"getCurrentForm",value:function(){return null==this.eqn.forms[this.eqn.currentForm]?null:this.eqn.forms[this.eqn.currentForm]}},{key:"render",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=this.getCurrentForm();null!=e&&(e.setPositions(),e.showHide(0,0,null,t),this.show(),e.applyElementMods())}},{key:"setCurrentForm",value:function(t){"string"==typeof t?(this.eqn.currentForm="",t in this.eqn.forms&&(this.eqn.currentForm=t)):this.eqn.currentForm=t.name}},{key:"showForm",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.eqn.currentForm,e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];rf(sf(i.prototype),"show",this).call(this);var n=t;(n="string"==typeof t?this.getForm(t):n)&&(this.setCurrentForm(n),this.render(e),this.fnMap.exec(n.onTransition),this.fnMap.exec(n.onShow))}},{key:"showAll",value:function(){this.showForm()}},{key:"getForm",value:function(t){return t instanceof Qu?t:t in this.eqn.forms?this.eqn.forms[t]:null}},{key:"goToForm",value:function(){var t,e,n,r,o,a,s,l=this,u=ft({duration:null,prioritizeFormDuration:!0,delay:0,fromWhere:"_current",animate:"dissolve",callback:null,ifAnimating:{skipToTarget:!0,cancelGoTo:!0}},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{});this.eqn.isAnimating&&(u.ifAnimating.skipToTarget?(this.stopEquationAnimating("complete"),null!=(e=this.getCurrentForm())&&this.showForm(e)):this.stopEquationAnimating("cancel"),this.eqn.isAnimating=!1,u.ifAnimating.cancelGoTo)||(null!=u.form?t=this.eqn.forms[u.form]:null!=u.index?t=this.eqn.forms[this.eqn.currentFormSeries[u.index]]:0<this.eqn.currentFormSeries.length&&(r=0,(o=(r=null!=(a=this.getCurrentForm())&&(r=this.eqn.currentFormSeries.indexOf(a.name))<0?0:r)+1)===this.eqn.currentFormSeries.length&&(o=0),t=this.eqn.forms[this.eqn.currentFormSeries[o]]),null!=t&&("_current"===u.fromWhere&&(u.fromWhere=this.eqn.currentForm),e=u.duration,u.prioritizeFormDuration&&(void 0!==t.duration&&(e=t.duration),null!=u.fromWhere&&null!=t.fromForm[u.fromWhere]&&void 0!==t.fromForm[u.fromWhere].duration&&(e=t.fromForm[u.fromWhere].duration)),a=t.onTransition,null!=t.fromForm&&null!=t.fromForm[u.fromWhere]&&void 0!==t.fromForm[u.fromWhere].onTransition&&(a=t.fromForm[u.fromWhere].onTransition),null!=e&&0<e&&"dissolve"===u.animate?(null==u.dissolveOutTime&&(u.dissolveOutTime=.4*e),null==u.dissolveInTime&&(u.dissolveInTime=.4*e),null==u.blankTime&&(u.blankTime=.2*e)):(null==u.dissolveOutTime&&(u.dissolveOutTime=.4),null==u.dissolveInTime&&(u.dissolveInTime=.4),null==u.blankTime&&(u.blankTime=.2)),0===e?(this.showForm(t),this.fnMap.exec(u.callback)):(this.eqn.isAnimating=!0,this.fnMap.exec(a),n=function(){l.fnMap.exec(t.onShow),l.eqn.isAnimating=!1,l.fnMap.exec(u.callback)},"move"===u.animate?t.animatePositionsTo(u.delay,u.dissolveOutTime,e,u.dissolveInTime,n,u.fromWhere,!1):"dissolveInThenMove"===u.animate?t.animatePositionsTo(u.delay,u.dissolveOutTime,e,u.dissolveInTime,n,u.fromWhere,!0):"moveFrom"===u.animate&&null!=this.eqn.formRestart&&null!=this.eqn.formRestart.moveFrom?(r=this.eqn.formRestart.moveFrom,o=this.getPosition(),a=this.getPosition(),r instanceof i&&r.showForm(t.name),a=r instanceof Rl?r.getPosition():Ae(this.eqn.formRestart.moveFrom),this.fnMap.add("_equationShowFormCallback",(function(){l.showForm(t.name,!1)})),this.animations.new("_Equation").dissolveOut({duration:u.dissolveOutTime}).position({target:a,duration:0}).trigger({callback:"showFormCallback",duration:.01}).position({target:o,duration:e}).whenFinished(n).start()):"pulse"===u.animate&&null!=this.eqn.formRestart&&null!=this.eqn.formRestart.pulse?(s=this.eqn.formRestart.pulse,t.allHideShow(u.delay,u.dissolveOutTime,u.blankTime,u.dissolveInTime,(function(){l.pulse({duration:s.duration,scale:s.scale,frequency:0,done:n}),null!=s.element&&s.element instanceof i&&s.element.getCurrentForm().name===t.name&&s.element.pulse({duration:s.duration,scale:s.scale})}))):t.allHideShow(u.delay,u.dissolveOutTime,u.blankTime,u.dissolveInTime,n),this.setCurrentForm(t))))}},{key:"getFormIndex",value:function(){if(null==(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null))return-1;var t,e=this.getForm(t);return null!=e?this.eqn.currentFormSeries.indexOf(e.name):-1}},{key:"prevForm",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=this.getCurrentForm();null==r||-1<(t=this.getFormIndex(r))&&(--t<0&&(t=this.eqn.currentFormSeries.length-1),"number"==typeof e||null==e?this.goToForm({index:t,duration:e,delay:n,fromWhere:r.name}):this.goToForm(ft({index:t,fromWhere:r.name},e)))}},{key:"nextForm",value:function(){var t,e,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i="move",o=this.getCurrentForm();null==o||-1<(t=this.getFormIndex(o))&&((t+=1)>this.eqn.currentFormSeries.length-1&&(t=0,i=null!=(e=this.eqn.formRestart)&&null!=e.moveFrom?"moveFrom":null!=e&&null!=e.pulse?"pulse":"dissolve"),"number"==typeof n||null==n?this.goToForm({index:t,duration:n,delay:r,fromWhere:o.name,animate:i}):this.goToForm(ft({index:t,animate:i,fromWhere:o.name},n)))}},{key:"replayCurrentForm",value:function(t){var e;this.eqn.isAnimating?(this.stopEquationAnimating("complete"),this.eqn.isAnimating=!1,null!=(e=this.getCurrentForm())&&this.showForm(e)):(this.stopEquationAnimating(),this.eqn.isAnimating=!1,this.prevForm(0),this.nextForm(t,.5))}},{key:"animateToForm",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;this.stopEquationAnimating();var i=this.getForm(t);null!=i&&i.animatePositionsTo(n,.4,e,.4,r),this.setCurrentForm(t)}},{key:"changeDescription",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};null!=(t=this.getForm(t))&&(t.description="".concat(e),t.modifiers=n)}},{key:"getDescription",value:function(t){return null!=(t=this.getForm(t))&&null!=t.description?eu(t.description,t.modifiers):""}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}(),uf=function(){function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this);var r,i,o,a,s=(h=ft({},{label:"",color:[this.lastOffsetMag=0,0,1,1],scale:.7,position:new Oe(0,0),xAlign:"center",yAlign:"middle"},n)).label,l=h.color,u=h.scale,c=h.position,h=(n=h.yAlign,h.xAlign);"string"==typeof s?(a=e.equation({elements:{base:s},color:l,formDefaults:{alignment:{fixTo:new Oe(0,0),xAlign:h,yAlign:n}},scale:u,forms:{base:["base"]},position:c})).showForm("base"):s instanceof lf?(a=s).showForm(Object.keys(a.eqn.forms)[0]):Array.isArray(s)?(r={},i={},o=[],s.forEach((function(t,e){r["_".concat(e)]=t,i[e]=[t],o.push("".concat(e))})),(a=e.equation({elements:r,forms:i,color:l,position:c,formDefaults:{alignment:{fixTo:new Oe(0,0),xAlign:h,yAlign:n}},scale:u,formSeries:o})).showForm("0")):(u={color:l,formDefaults:{alignment:{fixTo:new Oe(0,0),xAlign:h,yAlign:n}},scale:u},(a=e.equation(ft(u,s))).showForm(Object.keys(a.eqn.forms)[0])),this.eqn=a,this.width=0,this.height=0,this.aOffset=0}var e=[{key:"showForm",value:function(t){this.eqn.showForm(t)}},{key:"setText",value:function(t){var e,n,r=this.eqn.getCurrentForm();null!=r&&(e=Object.keys(r.elements)[0],null!=(n=r.elements[e].drawingObject)&&(n.setText(t),r.elements[e].drawBorder=r.elements[e].drawingObject.textBorder,r.elements[e].drawBorderBuffer=r.elements[e].drawingObject.textBorderBuffer),r.arrange(this.eqn.eqn.scale,this.eqn.eqn.formDefaults.alignment.xAlign,this.eqn.eqn.formDefaults.alignment.yAlign,this.eqn.eqn.formDefaults.alignment.fixTo))}},{key:"getText",value:function(){var t,e="",n=this.eqn.getCurrentForm();return null!=n&&(t=Object.keys(n.elements)[0],null!=(t=n.elements[t].drawingObject)&&(e=t.text[0].text)),e}},{key:"updateRotation",value:function(t,e,n,r,i,o){var a,s,l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:"oval",c=!(8<arguments.length&&void 0!==arguments[8])||arguments[8],h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:2*Math.PI,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:Math.PI,d=Math.PI/2,p=0;"start"===r?d=-Math.PI:"end"===r?d=0:(s=-(a=Math.cos(e+l)<0?-Math.PI/2:Math.PI/2),y=-(v=0<Math.sin(e+l)?Math.PI/2:-Math.PI/2),"top"===r&&(d=a),"bottom"===r&&(d=s),"right"===r&&(d=y),"left"===r&&(d=v),"positive"===r&&(d=Math.PI/2),"negative"===r&&(d=-Math.PI/2),0!==m(Math.sin(e+l),4)||"left"!==r&&"right"!==r||("top"===i&&(d=a),"bottom"===i&&(d=s)),0!==m(Math.cos(e+l),4)||"top"!==r&&"bottom"!==r||("right"===i&&(d=y),"left"===i&&(d=v)),"inside"===r&&(d=-Math.PI/2),"outside"===r&&(d=Math.PI/2));var y=l;"horizontal"===o&&(p=-e),"baseToLine"===o&&d<(p=y=0)&&(p=Math.PI),"baseAway"===o&&(y=0,p=Math.PI,d<0&&(p=0)),"upright"===o&&(y=0,Math.cos(e+l)<0&&(p=Math.PI)),i=0;var v=0;l=!1,null!=(o=this.eqn.getCurrentForm())&&(this.height!==o.height&&(this.height=o.height,l=!0),this.width!==o.width&&(this.width=o.width,l=!0),i=o.height/2,v=o.width/2),n!==this.lastOffsetMag&&(this.lastOffsetMag=n,l=!0),o=new Oe(0,0),"oval"===u&&(o=this.getOvalOffset(p-y,i,v,n,d,l,r,h,f)),h=t.add(o),f=p-y,!1===c&&(h=t.add(o).rotate(e,t),f=p-y+e),this.eqn.setPosition(h),this.eqn.transform.updateRotation(f)}},{key:"getOvalOffset",value:function(t,e,n,r,i,o,a){function s(t,e,n){return t*e/Math.sqrt(Math.pow(e*Math.cos(n),2)+Math.pow(t*Math.sin(n),2))}var l=7<arguments.length&&void 0!==arguments[7]?arguments[7]:2*Math.PI,u=8<arguments.length&&void 0!==arguments[8]?arguments[8]:Math.PI;if(o){for(var c=Math.atan(e/n),h=e/Math.sin(c)+r,f=h-s(n+r,e+r,c),d=2,p=-1,m=0;d<33&&p<h;)p=s(n+(m=f*d*.1+r),e+m,c),d+=1;this.aOffset=m}var y,v,g=this.aOffset+n,b=this.aOffset+e,w=Ee(t,"0to360");return o=0,t=0,"start"===a?(o=-(y=s(g,b,v=l-w))*Math.cos(l),t=-y*Math.sin(l)):"end"===a?(o=-(y=s(g,b,v=u-w))*Math.cos(u),t=-y*Math.sin(u)):(y=s(g,b,v=Ee(2*Math.PI-Math.atan(-Math.pow(b,2)/(Math.pow(g,2)*Math.tan(w))),"0to360")),(v=Ee(w+v-Math.PI,"-180to180"))<0&&(v+=Math.PI),o=y*Math.cos(v),t=y*Math.sin(v),i<0&&(t=-t,o=-o)),0===r?new Oe(0,0):new Oe(o,t)}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function cf(t){return(cf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function hf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ff(t,e,n){return(ff="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=gf(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function df(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function pf(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&mf(t,e)}function mf(t,e){return(mf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function yf(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=gf(t);return function(t,e){if(e&&("object"===cf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return vf(t)}(this,e?(n=gf(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function vf(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function gf(t){return(gf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var bf=function(){pf(e,uf);var t=yf(e);function e(n,r,i,o){var a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"top",s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:"left",l=6<arguments.length&&void 0!==arguments[6]?arguments[6]:"horizontal",u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:.5,c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:.7,h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:1;return df(this,e),(c=t.call(this,n,{label:r,color:i,scale:c})).offset=o,c.location=a,c.subLocation=s,c.orientation=l,c.linePosition=u,c.precision=h,c}return e}(),wf=function(){pf(n,Rl);var t,e=yf(n);function n(t,r){var i,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};df(this,n);var a,s,l=ft({},{width:.01,align:"start",color:t.primitives.defaultColor,dash:[],mods:{},pulseWidth:{line:6,label:2,arrow:3,duration:1,frequency:0},transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},o),u=l.move;delete l.move,(i=e.call(this,l)).collections=t,i.setColor(l.color),i.isTouchDevice=r,i.dash=l.dash,i.width=l.width,i.line=(s=l,s=null!=(a=ft({},{p1:new Oe(0,0),length:1,angle:0,align:"start",offset:0},s)).p1&&null!=a.p2?new Ie(a.p1,a.p2):new Ie({p1:a.p1,length:a.length,angle:a.angle}),s=0!==a.offset?s.offset("positive",a.offset):s),i.alignDraw=l.align,i.localXPosition=0,i.autoUpdateSubscriptionId=-1,i.lastParentRotationOffset=0,i.multiMove={midLength:.333,includeLabelInTouchBoundary:!1},i.pulseWidthOptions={oldCallback:null,oldTransformMethod:null},i.scaleTransformMethodName="_transformMethod",i._line=null,0<i.width&&(o=i.collections.primitives,t=i.line.length(),r=i.width,a=l.color,s=i.dash,(s=o.line({p1:[0,0],length:s.length<2?1:t,angle:0,width:r,color:a,dash:s,transform:(new Qe).scale(1,1).translate(0,0)})).fnMap.add(i.scaleTransformMethodName,(function(t){return(new Qe).scale(1,t)})),i.add("line",s)),i._arrow1=null,i._arrow2=null,i.label=null,i._label=null,i.showRealLength=!1,null!=l.arrow&&(c=Kr(l.arrow,i.width||.01),i.arrow=c,i.addArrow("start"),i.addArrow("end")),i.setupLine();var c={text:null,offset:1e-5,location:"positive",subLocation:"left",orientation:"horizontal",linePosition:.5,scale:.7,color:l.color,precision:1,update:!1};void 0!==l.label&&(null===(c="string"==typeof l.label||null===l.label?ft({},c,{text:l.label}):ft({},c,l.label)).text&&(c.text="",i.showRealLength=!0),i.addLabel(c.text,c.offset,c.location,c.subLocation,c.orientation,c.linePosition,c.scale,c.color,c.precision,c.update,c)),u&&(u=ft({},{type:"rotation",middleLength:.22,includeLabelInTouchBoundary:!1},u),i.setMovable({movable:!0,type:u.type,middleLength:u.middleLength})),i.pulseWidthDefaults={line:l.pulseWidth.line||1,label:l.pulseWidth.label||1,arrow:l.pulseWidth.arrow||1,duration:l.pulseWidth.duration||1,frequency:l.pulseWidth.frequency||0},null!=l.mods&&l.mods!=={}&&i.setProperties(l.mods);var h,f,d=!0;return i.fnMap.add("_lengthCallback",(function(t){d&&(null==h&&(h=i.line.length()),null==f&&(f=i.line.length())),d=!1,t=(f-h)*t+h,i.setLength(t)})),i.animations.length=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{element:vf(i)}].concat(e));return h=r.start,f=r.target,r.callback="_lengthCallback",r.timeKeeper=i.timeKeeper,new Na(r)},i.fnMap.add("_pulseWidth",(function(t,e){var n=e.line,r=e.label,o=e.arrow,a=e.duration;e=e.frequency,i.pulseWidth({line:n,label:r,arrow:o,duration:a,frequency:e})})),i.animations.pulseWidth=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{element:vf(i),duration:1}].concat(e));return r.callback="_pulseWidth",r.customProperties={line:r.line,label:r.label,arrow:r.arrow,duration:r.duration,frequency:r.frequency},r.timeKeeper=i.timeKeeper,new ja(r)},i.animations.customSteps.push({step:i.animations.length.bind(vf(i)),name:"length"}),i.animations.customSteps.push({step:i.animations.pulseWidth.bind(vf(i)),name:"pulseWidth"}),i.fnMap.add("transformToLine",i.transformToLine.bind(vf(i))),i.notifications.add("setTransform","transformToLine"),i}return t=[{key:"transformToLine",value:function(){var t=this.transform.r()||0,e=this.transform.t()||new Oe(0,0),n=this.line.length(),r=new Ie({p1:e,length:n,angle:t}),i=[0,0];"start"===this.alignDraw?i=e._dup():"end"===this.alignDraw?i=r.pointAtPercent(-1):"center"===this.alignDraw?i=r.pointAtPercent(-.5):"number"==typeof this.alignDraw&&(i=r.pointAtPercent(-this.alignDraw)),this.line=new Ie({p1:i,length:n,angle:t})}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return hf(t)}(e=ff(gf(n.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return hf(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?hf(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["line","alignDraw","width","dash","animateLengthToOptions","pulseWidthOptions"]);var e}},{key:"_fromState",value:function(t){return ft(this,t),this.setupLine(),this}},{key:"stateSet",value:function(){ff(gf(n.prototype),"stateSet",this).call(this),this.setupLine()}},{key:"pulseWidthDone",value:function(){var t=this._line;null!=t&&(this.pulseWidthOptions.oldTransformMethod&&(t.pulseSettings.transformMethod=this.pulseWidthOptions.oldTransformMethod),t.pulseSettings.callback=this.pulseWidthOptions.oldCallback)}},{key:"pulseWidth",value:function(){var t=ft({line:this.pulseWidthDefaults.line,label:this.pulseWidthDefaults.label,arrow:this.pulseWidthDefaults.arrow,done:null,duration:this.pulseWidthDefaults.duration,frequency:this.pulseWidthDefaults.frequency,when:"nextFrame"},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),e=t.done;null!=(r=this._line)&&(r.stopPulsing(),this.pulseWidthOptions={oldTransformMethod:r.pulseSettings.transformMethod,oldCallback:r.pulseSettings.callback},r.pulseSettings.callback=this.pulseWidthDoneCallbackName,r.pulseSettings.transformMethod=this.scaleTransformMethodName,r.pulse({duration:t.duration,scale:t.line,frequency:t.frequency,callback:e,when:t.when}),e=null);var n=this._arrow1,r=this._arrow2;null!=n&&(n.pulse({duration:t.duration,scale:t.arrow,frequency:t.frequency,callback:e,when:t.when,centerOn:n.getPosition("figure")}),e=null),null!=r&&(r.pulse({duration:t.duration,scale:t.arrow,frequency:t.frequency,callback:e,when:t.when,centerOn:r.getPosition("figure")}),e=null),null!=(r=this._label)&&(t="number"==typeof t.label?ft({},t,{scale:t.label,callback:e}):ft({},t,t.label,{callback:e}),r.pulse(t),e=null),null!=e&&e(),this.animateNextFrame()}},{key:"addArrow",value:function(t){var e,n,r;null!=this.arrow&&null!=this.arrow[t]&&(r=this.arrow[t],e=0,n=1,"start"===t&&(e=Math.PI,n=0),n=this.collections.primitives.arrow(ft({},r,{angle:e,color:this.color,transform:(new Qe).translate(n)})),r=Nr(r)[1],this["arrow".concat(t="end"===t?2:1)]={height:r},this.add("arrow".concat(t),n))}},{key:"setMove",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e={movable:!0,type:this.move.type,middleLength:this.multiMove.midLength,includeLabelInTouchBoundary:this.multiMove.includeLabelInTouchBoundary},r=!1===t?ft({},e,{movable:!1}):!0===t?e:ft({},e,t);ff(gf(n.prototype),"setMove",this).call(this,r),r.movable?(t=(e=r).includeLabelInTouchBoundary,r=e.type,e=e.middleLength,this.multiMove.includeLabelInTouchBoundary=t,"translation"===r||"rotation"===r||"scale"===r?(this.move.type=r,ff(gf(n.prototype),"setMovable",this).call(this,!0),null!=this._line&&(this._line.isTouchable=!0,this._line.isMovable=!1),this._movePad&&(this._movePad.isMovable=!1)):"centerTranslateEndRotation"===r&&(this.setMultiMovable(e),this.updateMovePads())):(this.isMovable=!1,this.isTouchable=!1,null!=this._line&&(this._line.isTouchable=!1,this._line.isMovable=!1))}},{key:"setMultiMovable",value:function(t){var e;this.multiMove.midLength=t,null==this._rotPad&&(e=this.collections.primitives.rectangle({position:new Oe(0,0),xAlign:"left",yAlign:"bottom",width:1,height:1,color:[0,0,1,5e-4]}),this.add("rotPad",e),e.setMovable(),e.move.type="rotation",e.move.element=this,e.drawingObject.border=[[]]),null==this._movePad&&(e=this.collections.primitives.rectangle({position:new Oe(0,0),xAlign:"left",yAlign:"bottom",width:1,height:1,color:[0,1,0,5e-4]}),this.add("movePad",e),e.setMovable(),e.move.type="translation",e.move.element=this,e.drawingObject.border=[[]]),this.isTouchable=!1,this.isMovable=!1,this.setLength(this.line.length())}},{key:"moved",value:function(t){this.move.type="number"==typeof t?"rotation":"translation",ff(gf(n.prototype),"moved",this).call(this,t)}},{key:"updateMoveTransform",value:function(){var t=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.transform._dup()).r();null!=t&&(t>2*Math.PI&&this.transform.updateRotation(t-2*Math.PI),t<0&&this.transform.updateRotation(t+2*Math.PI))}},{key:"addLabel",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"top",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"left",i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"horizontal",o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:.5,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:.7,s=7<arguments.length&&void 0!==arguments[7]?arguments[7]:this.color,l=8<arguments.length&&void 0!==arguments[8]?arguments[8]:1,u=9<arguments.length&&void 0!==arguments[9]&&arguments[9],c=10<arguments.length&&void 0!==arguments[10]?arguments[10]:{};this.label=new bf(this.collections,t,s,e,n,r,i,o,a,l),(this.label.eqn.initialForm=null)!=c.isTouchable&&(this.label.eqn.isTouchable=c.isTouchable),null!=c.touchBorder&&(this.label.eqn.touchBorder=c.touchBorder),null!=c.onClick&&(this.label.eqn.onClick=c.onClick),null!=this.label&&this.add("label",this.label.eqn),this.setAutoUpdate(u),this.updateLabel(),this.updateMovePads()}},{key:"setAutoUpdate",value:function(){var t=this;0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.notifications.remove("setTransform",this.autoUpdateSubscriptionId),this.autoUpdateSubscriptionId=-1):this.autoUpdateSubscriptionId=this.notifications.add("setTransform",(function(){t.updateLabel(),t.updateMovePads()}))}},{key:"getLength",value:function(){return this.line.length()}},{key:"getAngle",value:function(){return"deg"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"rad")?180*this.line.angle()/Math.PI:this.line.angle()}},{key:"setLabel",value:function(t){this.showRealLength=!1,null!=this.label&&this.label.setText(t),this.updateLabel(),this.updateMovePads()}},{key:"getLabel",value:function(){return null!=this.label?this.label.getText():""}},{key:"setLabelToRealLength",value:function(){this.showRealLength=!0,this.updateLabel(),this.updateMovePads()}},{key:"updateLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;null!=t&&(this.lastParentRotationOffset=t);var e,n=this.label;null!=n&&(t=Me(this.transform.r()||0),this.showRealLength&&this._label&&(e=p(this.line.length(),2).toFixed(n.precision),n.getText()!==e&&n.setText(p(this.line.length(),2).toFixed(n.precision))),e=new Oe(this.localXPosition+n.linePosition*this.line.length(),0),"start"===n.location&&(e.x=this.localXPosition),"end"===n.location&&(e.x=this.localXPosition+this.line.length()),n.updateRotation(e,t,n.offset,n.location,n.subLocation,n.orientation,this.lastParentRotationOffset,"oval",!0,2*Math.PI,Math.PI))}},{key:"setLength",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.alignDraw;t=0===t?1e-7:t,"start"===e?this.line=new Ie({p1:this.line.p1,length:t,angle:this.line.angle()}):"end"===e?this.line=new Ie({p1:this.line.pointAtLength(this.line.length()-t),length:t,angle:this.line.angle()}):"center"===e?this.line=new Ie({p1:this.line.pointAtLength((this.line.length()-t)/2),length:t,angle:this.line.angle()}):"number"==typeof e&&(this.line=new Ie({p1:this.line.pointAtLength((this.line.length()-t)*e),length:t,angle:this.line.angle()})),this.alignDraw=e,this.setupLine()}},{key:"setupLine",value:function(){var t=this,e=!this.isShown,n=!1;null!=this._label&&!1===this._label.isShown&&(n=!0);var r=function(e,n){null!=t["_".concat(e)]&&t["_".concat(e)].transform.updateTranslation([n,0])},i=0,o=this.line.p1._dup();"number"==typeof(s=this.alignDraw)?(i=-this.line.length()*s,o=this.line.pointAtPercent(s)):"end"===s?(i=-this.line.length(),o=this.line.p2._dup()):"center"===s&&(i=-this.line.length()/2,o=this.line.pointAtPercent(.5)),r("arrow1",this.localXPosition=i),r("arrow2",i+this.line.length());var a=this.line.length(),s=0;this.arrow1&&this._arrow1&&(a-=this.arrow1.height,s=this.arrow1.height),this.arrow2&&this._arrow2&&(a-=this.arrow2.height),a=Math.max(a,0),(r=this._line)&&(r.transform.updateTranslation([i+s,0]),r.custom.updatePoints({p1:[0,0],p2:[a,0],dash:this.dash})),this.transform.updateRotation(this.line.angle()),this.transform.updateTranslation(o),this.updateLabel(),this.updateMovePads(),e&&this.hide(),n&&null!=this._label&&this._label.hide()}},{key:"updateMovePads",value:function(){var t,e,n,r,i;null!=this._movePad&&null!=this._rotPad&&(n=["line","arrow1","arrow2"],this.multiMove.includeLabelInTouchBoundary&&n.push("label"),t=(i=fr(this.getBorder("draw","touchBorder",n)))[0].distance(i[1]),e=i[0].distance(i[3]),(n=this._movePad)&&(r=this.multiMove.midLength*this.line.length(),n.transform.updateScale([r,e]),n.setPosition(this.localXPosition+this.line.length()/2-r/2,i[0].y)),(r=this._rotPad)&&(r.transform.updateScale([t,e]),r.setPosition(i[0].x,i[0].y)),(i=this._startPad)&&i.transform.updateTranslation([this.localXPosition,0]))}},{key:"setEndPoints",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.line=new Ie(t,e).offset("positive",n),this.setupLine()}},{key:"pointFromTo",value:function(t,e){var n,r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],i=this.spaceTransformMatrix("figure","local"),o=t.element.getBoundingRect("figure"),a=e.element.getBoundingRect("figure"),s={from:{xAlign:"center",yAlign:"middle",space:0},to:{xAlign:"center",yAlign:"middle",space:0}};r&&(n=o.intersectsWith(a.center()),r=a.intersectsWith(o.center()),null!=n&&(s.from.xAlign=(n.x-o.left)/o.width,s.from.yAlign=(n.y-o.bottom)/o.height),null!=r&&(s.to.xAlign=(r.x-a.left)/a.width,s.to.yAlign=(r.y-a.bottom)/a.height)),o=gr(o,(e=ft({},s,{from:t,to:e})).from.xAlign,e.from.yAlign).transformBy(i),i=gr(a,e.to.xAlign,e.to.yAlign).transformBy(i),i=new Ie(o,i),this.setEndPoints(i.pointAtLength(e.from.space),i.pointAtLength(i.length()-e.to.space))}},{key:"grow",value:function(t){t=ft({},{start:0},t),this.animations.new().then(this.animations.length(t)).start()}},{key:"showLineOnly",value:function(){this.show(),this._line&&this._line.show(),this._arrow1&&this._arrow1.show(),this._arrow2&&this._arrow2.show(),this._label&&this._label.hideAll()}},{key:"getLine",value:function(){return new Ie(this.getP1(),this.getP2())}},{key:"getP1",value:function(){return this.line.p1._dup()}},{key:"getP2",value:function(){return this.line.p2._dup()}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(n.prototype,t),n}();function xf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Sf(t){return(Sf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Tf(t,e,n){return(Tf="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Mf(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Af(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kf(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_f(t,e)}function _f(t,e){return(_f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Of(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Mf(t);return Pf(this,e?(n=Mf(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function Pf(t,e){if(e&&("object"===Sf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Ef(t)}function Ef(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Mf(t){return(Mf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Cf=function(){kf(e,uf);var t=Of(e);function e(n,r,i,o){var a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:.5,s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,l=6<arguments.length&&void 0!==arguments[6]&&arguments[6],u=7<arguments.length&&void 0!==arguments[7]?arguments[7]:"degrees",c=8<arguments.length&&void 0!==arguments[8]?arguments[8]:0,h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:null,f=10<arguments.length&&void 0!==arguments[10]?arguments[10]:null,d=11<arguments.length&&void 0!==arguments[11]?arguments[11]:"horizontal",p=12<arguments.length?arguments[12]:void 0,m=13<arguments.length?arguments[13]:void 0,y=14<arguments.length&&void 0!==arguments[14]?arguments[14]:.7;return Af(this,e),(y=t.call(this,n,{label:r,color:i,scale:y})).radius=o,y.curvePosition=a,y.offset=s,y.showRealAngle=l,y.units=u,y.orientation=d,y.precision=c,y.autoHide=h,y.autoHideMax=f,y.location=p,y.subLocation=m,y}return e}();const jf=function(){kf(n,Rl);var t,e=Of(n);function n(t,r,i){var o,a,s,l=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(Af(this,n),l=ft({},{position:new Oe(0,0),color:t.primitives.defaultColor,direction:1,curve:null,corner:null,sides:null,sideStart:null,sideStop:null,pulseAngle:{curve:1.5,label:1.5,arrow:1.5,side:1.5,corner:1.5,thick:1},mods:{},transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},l),(o=e.call(this,l)).setColor(l.color),o.collections=t,o.largerTouchBorder=l.largerTouchBorder,o.isTouchDevice=r,o.autoUpdateSubscriptionId=0,o.lastLabelRotationOffset=0,"positive"===l.direction?o.direction=1:"negative"===l.direction?o.direction=-1:o.direction=l.direction,o.calculateAngleRotationPosition(l),o.setNextPositionAndRotation(),o.side1=null,o.side2=null,o.curve=null,o.label=null,o._curve=null,l.curve&&o.addCurve(l.curve),o._arrow1=null,(o._arrow2=null)!=l.arrow){t=.01,o.curve&&(t=o.curve.width);var u=!0;"string"!=typeof l.arrow&&null!=l.arrow.autoHide&&(u=l.arrow.autoHide),r=.1,o.curve&&(r=o.curve.radius),"string"!=typeof l.arrow&&null!=l.arrow.radius&&(r=l.arrow.radius);var c=.3;if("string"!=typeof l.arrow&&null!=l.arrow.curveOverlap&&(c=l.arrow.curveOverlap),t=Kr(l.arrow,t),o.arrow=t,null==o.arrow)return Pf(o);u={radius:r,autoHide:u,curveOverlap:c},null!=o.arrow.start&&(o.arrow.start=ft({},u,o.arrow.start)),null!=o.arrow.end&&(o.arrow.end=ft({},u,o.arrow.end)),o.addArrow("start"),o.addArrow("end")}return!l.label&&null!==l.label||(null===l.label&&(l.label={text:null}),"string"==typeof l.label&&(l.label={text:l.label}),o.addLabel(l.label)),c=.5,u=.01,u={length:c=o.curve?2*o.curve.radius:c,width:u=o.curve?o.curve.width:u,color:o.color},l.side1&&(a=ft({},u,l.side1),o.addSide(1,a.length,a.width,a.color)),l.side2&&(a=ft({},u,l.side2),o.addSide(2,a.length,a.width,a.color)),null!=l.corner&&(s=ft({},u,{style:"fill"},l.corner),o.addCorner(s)),l.sides&&(s={},s=ft({},u,s="object"===Sf(l.sides)?l.sides:s),o.addSide(1,s.length,s.width,s.color),o.addSide(2,s.length,s.width,s.color)),o.pulseAngleDefaults={curve:l.pulseAngle.curve||1.5,corner:l.pulseAngle.corner||1.5,label:l.pulseAngle.label||1.5,arrow:l.pulseAngle.arrow||1.5,duration:l.pulseAngle.duration||1.5,frequency:l.pulseAngle.frequency||0,thick:l.pulseAngle.thick||1},o.animations.angle=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r,i,a=ft.apply(void 0,[{},{element:Ef(o)}].concat(e)),s=!0;return a.callback=function(t){s&&(i=null==a.start?o.angle:a.start,r=null==a.target?o.angle:a.target,s=!1),t=(r-i)*t+i,o.setAngle({angle:t})},a.timeKeeper=o.timeKeeper,new Na(a)},o.animations.customSteps.push({step:o.animations.angle.bind(Ef(o)),name:"angle"}),o.animations.pulseAngle=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{element:Ef(o),duration:1}].concat(e));return r.callback=function(){o.pulseAngle({curve:r.curve,label:r.label,arrow:r.arrow,corner:r.corner,duration:r.duration,frequency:r.frequency,thick:r.thick})},r.timeKeeper=o.timeKeeper,new ja(r)},o.animations.customSteps.push({step:o.animations.pulseAngle.bind(Ef(o)),name:"pulseAngle"}),o.update(),null!=l.mods&&l.mods!=={}&&o.setProperties(l.mods),o}return t=[{key:"calculateAngleRotationPosition",value:function(t){var e,n=ft({},{angle:1,startAngle:this.startAngle},t),r=n.angle,i=n.startAngle,o=n.position;null!=o&&(o=Ae(o)),null!=n.p1&&null!=n.p2&&null!=n.p3&&(e=Ae(n.p1),t=Ae(n.p2),n=Ae(n.p3),o=t._dup(),i=new Ie(t,e).angle(),r=je(e,t,n)),this.nextStartAngle=i,null!=o&&(this.nextPosition=o),this.angle=r}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return xf(t)}(e=Tf(Mf(n.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return xf(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?xf(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["angle","lastLabelRotationOffset"]);var e}},{key:"_fromState",value:function(t){return ft(this,t),this.setAngle({angle:this.angle,rotationOffset:this.lastLabelRotationOffset}),this}},{key:"setAutoUpdate",value:function(){var t=this;0<arguments.length&&void 0!==arguments[0]&&!arguments[0]?(this.notifications.remove("setTransform",this.autoUpdateSubscriptionId),this.autoUpdateSubscriptionId=-1):this.autoUpdateSubscriptionId=this.notifications.add("setTransform",(function(){t.updateLabel(t.getRotation())}))}},{key:"setNextPositionAndRotation",value:function(){null!=this.nextPosition&&this.transform.updateTranslation(this.nextPosition),null!=this.nextStartAngle&&(this.transform.updateRotation(this.nextStartAngle),this.startAngle=this.nextStartAngle||0),this.nextPosition=null,this.nextStartAngle=null}},{key:"setAngle",value:function(){var t=!this.isShown,e=!1;null!=this._label&&!1===this._label.isShown&&(e=!0),this.calculateAngleRotationPosition(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{});var n=this.corner,r=this._corner;null!=n&&null!=r&&(n=this.getCornerPoints(n.length),r.custom.updatePoints({points:n})),this.update(),t&&this.hide(),e&&null!=this._label&&null!=this.label&&null==this.label.autoHide&&null==this.label.autoHideMax&&this._label.hide()}},{key:"getCornerPoints",value:function(t){return[new Oe(t,0),new Oe(0,0),new Oe(t*Math.cos(this.angle),t*Math.sin(this.angle))]}},{key:"addCorner",value:function(t){var e=t.width,n=t.color,r=t.length,i=t.style;t=this.collections.primitives.polyline({width:e,color:n,points:this.getCornerPoints(r),cornerStyle:i}),this.corner={length:r,width:e,color:n,style:i},this.add("corner",t)}},{key:"addSide",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:this.color;r=this.collections.primitives.line({length:1,width:n,angle:0,color:r,transform:(new Qe).scale(1,1).rotate(0)}),this["side".concat(t)]={length:e,width:n},this.add("side".concat(t),r)}},{key:"addLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e={text:null,radius:.4,curvePosition:.5,offset:1e-4,showRealAngle:!1,units:"degrees",precision:0,orientation:"horizontal",autoHide:null,autoHideMax:null,scale:.7,color:this.color,location:"outside",update:!1};this.curve&&(e.radius=Math.max(this.curve.radius,this.curve.radius+(this.curve.num-1)*this.curve.step)),null===(t=ft({},e,t)).text&&(t.text="",t.showRealAngle=!0),this.label=new Cf(this.collections,t.text,t.color,t.radius,t.curvePosition,t.offset,t.showRealAngle,t.units,t.precision,t.autoHide,t.autoHideMax,t.orientation,t.location,t.subLocation,t.scale),(this.label.eqn.initialForm=null)!=t.isTouchable&&(this.label.eqn.isTouchable=t.isTouchable),null!=t.touchBorder&&(this.label.eqn.touchBorder=t.touchBorder),null!=t.onClick&&(this.label.eqn.onClick=t.onClick),null!=this.label&&this.add("label",this.label.eqn),this.setAutoUpdate(t.update),this.updateLabel()}},{key:"addCurve",value:function(){var t=ft({},{width:.01,sides:100,radius:.5,num:1,fill:!1,step:0,autoHide:null,autoHideMax:null,autoRightAngle:!1,rightAngleRange:1/180*Math.PI},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}),e=this.direction;this.angle<0&&-1===this.direction?e=1:this.angle<0&&1===this.direction&&(e=-1);for(var n,r,i=0;i<t.num;i+=1){var o={sides:t.sides,radius:t.radius+i*t.step,color:this.color,direction:e,transform:(new Qe).rotate(0)};!1===t.fill&&(o.line={width:t.width});var a=this.collections.primitives.polygon(o);this.curve=t,o="curve",0<i&&(o="".concat(o).concat(i)),this.add(o,a)}null!=this.curve&&this.curve.autoRightAngle&&(n=this.collections.collection(),r=.707*t.radius,n.add("line1",this.collections.primitives.line({p1:[r,0],length:r+t.width/2,width:t.width,angle:Math.PI/2*e,color:this.color})),n.add("line2",this.collections.primitives.line({p1:[0,r*e],length:r+t.width/2,width:t.width,angle:0,color:this.color})),this.add("curveRight",n))}},{key:"change",value:function(t){null!=this._curve&&null!=t.radius&&this._curve.custom.update({radius:t.radius}),null!=this.label&&(null!=t.curveRadius&&(this.label.radius=t.curveRadius),null!=t.curvePosition&&(this.label.curvePosition=t.curvePosition),null!=t.offset&&(this.label.offset=t.offset))}},{key:"addArrow",value:function(t){var e,n,r,i;null!=this.arrow[t]&&(e=this.arrow[t],n=this.collections.primitives.arrow(ft({},e,{color:this.color,transform:(new Qe).rotate(0).translate(0,0)})),r=Nr(e)[1],i="end"===t?2:1,this.arrow[t]={height:r,radius:e.radius||0,autoHide:e.autoHide,curveOverlap:e.curveOverlap},this.add("arrow".concat(i),n),this.update())}},{key:"updateCurve",value:function(t,e,n,r){var i=this.curve;if(i){var o=this.direction;this.angle<0&&-1===this.direction?o=1:this.angle<0&&1===this.direction&&(o=-1);var a=n;-1===this.direction&&(a*=-1),this.angle<0&&(a*=-1);for(var s=0;s<i.num;s+=1){var l,u="_curve",c=this[u=0<s?"_curve".concat(s):u];c&&(r?(c.show(),0===s?(l=0,this.curve&&(u=2*Math.PI/this.curve.sides,l=t-Math.floor(p(t/u))*u),c.angleToDraw=Ee(t,"0to360"),c.transform.updateRotation(a+o*l/2)):(l=0,this.curve&&(l=e%(2*Math.PI/this.curve.sides)),c.angleToDraw=Ee(e,"0to360"),c.transform.updateRotation(o*l/2))):c.hide())}}}},{key:"update",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=this._arrow1,n=this._arrow2,r=!1,i=!1,o=0,a=Ee(this.angle,"-360to360");0<=a&&-1===this.direction?a=2*Math.PI-a:a<0&&1===this.direction?a=Math.abs(a):a<0&&-1===this.direction&&(a=2*Math.PI-Math.abs(a));var s,l,u,c,h=a,f=a,d=0,p=0;null!=this.arrow&&null!=this.arrow.start&&(l=(s=this.arrow.start).radius||0,h-=d=s.height/l*(1-s.curveOverlap),f-=s.height/l),null!=this.arrow&&null!=this.arrow.end&&(l=(s=this.arrow.end).radius||0,h-=p=s.height/l*(1-s.curveOverlap),f-=s.height/l),null!=this.arrow&&f<0&&(null!=this.arrow.start&&this.arrow.start.autoHide&&(u=this.arrow.start.radius||0,r=!0,f+=this.arrow.start.height/u,h+=d),null!=this.arrow.end&&this.arrow.end.autoHide&&(u=this.arrow.end.radius||0,i=!0,f+=this.arrow.end.height/u,h+=p)),e&&null!=this.arrow&&null!=this.arrow.start&&(r?e.hide():(e.show(),e.transform.updateTranslation([this.arrow.start.radius,0]),p=this.arrow.start.height/this.arrow.start.radius,c=this.arrow.start.radius||0,c=(0<this.angle&&1===this.direction||this.angle<0&&-1===this.direction?new Ie(Ke(c,p),[c,0]):new Ie(Ke(c,-p),[c,0])).angle(),e.transform.updateRotation(c),o=d)),n&&null!=this.arrow&&null!=this.arrow.end&&(i?n.hide():(n.show(),n.transform.updateTranslation(Ke(this.arrow.end.radius,this.angle)),c=this.arrow.end.height/this.arrow.end.radius,m=this.arrow.start.radius||0,m=(0<this.angle&&1===this.direction||0<this.angle&&-1===this.direction?new Ie(Ke(m,this.angle-this.direction*c),Ke(m,this.angle)):new Ie(Ke(m,this.angle+this.direction*c),Ke(m,this.angle))).angle(),n.transform.updateRotation(m),o=d)),null!=t&&(this.lastLabelRotationOffset=t),this.setNextPositionAndRotation();var m=this._curve;d=this.curve,t=this._curveRight,null!=m&&null!=d&&(null!=d.autoHide&&a<d.autoHide||null!=d.autoHideMax&&a>d.autoHideMax?(null!=t&&t.hide(),m.hide(),null!=e&&e.hide(),null!=n&&n.hide()):null!=d&&d.autoRightAngle&&a>=Math.PI/2-d.rightAngleRange/2&&a<=Math.PI/2+d.rightAngleRange/2?(null!=t&&t.showAll(),m.hide(),null!=e&&e.hide(),null!=n&&n.hide()):(null!=t&&t.hide(),null!=e&&!1===r&&e.show(),null!=n&&!1===i&&n.show(),h=Math.max(h,0),this.updateCurve(h,a,o,!0))),this.updateLabel(),a=this._side1,o=this.side1,a&&o&&a.transform.updateScale([o.length,1]),a=this._side2,o=this.side2,a&&o&&(a.transform.updateRotation(this.angle),a.transform.updateScale([o.length,1])),this.updateMovePads()}},{key:"checkLabelForRightAngle",value:function(){var t,e,n,r;null!=this.curve&&!1===this.curve.autoRightAngle||(r=!1)!==(r=null!=(n=this.label)&&90===parseFloat(n.getText())||r)&&(t=this._curveRight,e=this._curve,n=this._arrow1,r=this._arrow2,null!=t&&t.showAll(),null!=e&&e.hide(),null!=n&&n.hide(),null!=r&&r.hide())}},{key:"getAngle",value:function(){return"deg"===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"rad")?180*this.angle/Math.PI:this.angle}},{key:"setLabel",value:function(t){var e=this.label;null!=e&&(e.setText(t),e.showRealAngle=!1),this.updateLabel()}},{key:"getLabel",value:function(){return null!=this.label?this.label.getText():""}},{key:"setLabelToRealAngle",value:function(){var t=this.label;null!=t&&(t.showRealAngle=!0),this.updateLabel()}},{key:"updateLabel",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getRotation();null!=t&&(this.lastLabelRotationOffset=t);var e,n,r,i=this._label,o=this.label;i&&o&&(null!=o.autoHide&&o.autoHide>Math.abs(this.angle)||null!=o.autoHideMax&&Math.abs(this.angle)>o.autoHideMax?i.hide():(i.show(),o.showRealAngle&&(0<=(e=this.angle)&&-1===this.direction?e=-(2*Math.PI-Math.abs(e)):e<0&&-1===this.direction&&(e=2*Math.PI-Math.abs(e)),e=Math.abs(e),r=p(e,o.precision).toFixed(o.precision),"degrees"===o.units&&(r=(n=360===(n=p(180*e/Math.PI,o.precision))?0:n).toFixed(o.precision),r="".concat(r,"°")),o.setText(r)),t=Ee(this.angle,"-360to360"),i=Math.PI/2,t<0&&(i=-Math.PI/2),0<=t&&-1===this.direction?t=-(2*Math.PI-t):t<0&&-1===this.direction&&(t=2*Math.PI-Math.abs(t)),e=Ke(o.radius,t*o.curvePosition),"tangent"===(n=o.orientation)&&(n="baseToLine"),"outside"===(r=o.location)&&(r="negative",-1===this.direction&&(r="positive")),"inside"===r&&(r="positive",-1===this.direction&&(r="negative")),i=Ee(Ee(t,"0to360")*o.curvePosition+i,"0to360"),"start"===r&&(e=new Oe(o.radius,0),i=0),"end"===r&&(e=Ke(o.radius,t),i=Ee(t,"0to360")),o.updateRotation(e,i,o.offset,r,o.subLocation,n,null==this.lastLabelRotationOffset?0:this.lastLabelRotationOffset,"oval",!1,Math.PI/2,-Math.PI/2)))}},{key:"pulseAngle",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n={curve:this.pulseAngleDefaults.curve,label:this.pulseAngleDefaults.label,arrow:this.pulseAngleDefaults.arrow,corner:this.pulseAngleDefaults.corner,done:null,duration:this.pulseAngleDefaults.duration,frequency:this.pulseAngleDefaults.frequency,when:"nextFrame",thick:this.pulseAngleDefaults.thick},r=this.getPosition("figure"),i=ft(n,e),o=i.done;e=function(e,n,r,a){var s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;null!=(e=t.elements[e])&&e.isShown&&(r=ft({num:i.thick},1<i.thick?a:r),1<(n="number"==typeof i[n]?ft({},r,i,{scale:i[n],callback:o}):ft({},r,i,i[n],{callback:o})).num&&null==n.min&&(n.min=1/n.scale),null!=s&&(n.centerOn=s),e.pulse(n),o=null)},null!=this._curve&&e("curve","curve",{},{}),null!=this._curveRight&&e("curveRight","curve",{},{},this.getPosition("figure")),null!=this.corner&&null!=this._corner&&e("corner","corner",{centerOn:r},{centerOn:r,num:1}),e("label","label",{centerOn:r},{num:1}),null!=this.arrow&&(null!=this._arrow1&&e("arrow1","arrow",{centerOn:r},{centerOn:this._arrow1.getPosition("figure"),num:1}),null!=this._arrow2&&e("arrow2","arrow",{centerOn:r},{centerOn:this._arrow2.getPosition("figure"),num:1})),this.animateNextFrame()}},{key:"showAll",value:function(){Tf(Mf(n.prototype),"showAll",this).call(this),this.update()}},{key:"setMovable",value:function(t){var e={movable:!0,type:this.move.type,width:.5,movePadRadius:0,startArm:null,endArm:null},n=(i=!1===t?ft({},e,{movable:!1}):!0===t?e:ft({},e,t)).movable,r=(e=i.startArm,t=i.endArm,i.movePadRadius),i=i.width;n?(null!=e&&null!=t?("rotation"===e&&this.addRotPad(1-r,i,"rotation"),"rotation"===t&&this.addAnglePad(1-r,i,"rotation"),"angle"===e&&this.addRotPad(1-r,i,"angle"),"angle"===t&&this.addAnglePad(1-r,i,"angle")):null!=e?this.addRotPad(1-r,i,e):null!=t&&this.addAnglePad(1-r,i,t),0<r&&this.addMovePad(r)):(this.isMovable=!1,this.isTouchable=!1,null!=this._anglePad&&this._anglePad.setMovable(!1),null!=this._rotPad&&this._rotPad.setMovable(!1)),this.updateMovePads()}},{key:"getLength",value:function(){return null!=this.corner&&null!=this.corner.length?this.corner.length:null!=this.curve&&null!=this.curve.radius?this.curve.radius:null!=this.label&&null!=this.label.radius?this.label.radius:1}},{key:"addAnglePad",value:function(){var t,e,n=this,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,o=2<arguments.length?arguments[2]:void 0;null==this._anglePad&&(t=this.getLength(),e=this.collections.primitives.rectangle({offset:[t*(1-r),0],xAlign:"left",yAlign:"middle",width:t*r+i,height:i,color:[0,0,1,0],border:[[]],touchBorder:"buffer"}),this.add("anglePad",e),e.setMovable(),e.move.type="rotation",e.drawingObject.border=[[]],"rotation"===o?e.notifications.add("beforeSetTransform",(function(t){t=t[0].r()-e.getRotation(),n.transform.updateRotation(n.getRotation()+t),e.cancelSetTransform=!0})):e.notifications.add("setTransform",(function(){var t=e.getRotation();t=0<n.angle?Ee(t,"0to360"):Ee(t,"-360to0"),n.setAngle({angle:t})})))}},{key:"addRotPad",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.5,i=2<arguments.length?arguments[2]:void 0;null==this._rotPad&&(t=this.getLength(),n=this.collections.primitives.rectangle({xAlign:"left",yAlign:"middle",width:t*n+r,height:r,color:[1,0,1,0],offset:[t*(1-n),0],border:[[]],touchBorder:"buffer"}),this.add("rotPad",n),n.setMovable(),n.move.type="rotation",n.drawingObject.border=[[]],"angle"===i?(n.move.element=this).notifications.add("beforeSetTransform",(function(t){var n=t[0].r();t=e.getRotation(),t=e.angle-(n-t),t=0<e.angle?Ee(t,"0to360"):Ee(t,"-360to0"),e.setAngle({angle:t})})):n.move.element=this)}},{key:"addMovePad",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;null==this._movePad&&(t=this.getLength(),e=this.collections.primitives.polygon({radius:t*e,sides:8,fill:!0,color:[1,0,0,0],border:[[]],touchBorder:"buffer"}),this.add("movePad",e),e.setMovable(),e.move.type="translation",e.drawingObject.border=[[]],e.move.element=this)}},{key:"updateMovePads",value:function(){null!=this._anglePad&&this._anglePad.transform.updateRotation(this.angle)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(n.prototype,t),n}();function Rf(t){return(Rf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Bf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Ff(t,e,n){return(Ff="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Df(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function If(t,e){return(If=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Df(t){return(Df=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Lf(t,e,n,r){if(Array.isArray(t)){for(var i=[],o=0;o<r;o+=1){var a=t[o%t.length];null!=a.label?i.push(ft({},e,{label:n},a)):i.push(ft({},e,a))}return i}for(var s=[],l=0;l<r;l+=1)s.push("".concat(l));var u,c=ht({except:s},{},t),h=[];null!=c.label&&null!=c.label.text&&Array.isArray(c.label.text)&&(h=c.label.text),null===c.label&&(c.label={text:null}),u=null!=c.show?c.show:1<r?_(0,r-1,1):[0],null!=c.hide&&c.hide.forEach((function(t){-1!==(t=u.indexOf(t))&&u.splice(t,1)}));for(var f,d,p,m=[],y=0;y<r;y+=1)-1===u.indexOf(y)?m.push(null):(f=u.indexOf(y),d=u[f],p={},null!=t["".concat(d)]&&(p=t["".concat(d)]),d={},null!=(p=ft({},e,c,d=0<h.length?{label:{text:h[f%h.length]}}:d,p)).label?m.push(ft({},{label:n},p)):m.push(p));return m}var zf=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&If(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Df(e);return function(t,e){if(e&&("object"===Rf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Df(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e,n){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var a={color:t.primitives.defaultColor,points:[new Oe(1,0),new Oe(0,0),new Oe(0,1)],close:!1,showLine:!0,width:t.primitives.defaultLineWidth,reverse:!1,transform:(new Qe).scale(1,1).rotate(0).translate(0,0),makeValid:null};null!=o.makeValid&&null!=o.makeValid.shape&&"triangle"===o.makeValid.shape&&(a.makeValid={shape:"triangle",hide:{minAngle:null,maxAngle:null,minSide:null}});var s=ft({},a,o);return(a=r.call(this,s)).setColor(s.color),a.collections=t,a.largerTouchBorder=s.largerTouchBorder,a.isTouchDevice=e,a.animateNextFrame=n,a.updatePointsCallback=null,a.close=s.close,a.options=s,a.reverse=s.reverse,a.makeValid=s.makeValid,a.points=s.points.map(Ae),s.pad&&a.addPads(s.pad),s.angle&&a.addAngles(s.angle,s.close),s.showLine&&(o=a.collections.primitives.polyline({points:a.points,width:o.width,close:o.close,widthIs:o.widthIs,cornerStyle:o.cornerStyle,cornerSize:o.cornerSize,cornerSides:o.cornerSides,minAutoCornerAngle:o.minAutoCornerAngle,dash:o.dash,color:o.color,pulse:o.pulse,arrow:o.arrow,drawBorderBuffer:o.drawBorderBuffer,touchBorder:"buffer"}),a.add("line",o)),s.side&&a.addSides(s.side,s.close),a}return t=[{key:"addPads",value:function(t){for(var e=this,n={sides:20,radius:.1,color:this.color},r=this.points.length,i=Lf(t,n,{},r),o=0;o<r;o+=1)null!=i[o]&&function(){var t="pad".concat(o),n=ft({},{transform:(new Qe).translate(e.points[o])},i[o]),r=e.collections.primitives.polygon(n);r.isMovable&&(n="_polyline_pad".concat(o),r.fnMap.add(n,(function(t){var n=parseInt(r.name.slice(3),10);null!=(t=t.t())&&(e.points[n]=t._dup(),e.updatePoints(e.points))})),r.setTransformCallback=n),e.add(t,r)}()}},{key:"addAngles",value:function(t,e){var n={color:this.color,curve:{},autoRightAngle:!0},r=this.points.length;!1===e&&(r-=2);for(var i=Lf(t,n,{text:null,offset:.05},r),o=0;o<r;o+=1){var a,s,l=o,u=o+1,c=o===r-2&&e?0:o+2;o===r-1&&e&&(u=0,c=1),null!=i[o]&&(a="angle".concat(o),this.reverse&&(s=c,c=l,l=s),c=ft({},{p1:this.points[l],p2:this.points[u],p3:this.points[c]},i[o]),c=this.collections.angle(c),this.add(a,c))}}},{key:"addSides",value:function(t,e){var n={showLine:!1,offset:0,width:0,color:this.color},r=this.points.length-1;e&&(r+=1);for(var i=Lf(t,n,{offset:.1,text:null,location:"outside",subLocation:"top",orientation:"horizontal",linePosition:.5,scale:.7},r),o=0;o<r;o+=1){var a,s,l=o===r-1&&e?0:o+1;null!=i[o]&&(a="side".concat(o).concat(l),s=ft({},{p1:this.points[o],p2:this.points[l]},i[o]),this.reverse&&(s=ft({},{p1:this.points[l],p2:this.points[o]},i[o])),(l=this.collections.line(s))._custom.offset=s.offset,this.add(a,l))}}},{key:"_getStateProperties",value:function(t){return[].concat(function(t){if(Array.isArray(t))return Bf(t)}(e=Ff(Df(i.prototype),"_getStateProperties",this).call(this,t))||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(t){if(t){if("string"==typeof t)return Bf(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Bf(t,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),["points"]);var e}},{key:"_fromState",value:function(t){return ft(this,t),this.updatePoints(this.points),this}},{key:"updateSideLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(null!=this.options.side){var e=this.points.length-1;this.close&&(e+=1);for(var n=0;n<e;n+=1){var r=n+1;n===e-1&&this.close&&(r=0);var i="side".concat(n).concat(r);null!=this.elements[i]&&(r=!this.elements[i].isShown,this.elements[i].updateLabel(t),r&&this.elements[i].hide())}}}},{key:"updateAngleLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(null!=this.options.angle){var e=this.points.length;!1===this.close&&(e-=2);for(var n=0,r=n=!1===this.close?1:n;r<e+n;r+=1){var i,o="angle".concat(r);null!=this.elements[o]&&(i=!this.elements[o].isShown,this.elements[o].updateLabel(t),i&&this.elements[o].hide())}}}},{key:"updatePoints",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=t.map(Ae);null!=this._line&&this._line.custom.updatePoints({points:n});var r=this.points.length;if(this.options.pad)for(var i=0;i<r;i+=1){var o="pad".concat(i);this.elements[o]&&this.elements[o].transform.updateTranslation(n[i])}if(null!=this.options.side){r=this.points.length-1,this.close&&(r+=1);for(var a=0;a<r;a+=1){var s=a+1;a===r-1&&this.close&&(s=0);var l="side".concat(a).concat(s);null!=this.elements[l]&&(this.reverse?this.elements[l].setEndPoints(n[s],n[a],this.elements[l]._custom.offset):this.elements[l].setEndPoints(n[a],n[s],this.elements[l]._custom.offset))}}this.points=n,this.updateAngles(),null==this.makeValid||"triangle"!==this.makeValid.shape||e||this.makeValidTriangle(),null==this.updatePointsCallback||e||(this.fnMap.exec(this.updatePointsCallback),this.notifications.publish("updatePoints"))}},{key:"updateAngles",value:function(){if(null!=this.options.angle){var t=this.points.length;!1===this.close&&(t-=2);for(var e=0;e<t;e+=1){var n=e,r=e+1,i=e+2;e===t-2&&this.close&&(i=0),e===t-1&&this.close&&(r=0,i=1);var o,a="angle".concat(e);null!=this.elements[a]&&(this.reverse&&(o=i,i=n,n=o),this.elements[a].setAngle({p1:this.points[n],p2:this.points[r],p3:this.points[i]}))}}}},{key:"updateRotation",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=this["_angle".concat(n=0)];null!=e;)e.update(this.getRotation()+t),e=this["_angle".concat(n+=1)];for(var n,r=this["_side".concat(n=0).concat(n+1)];null!=r;)r.updateLabel(this.getRotation()+t),r=this["_side".concat(n+=1).concat(n+1)];null!=(r=this["_side".concat(n,0)])&&r.updateLabel(this.getRotation()+t)}},{key:"reversePoints",value:function(){for(var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],e=[],n=0;n<this.points.length;n+=1)e.push(this.points[this.points.length-1-n]);this.updatePoints(e,t)}},{key:"setPositionWithoutMoving",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=new Oe(0,0);"number"==typeof t?(n.x=t,n.y=e):n=t;var r=this.getPosition().sub(n);this.setPosition(n),n=this.points.map((function(t){return t.add(r)})),this.updatePoints(n)}},{key:"setRotationWithoutMoving",value:function(t){var e=this.getRotation()-t,n=(new Qe).rotate(e).m();this.setRotation(t),t=this.points.map((function(t){return t.transformBy(n)})),this.updatePoints(t)}},{key:"setScaleWithoutMoving",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=new Oe(0,0);"number"==typeof t?(n.x=t,n.y=e):n=t,t=this.getScale(),t=new Oe(t.x/n.x,t.y/n.y);var r=(new Qe).scale(t).m();this.setScale(n),n=this.points.map((function(t){return t.transformBy(r)})),this.updatePoints(n)}},{key:"setShow",value:function(t,e){for(var n=0;n<this.drawOrder.length;n+=1){var r=this.elements[this.drawOrder[n]];r.name.startsWith(t)&&(e?r.showAll():r.hide())}}},{key:"hideAngles",value:function(){this.setShow("angle",!1)}},{key:"hideSides",value:function(){this.setShow("side",!1)}},{key:"showAngles",value:function(){this.setShow("angle",!0)}},{key:"showSides",value:function(){this.setShow("side",!0)}},{key:"updateLabels",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.getRotation();this.updateAngleLabels(t),this.updateSideLabels(t)}},{key:"makeValidTriangle",value:function(){var t=this._angle0,e=this._angle1,n=this._angle2,r=this._side01,i=this._side12,o=this._side20,a=t.label.precision,s=r.label.precision,l=180*Ee(t.getAngle(),"0to360")/Math.PI,u=180*Ee(e.getAngle(),"0to360")/Math.PI,c=180*Ee(n.getAngle(),"0to360")/Math.PI,h=m(l,a),f=m(u,a),d=m(c,a),p=m(r.getLength(),s),y=m(i.getLength(),s),v=m(o.getLength(),s);90<h&&90<f&&90<d&&(this.reverse=!this.reverse,this.updatePoints(this.points,!1),h=m(180*Ee(t.getAngle(),"0to360")/Math.PI,a),f=m(180*Ee(e.getAngle(),"0to360")/Math.PI,a),d=m(180*Ee(n.getAngle(),"0to360")/Math.PI,a));var g,b=(h=180<h?360-t:h)+(f=180<f?360-e:f)+(d=180<d?360-n:d),w=b-180;l=[m(l,a+1),m(u,a+1),m(c,a+1)].map((function(t){return t-Math.floor(t*Math.pow(10,a))/Math.pow(10,a)})),u=[h,f,d],c=0,180<b?c=l.reduce((function(t,e,n,r){return e>r[t]?n:t}),0):b<180&&(c=l.reduce((function(t,e,n,r){return e<r[t]?n:t}),1)),u[c]-=w,h=u[0],f=u[1],d=u[2],t.setLabel("".concat(h.toFixed(a),"º")),e.setLabel("".concat(f.toFixed(a),"º")),n.setLabel("".concat(d.toFixed(a),"º")),t.checkLabelForRightAngle(),e.checkLabelForRightAngle(),n.checkLabelForRightAngle(),null!=this.makeValid&&(t=this.makeValid.hide.minSide,e=(g=this.makeValid.hide).minAngle,n=g.maxAngle,g=!1,null!=e&&(h<(e*=180/Math.PI)||f<e||d<e)&&(g=!0),null!=n&&((n*=180/Math.PI)<h||n<f||n<d)&&(g=!0),(g=null!=t&&(p<t||y<t||v<t)||g)&&this.hideAngles()),(r.isShown||i.isShown||o.isShown)&&0<h&&h<180&&0<f&&f<180&&0<d&&d<180&&(g=1/Math.pow(10,s),60===h&&60===f&&60===d?v=y=p:h===f?p===(v=y)&&(m(r.getLength(),s+1)<p?p-=g:p+=g):h===d?v===(p=y)&&(m(o.getLength(),s+1)<v?v-=g:v+=g):f===d&&y===(v=p)&&(m(i.getLength(),s+1)<y?y-=g:y+=g)),r.setLabel("".concat(p.toFixed(s))),i.setLabel("".concat(y.toFixed(s))),o.setLabel("".concat(v.toFixed(s)))}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Wf(t){return(Wf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Nf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function qf(t,e){return(qf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Hf(t){return(Hf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Uf=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&qf(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Hf(e);return function(t,e){if(e&&("object"===Wf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Hf(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n,o,a,s,l={length:t.primitives.defaultLength,angle:0,start:0,color:t.primitives.defaultColor,font:t.primitives.defaultFont,name:"",line:{},show:!0,axis:"x",transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},u=ft({},l,e);return(s=r.call(this,u)).collections=t,(s.autoStep=null)!=e.auto&&(n=(a=s.calcAuto(e.auto)).start,o=a.stop,t=a.step,a=a.precision,l.start=n,l.stop=o,l.ticks={},l.labels={precision:a},s.autoStep=t),(null==(u=ft({},l,e)).stop||u.stop<=u.start)&&(u.stop=u.start+1),s.name=u.name,s.defaultFont=u.font,null!=e.font&&null!=e.font.color||(s.defaultFont.color=u.color),s.showAxis=u.show,s.startValue=u.start,s.stopValue=u.stop,s.startValue>=s.stopValue&&(s.startValue=s.stopValue-1),s.length=u.length,s.axis=u.axis,s.angle="x"===s.axis?0:Math.PI/2,s.drawToValueRatio=(u.stop-u.start)/u.length,s.valueToDrawRatio=1/s.drawToValueRatio,null!=u.ticks&&void 0===u.labels&&(u.labels={}),s.setColor(u.color),s.ticks=[],s.grid=[],s.labels=[],s.showAxis&&null!=u.line&&!1!==u.line&&s.addLine(u.line),s.showAxis&&null!=u.ticks&&!1!==u.ticks&&s.addTicks(u.ticks,"ticks"),s.showAxis&&null!=u.labels&&!1!==u.labels&&s.addLabels(u.labels),s.showAxis&&null!=u.title&&s.addTitle(u.title),s.showAxis&&null!=u.grid&&!1!==u.grid&&s.addTicks(u.grid,"grid"),s.reorder(),s}return t=[{key:"addLine",value:function(t){var e=t;t=ft({},{length:this.length,angle:this.angle,width:this.collections.primitives.defaultLineWidth,color:this.color},e=!0===t?{}:e),e=this.collections.primitives.line(t),this.line=t,this.add("line",e)}},{key:"reorder",value:function(){var t=[],e=[],n=[];this.drawOrder.forEach((function(r){r.startsWith("grid")&&t.push(r),r.startsWith("tick")&&e.push(r),r.startsWith("line")&&n.push(r)})),e=e.reverse(),t=t.reverse(),this.toBack(e),this.toBack(n),this.toBack(t)}},{key:"processTicks",value:function(t,e,n){var r,i,o=this.startValue,a=this.stopValue;return null!=e.start&&(o=e.start),null!=e.stop&&(a=e.stop),null!=e.step&&(r=e.step),null!=e.values&&(i=e.values),"grid"===t&&this.ticks.length>=n+1&&(null==e.start&&(o=this.ticks[n].start),null==e.stop&&(a=this.ticks[n].stop),null==e.step&&(r=this.ticks[n].step),null==e.values&&(i=this.ticks[n].values)),null==r&&null!=this.autoStep&&this.autoStep<(a-o)/2?r=this.autoStep:null==r&&0===n?r=(a-o)/5:null==r&&(r=this[t].step/2),{start:o,stop:a,step:r,values:i}}},{key:"addTicks",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"ticks",r=t;!0===t&&(r={});var i={width:null!=this.line?this.line.width:this.collections.primitives.defaultLineWidth,length:"ticks"===n?10*this.collections.primitives.defaultLineWidth:50*this.collections.primitives.defaultLineWidth,angle:this.angle+Math.PI/2,color:this.color};r=Array.isArray(r)?r:[r],this[n]=[];var o=[],a="x"===this.axis?1:-1;r.forEach((function(t,r){var s=ft({},i,t),l=(u=e.processTicks(n,s,r)).start,u=(t=u.stop,r=u.step,u.values);s.start=l,s.stop=t,s.step=r,s.length*=a,null==s.offset&&"ticks"===n?s.offset="x"===e.axis?-s.length/2:s.length/2:null==s.offset&&"grid"===n&&(c=e.transform.t()||new Oe(0,0),"x"===e.axis?s.offset=-c.y:s.offset=-c.x);var c=Math.floor((s.stop+s.step/1e4-s.start)/s.step);s.num=c,s.values=null==u?_(s.start,s.stop,s.step):u,"x"===e.axis?s.copy=[{to:s.values.map((function(t){return new Oe(e.valueToDraw(t),0)}))}]:s.copy=[{to:s.values.map((function(t){return new Oe(0,e.valueToDraw(t))}))}],s.copy[0].original=!1,null==s.p1&&(s.p1=new Oe(0,s.offset*a).rotate(e.angle)),u=e.collections.primitives.line(s),o.push(u),e[n].push(s)})),o.reverse(),o.forEach((function(t,r){e.add("".concat(n).concat(r),t)}))}},{key:"addTitle",value:function(t){var e={font:ft({},this.defaultFont,{size:this.defaultFont.size||.13}),justify:"center",xAlign:"center",yAlign:"x"===this.axis?"top":"bottom",rotation:"x"===this.axis?0:Math.PI/2,offset:[0,0]};(e=ft({},e,"string"==typeof t?{text:[t]}:t)).offset=Ae(e.offset),t=this.getBoundingRect("draw"),null==e.position&&("x"===this.axis?e.position=new Oe(this.length/2,t.bottom-e.font.size/1.5).add(e.offset):e.position=new Oe(t.left-e.font.size/1.5,this.length/2).add(e.offset)),(t=this.collections.primitives.textLines(e)).transform.updateRotation(e.rotation),this.add("title",t)}},{key:"addLabels",value:function(t){var e=this,n=t;!0===t&&(n={});var r={text:null,precision:1,values:null,format:"decimal",font:this.defaultFont,xAlign:"x"===this.axis?"center":"right",yAlign:"x"===this.axis?"baseline":"middle",rotation:0,offset:[0,0]};n=Array.isArray(n)?n:[n],this.labels=[];var i=this.getBoundingRect("draw");n.forEach((function(t,n){var o=ft({},r,t);"number"==typeof o.hide&&(o.hide=[o.hide]),"number"==typeof o.values&&(o.values=[o.values]),o.offset=Ae(o.offset),"string"==typeof o.text&&(o.text=[o.text]);var a=[];null==(a=(null==o.values&&0<e.ticks.length?e.ticks[n]:o).values)&&(a=[]),null==o.text&&(o.text=[],o.text=Array(a.length).map((function(){return null}))),null==o.space&&(o.space="x"===e.axis?o.font.size+5*e.collections.primitives.defaultLineWidth:10*e.collections.primitives.defaultLineWidth);for(var s=[],l=0;l<a.length;l+=1){var u=e.valueToDraw(a[l]),c=("x"===e.axis?new Oe(u+o.offset.x,i.bottom-o.space+o.offset.y):new Oe(i.left+o.offset.x-o.space,u+o.offset.y)).rotate(-o.rotation);(null==o.hide||null!=o.hide&&-1===o.hide.indexOf(l))&&("number"==typeof(u=null==(u=o.text[l])?a[l]:u)&&(u="decimal"===o.format?"".concat(m(u,o.precision).toFixed(o.precision)):"".concat(u.toExponential(o.precision))),s.push({text:u,location:c}))}o.text=s,(t=e.collections.primitives.text(o)).transform.updateRotation(o.rotation),e.add("labels".concat(n),t),e.labels.push(o)}))}},{key:"calcAuto",value:function(t){var e=(r=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(n,r)||function(t,e){if(t){if("string"==typeof t)return Nf(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nf(t,e):void 0}}(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=e[0],r=e[1];0===(e=(t=r-n)<1?Math.floor(Math.log10(t)):1<=t&&t<3?Math.floor(Math.log10(t/3)):Math.ceil(Math.log10(t)))&&(e=1),t=Math.pow(10,e-1),n=Math.floor(n/t)*t;var i,o=(r=Math.ceil(r/t)*t)-n;switch(m(o/t)){case 3:case 6:i=o/3;break;case 4:case 8:i=o/4;break;case 7:i=o/7;break;case 9:i=o/3;break;default:i=o/5}return e<(t=0)&&(t=Math.abs(e)+1),{start:m(n),stop:m(r),step:m(i),precision:m(t)}}},{key:"valueToDraw",value:function(t){var e=this;return"number"==typeof t?(t-this.startValue)*this.valueToDrawRatio:t.map((function(t){return(t-e.startValue)*e.valueToDrawRatio}))}},{key:"drawToValue",value:function(t){var e=this;return"number"==typeof t?t*this.drawToValueRatio+this.startValue:t.map((function(t){return t*e.drawToValueRatio+e.startValue}))}},{key:"inAxis",value:function(t){return!((t=m(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:8))<this.startValue||t>this.stopValue)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Kf(t){return(Kf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Vf(t,e){return(Vf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Gf(t){return(Gf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Yf=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Vf(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Gf(e);return function(t,e){if(e&&("object"===Kf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Gf(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n=ft({},{width:t.primitives.defaultLength/50,length:t.primitives.defaultLength/2,start:0,color:[[1,0,0,1],[0,1,0,1],[0,0,1,1]],sides:10,transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},e);return null==n.fill&&null==n.line&&(n.fill=t.primitives.defaultColor.slice()),(e=r.call(this,ft({},n,{color:[1,0,0,1]}))).collections=t,e.x={width:Array.isArray(n.width)?n.width[0]:n.width,length:Array.isArray(n.length)?n.length[0]:n.length,color:Array.isArray(n.color[0])?n.color[0]:n.color,start:Array.isArray(n.start)?n.start[0]:n.start,arrow:Array.isArray(n.arrow)?n.arrow[0]:n.arrow,sides:Array.isArray(n.sides)?n.sides[0]:n.sides,lines:Array.isArray(n.lines)?n.lines[0]:n.lines},e.y={width:Array.isArray(n.width)?n.width[1]:n.width,length:Array.isArray(n.length)?n.length[1]:n.length,color:Array.isArray(n.color[1])?n.color[1]:n.color,start:Array.isArray(n.start)?n.start[1]:n.start,arrow:Array.isArray(n.arrow)?n.arrow[1]:n.arrow,sides:Array.isArray(n.sides)?n.sides[1]:n.sides,lines:Array.isArray(n.lines)?n.lines[1]:n.lines},e.z={width:Array.isArray(n.width)?n.width[2]:n.width,length:Array.isArray(n.length)?n.length[2]:n.length,color:Array.isArray(n.color[2])?n.color[2]:n.color,start:Array.isArray(n.start)?n.start[2]:n.start,arrow:Array.isArray(n.arrow)?n.arrow[2]:n.arrow,sides:Array.isArray(n.sides)?n.sides[2]:n.sides,lines:Array.isArray(n.lines)?n.lines[2]:n.lines},e._x=null,e._y=null,e._z=null,e.addAxis("x"),e.addAxis("y"),e.addAxis("z"),e}return t=[{key:"addAxis",value:function(t){var e,n,r=this["".concat(t)];0!==r.width&&("x"===t&&(e=[r.start,0,0],n=[r.start+r.length,0,0]),"y"===t&&(e=[0,r.start,0],n=[0,r.start+r.length,0]),"z"===t&&(e=[0,0,r.start],n=[0,0,r.start+r.length]),r=this.collections.primitives.line3({width:r.width,arrow:r.arrow,p1:e,p2:n,color:r.color.slice(),sides:r.sides,lines:r.lines}),this.add(t,r))}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Xf(t){return(Xf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function $f(t){return function(t){if(Array.isArray(t))return Jf(t)}(t)||function(){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}()||function(t){if(t){if("string"==typeof t)return Jf(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Jf(t,void 0):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jf(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Zf(t,e,n){return(Zf="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=td(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Qf(t,e){return(Qf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function td(t){return(td=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const ed=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Qf(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=td(e);return function(t,e){if(e&&("object"===Xf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=td(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n=ft({},{color:t.primitives.defaultColor,font:{family:"Times New Roman",size:.1,style:"normal",weight:"normal",color:t.primitives.defaultColor,opacity:1},name:"",transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},e);return null==n.markers&&void 0===n.line&&(n.line={}),(e=r.call(this,n)).collections=t,e.defaultFont=n.font,e.points=ke(n.points),e.xAxis=n.xAxis,e.yAxis=n.yAxis,e.name=n.name,e.setColor(n.color),null==n.xSampleDistance&&(n.xSampleDistance=(e.xAxis.stopValue-e.xAxis.startValue)/4e3),null==n.ySampleDistance&&(n.ySampleDistance=(e.yAxis.stopValue-e.yAxis.startValue)/4e3),e.xSampleDistance=n.xSampleDistance,e.ySampleDistance=n.ySampleDistance,null!=n.line&&e.addLine(n.line),null!=n.markers&&e.addMarkers(n.markers),e}return t=[{key:"update",value:function(t){this.removeLine(),this.removeMarkers(),this.points=ke(t),null!=this.line&&this.addLine(this.line),null!=this.markers&&(this.markers.copy=[],this.addMarkers(this.markers))}},{key:"getY",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=[],r=Math.abs(t-this.points[0].x),i=0,o=0;o<this.points.length;o+=1){var a=this.points[o].x;(a=Math.abs(a-t))<r&&(i=o,r=a),0===m(a,e)&&n.push(this.points[o].y)}return 0===n.length&&n.push(this.points[i].y),n}},{key:"getX",value:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8,n=[],r=Math.abs(t-this.points[0].y),i=0,o=0;o<this.points.length;o+=1){var a=this.points[o].y;(a=Math.abs(a-t))<r&&(i=o,r=a),0===m(a,e)&&n.push(this.points[o].x)}return 0===n.length&&n.push(this.points[i].x),n}},{key:"pointToDraw",value:function(t){return new Oe(this.xAxis.valueToDraw(t.x),this.yAxis.valueToDraw(t.y))}},{key:"inAxes",value:function(t){return!(!this.xAxis.inAxis(t.x)||!this.yAxis.inAxis(t.y))}},{key:"intersect",value:function(t,e){if(t.x<0&&e.x<0)return{result:!1};if(t.y<0&&e.y<0)return{result:!1};if(t.x>this.xAxis.length&&e.x>this.xAxis.length)return{result:!1};if(t.y>this.yAxis.length&&e.y>this.yAxis.length)return{result:!1};var n=new Ie(t,e),r=!1,i=[];return[new Ie([0,0],[0,this.yAxis.length]),new Ie([this.xAxis.length,0],[this.xAxis.length,this.yAxis.length]),new Ie([0,0],[this.xAxis.length,0]),new Ie([0,this.yAxis.length],[this.xAxis.length,this.yAxis.length])].forEach((function(t){(t=n.intersectsWith(t)).onLines&&(r=!0,i.push(t.intersect))})),{result:r,intersect:i}}},{key:"updatePoints",value:function(){this.polylines=[];var t,e=!(this.drawPoints=[]);null!=this.xSampleDistance&&null!=this.ySampleDistance&&(e=!0);for(var n=[],r=0;r<this.points.length;r+=1)(!e||null==t||Math.abs(this.points[r].x-t.x)>=this.xSampleDistance||Math.abs(this.points[r].y-t.y)>=this.ySampleDistance)&&(this.drawPoints.push(this.pointToDraw(this.points[r])),t=this.points[r],n.push(r));for(var i=[],o=[],a=0;a<n.length;a+=1)i.push(this.xAxis.inAxis(this.points[n[a]].x)),o.push(this.yAxis.inAxis(this.points[n[a]].y));for(var s,l,u=!1,c=[],h=0;h<this.drawPoints.length;h+=1)i[h]&&o[h]&&(u=!0,c.push(this.drawPoints[h])),u&&h===this.drawPoints.length-1?(this.polylines.push(c),c=[]):u&&i[h+1]&&o[h+1]||(!u||!1!==i[h+1]&&!1!==o[h+1]?!1===u&&i[h+1]&&o[h+1]?(s=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&c.push.apply(c,$f(s.intersect)):!1===u&&h<this.drawPoints.length-1&&(l=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&this.polylines.push(l.intersect.map((function(t){return t._dup()}))):((l=this.intersect(this.drawPoints[h],this.drawPoints[h+1])).result&&c.push.apply(c,$f(l.intersect)),this.polylines.push(c),u=!(c=[])))}},{key:"addLine",value:function(t){var e=this,n={color:this.color,width:this.collections.primitives.defaultLineWidth};this.updatePoints(),this.line=ft({},n,t),this.polylines.forEach((function(t,n){t=e.collections.primitives.polyline(ft({},e.line,{points:t})),e.add("line".concat(n),t)}))}},{key:"removeLine",value:function(){var t=this;this.drawOrder.filter((function(t){return t.startsWith("line")})).forEach((function(e){t.remove(e)}))}},{key:"removeMarkers",value:function(){var t=this;this.drawOrder.filter((function(t){return t.startsWith("markers")})).forEach((function(e){t.remove(e)}))}},{key:"addMarkers",value:function(t){var e=this,n={radius:.02,color:this.color},r=this.points.filter((function(t){return e.inAxes(t)}));t=ft({},n,t),this.markers=t,0!==r.length&&(null==t.copy?t.copy=[]:!1===Array.isArray(t.copy)&&(t.copy=[t.copy]),t.copy.push({to:r.map((function(t){return e.pointToDraw(t)})),original:!1}),this.add("markers",this.collections.primitives.polygon(t)))}},{key:"_getStateProperties",value:function(t){return $f(Zf(td(i.prototype),"_getStateProperties",this).call(this,t))}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function nd(t){return(nd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function rd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function id(t,e){return(id=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function od(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ad(t){return(ad=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const sd=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&id(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=ad(e);return function(t,e){if(e&&("object"===nd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return od(t)}(this,n?(t=ad(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n={font:t.primitives.defaultFont,color:t.primitives.defaultColor,theme:"classic",width:(t.primitives.scene.right-t.primitives.scene.left)/3,height:(t.primitives.scene.right-t.primitives.scene.left)/3,grid:[],xAlign:"plotAreaLeft",yAlign:"plotAreaBottom",transform:(new Qe).scale(1,1).rotate(0).translate(0,0),touchBorder:"rect"};null!=e.color&&(null==e.font||null!=e.font&&null==e.font.color)&&(n.font.color=e.color);var o,a=ft({},n,e);return null==a.stop&&(a.stop=a.start+1),(n=r.call(this,a)).collections=t,n.defaultFont=a.font,n.defaultColor=a.color,n.width=a.width,n.height=a.height,n.theme=a.theme,n.grid=a.grid,!(n.xAxisShow=!0)===a.xAxis&&(n.xAxisShow=!1),!(n.yAxisShow=!0)===a.yAxis&&(n.yAxisShow=!1),null!=e.font&&null!=e.font.size||(n.defaultFont.size=Math.min(n.width,n.height)/20),n.setColor(a.color),n.axes=[],n.traces=[],e=(t=function(t){if(Array.isArray(t))return t}(o=function(t){var e=[];Array.isArray(t)?0===t.length?e=[]:Te(t[0])?e=[{points:t}]:t.forEach((function(t){Array.isArray(t)?e.push({points:t}):e.push(t)})):e=[t];var n=!0,r={min:new Oe(0,0),max:new Oe(0,0)};return e.forEach((function(t){for(var e=0;e<t.points.length;e+=1){var i=Ae(t.points[e]);r=ur(i,r.min,r.max,n),n=!1}})),t=new En(r.min.x,r.min.y,r.max.x-r.min.x,r.max.y-r.min.y),[e,t]}(a.trace))||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,r,i=[],o=!0,a=!1;try{for(e=e.call(t);!(o=(n=e.next()).done)&&(i.push(n.value),2!==i.length);o=!0);}catch(t){a=!0,r=t}finally{try{o||null==e.return||e.return()}finally{if(a)throw r}}return i}}(o)||function(t){if(t){if("string"==typeof t)return rd(t,2);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?rd(t,2):void 0}}(o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],t=t[1],null!=a.frame&&!1!==a.frame&&n.addFrame(a.frame),null!=a.plotArea&&!1!==a.plotArea&&n.addPlotArea(a.plotArea),n.addAxes([ft({},{axis:"x",name:"x",auto:[t.left,t.right]},null!=a.xAxis?a.xAxis:{})]),n.addAxes([ft({},{axis:"y",name:"y",auto:[t.bottom,t.top]},null!=a.yAxis?a.yAxis:{})]),null!=a.axes&&n.addAxes(a.axes),null!=a.trace&&n.addTraces(e),null!=a.title&&n.addTitle(a.title),null!=a.legend&&!1!==a.legend&&n.addLegend(a.legend),null!=n.__frame&&null!=n.frameSpace&&n.__frame.surround(od(n),n.frameSpace,!0),n}return t=[{key:"getNonTraceBoundingRect",value:function(){var t=[];return Object.keys(this.elements).forEach((function(e){e.startsWith("trace")||t.push(e)})),this.getBoundingRect("draw","border",t)}},{key:"addAxes",value:function(t){var e=this,n={color:this.defaultColor,font:this.defaultFont,type:"x"};t.forEach((function(t){null!=t.axis?i=t.axis:null!=n.axis&&(i=n.axis),n.length="x"===i?e.width:e.height;var r=e.getTheme(e.theme,i,t.color),i="x"===i?e.xAxisShow:e.yAxisShow;n.show=i;var o=ft({},n,r.axis,t);if(Array.isArray(o.grid))for(var a=0;a<o.grid.length;a+=1)o.grid[a]=ft({},r.axis.grid,o.grid[a]);if(Array.isArray(o.ticks))for(var s=0;s<o.ticks.length;s+=1)o.ticks[s]=ft({},r.axis.ticks,o.ticks[s]);null==o.name&&(o.name="axis_".concat(e.axes.length)),t=e.collections.axis(o),e.add(o.name,t),e.axes.push(t)}))}},{key:"addPlotArea",value:function(t){var e={width:this.width,height:this.height,xAlign:"left",yAlign:"bottom",position:[0,0]};t=Array.isArray(t)?(e.fill=t,e):ft({},e,t),this.add("_plotArea",this.collections.rectangle(t))}},{key:"addFrame",value:function(t){var e={width:this.width/2,height:this.height/2,xAlign:"left",yAlign:"bottom",position:[0,0],space:Math.min(this.width,this.height)/20};!0===t?t={line:{width:this.collections.primitives.defaultLineWidth}}:Array.isArray(t)&&(t={fill:t}),t=ft({},e,t),this.frameSpace=t.space,this.add("_frame",this.collections.rectangle(t))}},{key:"getTraceIndex",value:function(t){if("number"==typeof t)return t;for(var e=0;e<this.traces.length;e+=1)if(t===this.traces[e].name)return e;return-1}},{key:"addLegend",value:function(t){t=!0===t?{}:t,t=ft({},{traces:this.traces,lineTextSpace:this.width/50,length:this.width/10,position:[this.width+this.width/20,this.height]},this.getTheme(this.theme).legend,t),t=this.collections.plotLegend(t),this.add("_legend",t)}},{key:"getAxis",value:function(t){for(var e=0;e<this.axes.length;e+=1)if(this.axes[e].name===t)return this.axes[e];return null}},{key:"getXAxis",value:function(){for(var t=0;t<this.axes.length;t+=1)if("x"===this.axes[t].axis)return this.axes[t];return null}},{key:"getYAxis",value:function(){for(var t=0;t<this.axes.length;t+=1)if("y"===this.axes[t].axis)return this.axes[t];return null}},{key:"pointToDraw",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"y";return e=this.getAxis(e),n=this.getAxis(n),null==e||null==n?null:(t=Ae(t),new Oe(e.valueToDraw(t.x),n.valueToDraw(t.y)))}},{key:"drawToPoint",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"y";return e=this.getAxis(e),n=this.getAxis(n),null==e||null==n?null:(t=Ae(t),new Oe(e.drawToValue(t.x),n.drawToValue(t.y)))}},{key:"addTraces",value:function(t){var e=this,n=this.getTheme(this.theme);t.forEach((function(t,r){null==(t=ft({},{xAxis:"x",yAxis:"y",color:n.traceColors[r%n.traceColors.length]},t)).name&&(t.name="trace_".concat(r)),t.xAxis=e.getAxis(t.xAxis),t.yAxis=e.getAxis(t.yAxis),r=e.collections.trace(t),e.add(t.name,r),e.traces.push(r)}))}},{key:"getTheme",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"x",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r="x"===e?this.width:this.height,i="x"===e?this.height:this.width,o={};return"classic"===t&&(e=null==n?[.35,.35,.35,1]:n,t=Math.min(this.width,this.height)/30,n=this.collections.primitives.defaultLineWidth,o={axis:{color:e,line:{width:this.collections.primitives.defaultLineWidth},ticks:{width:this.collections.primitives.defaultLineWidth,length:t,offset:-t},font:{color:e},length:r,grid:{color:e,width:this.collections.primitives.defaultLineWidth/2,length:i,dash:[n,n]}},title:{font:{color:e}},legend:{color:e,font:{color:e}},traceColors:[[0,0,1,1],[1,0,0,1],[0,.7,0,1],[.8,.8,.2,1],[.2,.8,.8,1],[.8,.2,.8,1]]}),null!=o.axis&&null!=o.axis.grid&&(!1===this.grid?delete o.axis.grid:"object"!==nd(this.grid)&&!Array.isArray(this.grid)||(o.axis.grid=ft({},o.axis.grid,this.grid))),o}},{key:"addTitle",value:function(t){var e={font:ft({},this.defaultFont,{size:1.5*this.defaultFont.size}),justify:"center",xAlign:"center",yAlign:"bottom",offset:[0,0]};t="string"==typeof t?{text:[t]}:t,(e=ft({},e,this.getTheme(this.theme).title,t)).offset=Ae(e.offset),t=this.getNonTraceBoundingRect(),null==e.position&&(e.position=new Oe(this.width/2+e.offset.x,t.top+.5*e.font.size+e.offset.y)),e=this.collections.primitives.textLines(e),this.add("title",e)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function ld(t){return(ld="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ud(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function cd(t,e){return(cd=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function hd(t){return(hd=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const fd=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&cd(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=hd(e);return function(t,e){if(e&&("object"===ld(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=hd(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n=ft({},{font:t.primitives.defaultFont,color:t.primitives.defaultColor,fontColorIsLineColor:!1,frame:!1,custom:{},length:t.primitives.defaultLength/10,space:.05,position:new Oe(0,0),transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},e);return(e=r.call(this,n)).setPosition(0,0),e.collections=t,e.defaultFont=n.font,e.defaultColor=n.color,e.traces=n.traces,e.toShow=e.getTracesToShow(n),e.offset=e.getOffset(n),e.addTraces(n),null!=n.frame&&!1!==n.frame&&(e.addFrame(n.frame),e.toBack("frame")),e}return t=[{key:"getTraceIndex",value:function(t){if("number"==typeof t)return t;for(var e=0;e<this.traces.length;e+=1)if(t===this.traces[e].name)return e;return-1}},{key:"getTracesToShow",value:function(t){var e,n,r=this,i=function(t){if(Array.isArray(t))return ud(t)}(n=Array(this.traces.length).keys())||function(){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}()||function(t){if(t){if("string"==typeof t)return ud(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(e="Object"===e&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ud(t,void 0):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();return t.show&&(i=[],(e="number"==typeof(e=t.show)?[e]:e).forEach((function(t){-1!==(t=r.getTraceIndex(t))&&i.push(t)}))),t.hide&&(t="number"==typeof(t=t.hide)?[t]:t).forEach((function(t){-1!==(t=r.getTraceIndex(t))&&-1!==i.indexOf(t)&&i.splice(t,1)})),i}},{key:"getOffset",value:function(t){for(var e=[],n=ke(n=null==(n=t.offset)?[new Oe(0,1.5*-this.defaultFont.size)]:n),r=0;r<this.toShow.length;r+=1)e.push(n[r%n.length]._dup());return e}},{key:"addTraces",value:function(t){var e=this,n=new Oe(0,0);this.toShow.forEach((function(r,i){var o=e.traces[r],a={};null!=t.custom["".concat(i)]?a=t.custom["".concat(i)]:null!=t.custom[o.name]&&(a=t.custom[o.name]),0===i&&null==a.position&&(a.position=Ae(t.position||[0,0]));var s=ft({},{length:t.length,font:t.font,fontColorIsLineColor:t.fontColorIsLineColor,offset:e.offset[i],space:t.space,text:o.name},a);n=null!=s.position?Ae(s.position):n.add(Ae(s.offset)),0<s.length&&null!=o.line&&(i=ft({},o.line,{p1:n,length:s.length,angle:0}),i=e.collections.primitives.line(i),e.add("line".concat(r),i)),0<s.length&&null!=o.markers&&(l=ft({},o.markers,{position:new Oe(n.x+s.length/2,n.y),copy:o.markers.copy.slice(0,-1)}),u=e.collections.primitives.polygon(l),e.add("marker".concat(r),u));var l={font:e.defaultFont,justify:"center",xAlign:"left",yAlign:"middle",position:new Oe(n.x+s.length+s.space,n.y)};null!=a.font&&(l.font=ft({},l.font,a.font));var u=s.text;"string"==typeof s.text&&(u={text:[s.text]}),"string"==typeof a.text&&(a.text={text:[a.text]}),s={},a=ft({},l,s=t.fontColorIsLineColor?{font:{color:o.color.slice()}}:s,u,a.text),a=e.collections.primitives.textLines(a),e.add("trace".concat(r),a)}))}},{key:"addFrame",value:function(t){var e=t;!0===t?e={}:Array.isArray(t)&&(e={fill:t});var n={space:this.defaultFont.size};null==t.line&&null==t.fill&&(n.line={width:.01}),null!=(n=ft({},n,e)).line&&null==n.line.color&&(n.line.color=this.defaultColor.slice()),(e=this.collections.rectangle(n)).surround(this,n.space,!0),this.add("frame",e)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function dd(t){return(dd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function pd(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||md(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function md(t,e){if(t){if("string"==typeof t)return yd(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yd(t,e):void 0}}function yd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function vd(t,e,n){return(vd="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=wd(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function gd(t,e){return(gd=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function bd(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wd(t){return(wd=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const xd=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&gd(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=wd(e);return function(t,e){if(e&&("object"===dd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return bd(t)}(this,n?(t=wd(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){var n;return function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this),null==(e=ft({},{width:t.primitives.defaultLength,height:t.primitives.defaultLength/2,xAlign:"center",yAlign:"middle",color:t.primitives.defaultColor,border:"children",touchBorder:"border",corner:{radius:0,sides:1},transform:(new Qe).scale(1,1).rotate(0).translate(0,0)},e)).fill&&null==e.line&&(e.fill=t.primitives.defaultColor.slice()),(n=r.call(this,e)).collections=t,n._line=null,n._fill=null,n._label=null,n.width=e.width,n.height=e.height,n.xAlign=e.xAlign,n.yAlign=e.yAlign,n.border=e.border,n.touchBorder=e.touchBorder,n.corner=e.corner,n.labelOffset=new Oe(0,0),n.stateProperties=["width","height","xAlign","yAlign"],n.setColor(e.color),null!=e.fill&&n.addRect(e.fill,"fill",!0),null!=e.line&&n.addRect(e.line,"line",!1),null!=e.label&&n.addlabel(e.label),e.button&&n.addButtonBehavior(e.button),n.setPositions(),n.animations.surround=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i,o,a,s,l,u,c,h,f=ft.apply(void 0,[{},{element:bd(n),space:0}].concat(e)),d=!0;return f.callback=function(t){d&&(a=null==f.start?(i=n.getPosition("local"),o=n.width,n.height):(e=pd(n.getSurround(f.start,f.space),3),i=e[0],o=e[1],e[2]),h=null==f.target?(s=n.getPosition("local"),l=n.width,n.height):(r=pd(n.getSurround(f.target,f.space),3),s=r[0],l=r[1],r[2]),u=s.sub(i),c=l-o,h-=a,d=!1);var e=o+c*t,r=a+h*t;t=i.add(u.scale(t)),n.setSurround(t,e,r)},f.timeKeeper=n.timeKeeper,new Na(f)},n.animations.customSteps.push({step:n.animations.surround.bind(bd(n)),name:"surround"}),n}return t=[{key:"addButtonBehavior",value:function(t){function e(e){var r,i,o=n.elements[e];null!=o&&(r=o.color.slice(),Array.isArray(t)?i=t.slice():!0!==t&&null!=t[e]&&(i=t[e].slice()),o.animations.new().trigger({callback:function(){null==i?o.opacity=.8:o.setColor(i)},duration:.1}).trigger({callback:function(){null==i?o.opacity=1:o.setColor(r)}}).ifCanceledThenComplete().start())}var n=this;this.notifications.add("onClick",(function(){e("line"),e("fill"),e("label")}))}},{key:"addRect",value:function(t,e,n){var r={width:this.width,height:this.height,xAlign:"center",yAlign:"middle",color:this.color,corner:this.corner};n||(r.line={widthIs:"inside",cornerStyle:"auto",width:Math.max(Math.min(this.width,this.height)/100,this.collections.primitives.defaultLineWidth)},(r.line.width>this.width||r.line.width>this.height)&&(r.line.widthIs="mid")),t=ft({},r,n?Array.isArray(t)?{color:t}:{texture:t}:{line:t}),this[e]=t,t=this.collections.primitives.rectangle(t),this.add(e,t)}},{key:"setPositions",value:function(){var t=this.width,e=this.height,n=new Oe(0,0);"left"===this.xAlign?n.x+=t/2:"right"===this.xAlign?n.x-=t/2:"number"==typeof this.xAlign&&(n.x=n.x+t/2-this.xAlign*t),"bottom"===this.yAlign?n.y+=e/2:"top"===this.yAlign?n.y-=e/2:"number"==typeof this.yAlign&&(n.y=n.y+e/2-e*this.yAlign);var r=this._line;t=this._fill,e=this._label,r&&r.setPosition(n),t&&t.setPosition(n),e&&e.setPosition(n.add(this.labelOffset))}},{key:"addlabel",value:function(t){var e={font:ft({},this.collections.primitives.defaultFont),xAlign:"center",yAlign:"baseline",justify:"center",color:this.color};e.font.size=.4*this.height,e.font.color=this.color,t=ft({},e,"string"==typeof t?{text:t}:t),this.labelOffset=new Oe(0,-t.font.size/2.5),t=this.collections.primitives.textLines(t),this.add("label",t)}},{key:"getSurround",value:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2]?"local":"figure",i=Array.isArray(t)?(e=[],t.forEach((function(t){var n;t=t.getBorder(r),e.push.apply(e,function(t){if(Array.isArray(t))return yd(t)}(n=t)||function(){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}()||md(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})),hr(e,n)):hr(t.getBorder(r),n);return t=this.spaceTransformMatrix(r,"draw")[0],n=i.width*t,t=i.height*t,i=new Oe(i.left+i.width/2,i.bottom+i.height/2).transformBy(this.spaceTransformMatrix(r,"local")),"left"===this.xAlign?i.x-=n/2:"right"===this.xAlign?i.x+=n/2:"number"==typeof this.xAlign&&(i.x=i.x-n/2+this.xAlign*n),"bottom"===this.yAlign?i.y-=t/2:"top"===this.yAlign?i.y+=t/2:"number"==typeof this.yAlign&&(i.y=i.y-t/2+t*this.yAlign),[i,n,t]}},{key:"surround",value:function(t){var e=(n=pd(this.getSurround(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]&&arguments[2]),3))[0],n=(t=n[1],n[2]);this.setSurround(e,t,n)}},{key:"setSurround",value:function(t,e,n){this.width=e,this.height=n,this._line&&this._line.custom.updatePoints({width:e,height:n}),this._fill&&this._fill.custom.updatePoints({width:e,height:n}),this.setPositions(),this.setPosition(t)}},{key:"stateSet",value:function(){vd(wd(i.prototype),"stateSet",this).call(this);var t=this.width,e=this.height;this._line&&this._line.custom.updatePoints({width:t,height:e}),this._fill&&this._fill.custom.updatePoints({width:t,height:e}),this.setPositions()}},{key:"setLabel",value:function(t){null!=this._label&&this._label.custom.updateText("string"==typeof t?{text:t}:t),this.animateNextFrame()}},{key:"getLabel",value:function(){return null!=this._label?this._label.drawingObject.text[0].text:""}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();function Sd(t){return(Sd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Td(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||Ad(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ad(t,e){if(t){if("string"==typeof t)return kd(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kd(t,e):void 0}}function kd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var _d=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.notifications=new It,this.inTransition=!1,this.fromAutoSlide=!1,this.disableButtonOpacity=.7,null!=e&&this.load(e)}var e=[{key:"load",value:function(t){var e=this,n=t;if(n.collection instanceof Rl?this.collection=n.collection:null!=n.collection&&null!=n.collection.elements&&(this.collection=n.collection.elements),this.collection.recorder.addEventType("slide",(function(t){t=(n=Td(t,2))[0];var n=n[1];"prev"===t&&e.currentSlideIndex===n-1?e.nextSlide(!0):"prev"===t?(e.goToSlide(n-1),e.nextSlide(!0)):"next"===t&&e.currentSlideIndex===n+1?e.prevSlide():e.goToSlide(n)}),!0),this.collection.recorder.addEventType("_autoSlide",(function(t){t=Td(t,1)[0],e.fromAutoSlide=!0,e.currentSlideIndex===t-1?e.nextSlide(!0):e.goToSlide(t)}),!0),null==this.collection.fnMap.global.map.slideNavigatorTransitionDone)this.slideTransitionDoneName="slideNavigatorTransitionDone";else{for(var r=0;null!=this.collection.fnMap.global.map["slideNavigatorTransitionDone".concat(r)];)r+=1;this.slideTransitionDoneName="slideNavigatorTransitionDone".concat(r)}this.collection.fnMap.global.add(this.slideTransitionDoneName,this.transitionDone.bind(this)),this.from="prev",null!=n.slides&&(this.slides=n.slides),"string"==typeof n.text?this.textElement=this.collection.getElement(n.text):null!=n.text?this.textElement=n.text:this.textElement=null,t=[],Array.isArray(n.equation)?t=n.equation:null!=n.equation&&(t=[n.equation]),this.setEquations(t),this.equationDefaults=ft({},{duration:1,animate:"move"},n.equationDefaults||{}),n.prevButton&&(this.prevButton=this.collection.getElement(n.prevButton)),n.nextButton&&(this.nextButton=this.collection.getElement(n.nextButton)),this.currentSlideIndex=0,this.inTransition=!1,t=this.prevButton,n=this.nextButton,null!=t&&(t.onClick=this.prevSlide.bind(this)),null!=n&&(n.onClick=this.nextSlide.bind(this,!1)),null!=this.slides||1!==this.equationsOrder.length||(n=Td(this.equationsOrder,1)[0])instanceof lf&&null!=(n=n.eqn).currentFormSeries&&0<n.currentFormSeries.length&&(this.slides=[],n.currentFormSeries.forEach((function(t){return e.slides.push({form:"".concat(t)})}))),this.loadRecorder()}},{key:"convertTime",value:function(t){var e;return"string"==typeof t?(e=t.split(":"),60*parseInt(e[0],10)+parseFloat(e[1])):t}},{key:"loadRecorder",value:function(){var t,e=this;null!=this.slides&&0!==this.slides.length&&(t=0,this.slides.forEach((function(n,r){var i=n.time,o=n.delta;n=n.execDelta,null!=i||0===r?(i=e.convertTime(i||0),e.collection.recorder.events._autoSlide.list.push([i,[r],0]),t=i):null!=o&&(t+=o,e.collection.recorder.events._autoSlide.list.push([t,[r],0])),null!=n&&0<n.length&&(n=Array.isArray(n[0])?n:[n]).forEach((function(n){var r=Td(n,2),i=r[0];if(n=r[1],"number"!=typeof(r=t+i))throw new Error("Error in delta time: ".concat(r,", ").concat(i,", $ // $FlowFixMe{lastTime}, ").concat(n));e.collection.recorder.events._autoExec.list.push([r,[n],0])}))})),this.slides.forEach((function(t){null!=(t=t.exec)&&0!==t.length&&(t=Array.isArray(t[0])?t:[t]).forEach((function(t){var n=Td(t,2),r=n[0];if(t=n[1],"number"!=typeof(n=e.convertTime(r)))throw new Error("Error in exec time: ".concat(n,", ").concat(r,", ").concat(t));e.collection.recorder.events._autoExec.list.push([n,[t],0])}))})),this.collection.recorder.events._autoExec.list.sort((function(t,e){return t[0]-e[0]})))}},{key:"loadSlides",value:function(t){this.slides=t,this.loadRecorder(),this.goToSlide(0)}},{key:"setEquations",value:function(t){var e=this,n={},r=[];t.forEach((function(t){null!=(t=e.collection.getElement(t))&&(r.push(t),n[t.name]=t)})),this.equations=n,this.equationsOrder=r}},{key:"getProperty",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=e,i=this.slides[r][t];if(this.slides[r].clear)return void 0===i?n:i;for(;void 0===i&&0<r;)if(i=this.slides[--r][t],this.slides[r].clear)return void 0===i?n:i;return void 0===i?n:i}},{key:"getText",value:function(t){return this.getProperty("text",t,"")}},{key:"getForm",value:function(t){return this.getFormGeneric("form",t)}},{key:"getFormGeneric",value:function(t,e){var n=this;if(void 0===(e="form"===t?this.getProperty("form",e,null):this.slides[e][t]))return{};if(Array.isArray(e)){var r={};return e.forEach((function(t,e){n.equationsOrder.length>e&&(r[n.equationsOrder[e].name]=t)})),r}return"string"!=typeof e&&null!==e?e:(t={},0<this.equationsOrder.length&&(t[this.equationsOrder[0].name]=e),t)}},{key:"getFromForm",value:function(t){return void 0===this.slides[t].fromForm?0===t||this.slides[t].clear?{}:this.getFormGeneric("form",t-1):this.getFormGeneric("fromForm",t)}},{key:"showForms",value:function(t){var e=this;Object.keys(t).forEach((function(n){var r=t[n];null!=(n=e.collection.getElement(n))&&(null==r?n.hide():n.showForm(r))}))}},{key:"setSteadyState",value:function(t){var e=this.currentSlideIndex,n=this.slides[e],r=this.getForm(e);this.showForms(r),null!=n.transition&&Array.isArray(n.transition)&&this.setFinalFromAutoTransition(n.transition),null!=n.transition&&"object"===Sd(n.transition)&&this.setFinalFromAutoTransition([n.transition]),this.collection.fnMap.exec(this.getProperty("steadyStateCommon",e,(function(){})),t,e),null!=n.steadyState&&this.collection.fnMap.exec(n.steadyState,t,e),t=this.prevButton,e=this.nextButton,null!=t&&(0===this.currentSlideIndex?(t.setOpacity(this.disableButtonOpacity),t.isTouchable=!1):!1===t.isTouchable&&(t.setOpacity(1),t.isTouchable=!0)),null!=e&&null!=e.setLabel&&(this.currentSlideIndex===this.slides.length-1?e.setLabel("Restart"):e.setLabel("Next")),this.inTransition=!1,this.notifications.publish("steady")}},{key:"transitionDone",value:function(){"freeze"!==(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"complete")&&(this.setSteadyState(this.from),this.inTransition=!1)}},{key:"setFinalFromAutoTransition",value:function(t){var e=this;t.forEach((function(t){(t=Array.isArray(t)?t:[t]).forEach((function(t){!1!==t.final&&(e.processAutoTransitionSet(t,"in","showAll"),e.processAutoTransitionSet(t,"out","hide"),e.processAutoTransitionSet(t,"scenario","setScenario","target"),e.processAutoTransitionSet(t,"dim","dim"),e.processAutoTransitionSet(t,"undim","undim"),e.processAutoTransitionSet(t,"rotation","setRotation","target"),e.processAutoTransitionSet(t,"position","setPosition","target"),e.processAutoTransitionSet(t,"scale","setScale","target"))}))}))}},{key:"processAutoTransitionAnim",value:function(t,e){var n,r,i,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",a=3<arguments.length?arguments[3]:void 0,s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{};null!=t.trigger&&"trigger"===e?(n=ht({except:e},{callback:t.trigger},s,t),a.push(this.collection.animations[o](n))):null!=t[e]&&(n=this.collection.getElements(t[e]),r=ht({except:e},{},s,t),a.push.apply(a,function(t){if(Array.isArray(t))return kd(t)}(i=n.map((function(t){return t.animations[o](r)})))||function(){if("undefined"!=typeof Symbol&&null!=i[Symbol.iterator]||null!=i["@@iterator"])return Array.from(i)}()||Ad(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))}},{key:"processAutoTransitionSet",value:function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";null!=t[e]&&(e=this.collection.getElements(t[e]),""!==r?e.map((function(e){return e[n](t[r])})):e.map((function(t){return t[n]()})))}},{key:"showAutoTransitionDissolve",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(null!=(t=this.slides[t]).transition&&"function"!=typeof t.transition)for(var r=t.transition,i=(r=Array.isArray(r)?r:[r]).length-1;0<=i;--i){var o=r[i];(Array.isArray(o)?o:[o]).forEach((function(t){n?null!=t.in?e.collection.getElements(t.in).map((function(t){return t.showAll()})):null!=t.out&&e.collection.getElements(t.out).map((function(t){return t.showAll()})):(null==t.out||null!=t.show&&!1===t.show||e.collection.getElements(t.out).map((function(t){return t.showAll()})),null==t.in||null!=t.show&&!0===t.show||e.collection.getElements(t.in).map((function(t){return t.hide()})))}))}}},{key:"autoTransition",value:function(t){var e=this,n=this.collection.animations.new();t.forEach((function(t){t=Array.isArray(t)?t:[t];var r=[];t.forEach((function(t){e.processAutoTransitionAnim(t,"in","dissolveIn",r,{duration:.5}),e.processAutoTransitionAnim(t,"out","dissolveOut",r,{duration:.5}),e.processAutoTransitionAnim(t,"rotation","rotation",r,{duration:2}),e.processAutoTransitionAnim(t,"position","position",r,{duration:2}),e.processAutoTransitionAnim(t,"scale","scale",r,{duration:2}),e.processAutoTransitionAnim(t,"scenario","scenario",r,{duration:2}),e.processAutoTransitionAnim(t,"scenarios","scenarios",r,{duration:2}),e.processAutoTransitionAnim(t,"pulseWidth","pulseWidth",r,{duration:1.5}),e.processAutoTransitionAnim(t,"length","length",r,{duration:1.5}),e.processAutoTransitionAnim(t,"pulseAngle","pulseAngle",r,{duration:1.5}),e.processAutoTransitionAnim(t,"pulse","pulse",r,{duration:1.5}),e.processAutoTransitionAnim(t,"dim","dim",r,{duration:1}),e.processAutoTransitionAnim(t,"undim","undim",r,{duration:1}),e.processAutoTransitionAnim(t,"trigger","trigger",r,{duration:0}),e.processAutoTransitionAnim(t,"goToForm","goToForm",r,{duration:1.5,animate:"move"}),1===Object.keys(t).length&&null!=t.delay&&r.push(e.collection.animations.delay({duration:t.delay}))})),1===r.length?n.then(r[0]):n.inParallel(r)})),n.whenFinished(this.slideTransitionDoneName).start()}},{key:"transition",value:function(t){var e=this;if(this.notifications.publish("beforeTransition"),"prev"!==(this.from=t))return this.transitionDone();this.inTransition=!0;var n=this.slides[this.currentSlideIndex];if("function"==typeof n.transition)return n.transition(this.slideTransitionDoneName,this.currentSlideIndex,t);if(null!=n.transition&&Array.isArray(n.transition))return this.autoTransition(n.transition);if(null!=n.transition&&"object"===Sd(n.transition))return this.autoTransition([n.transition]);var r=this.getForm(this.currentSlideIndex),i=this.getFromForm(this.currentSlideIndex),o=this.slideTransitionDoneName;return Object.keys(i).forEach((function(t){var n,a=e.collection.getElement(e.equations[t]);null!=a&&a instanceof lf&&void 0!==r[t]&&(n=i[t],t=r[t],null==n&&null!=t?(a.showForm(t),a.animations.new().dissolveIn(.4).whenFinished(o).start(),o=null):n!==t&&(a.animations.new().goToForm(ft({},{start:n,target:t},e.equationDefaults)).whenFinished(o).start(),o=null))})),null!=o?this.transitionDone():null}},{key:"setText",value:function(t){var e,n,r=this.textElement;null!=r&&(e=this.getProperty("modifiers",t,{}),n=this.getProperty("modifiersCommon",t,{}),t=this.getText(t)||" ",r.custom.updateText({text:t,modifiers:ft({},n,e)}))}},{key:"showElements",value:function(t){var e=this.getProperty("showCommon",t,[]);t=this.slides[t].show||[],this.collection.show(e),this.collection.show(t),null!=t&&Array.isArray(t)&&this.collection.show(),null!=this.nextButton&&this.nextButton.showAll(),null!=this.prevButton&&this.prevButton.showAll(),null!=this.textElement&&this.textElement.showAll()}},{key:"hideElements",value:function(t){var e=this.getProperty("hideCommon",t,[]);t=this.slides[t].hide||[],this.collection.hide(e),this.collection.hide(t)}},{key:"goToSlide",value:function(t){var e,n,r,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;this.notifications.publish("goToSlide",t),null!=this.slides&&0!==this.slides.length&&(e=t<0?this.slides.length-1:t,this.inTransition=!0,null==(n=i)&&(n=this.currentSlideIndex,e===this.currentSlideIndex+1?n="prev":e===this.currentSlideIndex-1&&(n="next")),"recording"===this.collection.recorder.state&&("next"===n||"prev"===n?!1===this.fromAutoSlide&&this.collection.recorder.recordEvent("slide",[n,e]):!1===this.fromAutoSlide&&this.collection.recorder.recordEvent("slide",["goTo",e]),this.fromAutoSlide=!1),this.getProperty("leaveStateCommon",this.currentSlideIndex,(function(){}))(this.currentSlideIndex,e),null!=this.slides[this.currentSlideIndex].leaveState&&this.collection.fnMap.exec(this.slides[this.currentSlideIndex].leaveState,this.currentSlideIndex,e),this.collection.stop("complete"),null!=(t=this.textElement)&&(this.setText(e),"prev"===n&&(r=this.getText(this.currentSlideIndex),i=this.getText(e),JSON.stringify(i)!==JSON.stringify(r)&&t.animations.new().dissolveIn(.2).start())),this.currentSlideIndex=e,r=this.slides[e],this.collection.hideAll(),this.showElements(e),this.hideElements(e),t=this.getFromForm(e),this.showForms(t),this.showAutoTransitionDissolve(e,!0),this.collection.setScenarios(this.getProperty("scenarioCommon",e,[])),this.collection.setScenarios(r.scenario||[]),this.collection.fnMap.exec(this.getProperty("enterStateCommon",e,(function(){})),n,e),null!=r.enterState&&this.collection.fnMap.exec(r.enterState,n,e),r.addReference&&"recording"===this.collection.recorder.state&&this.collection.recorder.addCurrentStateAsReference(),this.showAutoTransitionDissolve(e,!1),this.transition(n))}},{key:"nextSlide",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=(this.currentSlideIndex+1)%this.slides.length;this.inTransition&&(this.inTransition=!1,this.collection.stop("complete"),!t)||(this.goToSlide(e,null),this.collection.animateNextFrame())}},{key:"prevSlide",value:function(){var t=this.currentSlideIndex-1;t<0&&(t=this.slides.length-1),this.collection.stop("complete"),this.goToSlide(t),this.collection.animateNextFrame()}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function Od(t){return(Od="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Pd(t,e){return(Pd=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ed(t){return(Ed=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}const Md=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Pd(t,e)}(i,Rl);var t,e,n,r=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=Ed(e);return function(t,e){if(e&&("object"===Od(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,n?(t=Ed(this).constructor,Reflect.construct(r,arguments,t)):r.apply(this,arguments))});function i(t,e){!function(t){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this);var n,o=ft({},{transform:(new Qe).scale(1,1).rotate(0).translate(0,0),color:t.primitives.defaultColor,disableOpacity:.7},e);return(n=r.call(this,o)).collections=t,n._nextButton=null,n._prevButton=null,(n._text=null)!==o.prevButton&&n.addButton(o.prevButton||{},"Prev"),null!==o.nextButton&&n.addButton(o.nextButton||{},"Next"),null!==o.text&&n.addText(o.text||{}),n.nav=new _d,n.nav.disableButtonOpacity=o.disableOpacity,n.custom.options=o,n.onAdd=function(){n.nav.load({collection:n.parent,slides:o.slides,equation:o.equation,equationDefaults:o.equationDefaults,prevButton:n._prevButton,nextButton:n._nextButton,text:n._text}),n.nav.goToSlide(0)},n}return t=[{key:"loadSlides",value:function(t){this.nav.slides=t,this.nav.loadRecorder(),this.nav.goToSlide(0)}},{key:"goToSlide",value:function(t){this.nav.goToSlide(t)}},{key:"nextSlide",value:function(){this.nav.nextSlide(0<arguments.length&&void 0!==arguments[0]&&arguments[0])}},{key:"prevSlide",value:function(){this.nav.prevSlide()}},{key:"addText",value:function(t){var e={font:ft({},this.collections.primitives.defaultFont),text:"",xAlign:"center"};e.font.color=this.color,t=ft({},e,"string"==typeof t?{text:t}:t),(t=this.collections.primitives.textLines(t)).isTouchable=!0,this.add("text",t)}},{key:"addButton",value:function(t,e){(t="arrow"===t.type?this.getArrowButton(t,e):this.getRectangleButton(t,e)).isTouchable=!0,"Next"===e?this.add("nextButton",t):this.add("prevButton",t)}},{key:"getRectangleButton",value:function(t,e){var n=this.collections.primitives.defaultLength;return t=ft({},{width:n/3,height:n/5,line:{width:this.collections.primitives.defaultLineWidth},corner:{radius:n/30,sides:10},button:!0,label:e,position:["Next"===e?n/3:-n/3,-n/4]},t),this.collections.rectangle(t)}},{key:"getArrowButton",value:function(t,e){var n=this.collections.primitives.defaultLength/4,r=0,i=n;return"Prev"===e&&(r=Math.PI,i=-i),t=ft({},{head:"triangle",length:n,width:n,angle:r,position:[i,-n],align:"mid"},t),this.collections.primitives.arrow(t)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,t),i}();var Cd=function(){function t(e,n,r){!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.webgl=e.webgl,this.draw2D=e.draw2D,this.primitives=e,this.isTouchDevice=n,this.animateNextFrame=r}var e=[{key:"collection",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e={transform:(new Qe).scale(1,1).rotate(0).translate(0,0),border:"children",touchBorder:"children",color:this.primitives.defaultColor,parent:null},n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return e=t instanceof Oe?(e.transform.updateTranslation(t),ft.apply(void 0,[{},e].concat(r))):t instanceof Qe?(e.transform=t._dup(),ft.apply(void 0,[{},e].concat(r))):ft.apply(void 0,[{},e,t].concat(r)),(t=new Rl(e)).timeKeeper=this.primitives.timeKeeper,t.dimColor=this.primitives.defaultDimColor.slice(),null!=e.pulse&&"function"!=typeof t.pulseDefault&&"string"!=typeof t.pulseDefault&&(t.pulseDefault.scale=e.pulse),t.collections=this,t}},{key:"line",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new wf(this,this.isTouchDevice,r)}},{key:"angle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new jf(this,this.isTouchDevice,this.animateNextFrame,r)}},{key:"label",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new uf(this,r)}},{key:"polyline",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e));return new zf(this,this.isTouchDevice,this.animateNextFrame,r)}},{key:"rectangle",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new xd(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"slideNavigator",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Md(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"axis",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Uf(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"axis3",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Yf(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"trace",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new ed(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"plot",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new sd(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"plotLegend",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new fd(this,ft.apply(void 0,[{},{timeKeeper:this.primitives.timeKeeper}].concat(e)))}},{key:"equation",value:function(t){return new lf(this.primitives,t)}},{key:"addEquation",value:function(t,e){var n=new lf(this.primitives,2<arguments.length&&void 0!==arguments[2]?arguments[2]:{});return t.add(e,n),n}},{key:"cursor",value:function(t){(e={color:this.primitives.defaultColor,width:.008,radius:.05}).color[3]=.9;var e=ft(e,t),n=this.collection();return t={color:e.color,radius:e.radius,sides:50},e=this.primitives.polygon(ft({},t,{line:{width:e.width}})),t=this.primitives.polygon(ft({},t)),n.add("up",e),n.add("down",t),n}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function jd(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Rd(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rd(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rd(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Bd(t){return(Bd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Fd(t,e,n){return(Fd="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){if(t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=zd(t)););return t}(t,e))return(e=Object.getOwnPropertyDescriptor(t,e)).get?e.get.call(n):e.value})(t,e,n||t)}function Id(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Dd(t,e)}function Dd(t,e){return(Dd=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ld(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=zd(t);return function(t,e){if(e&&("object"===Bd(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}()}(this,e?(n=zd(this).constructor,Reflect.construct(r,arguments,n)):r.apply(this,arguments))}}function zd(t){return(zd=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Wd(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Nd(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function qd(t,e,n){return e&&Nd(t.prototype,e),n&&Nd(t,n),t}ss=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.frameRate={information:null,num:1,history:[]},this.fnMap=new X,this.isPaused=!1,this.scrolled=!1,this.cursorElementName="_cursor_",this.slideNavigatorElementName="_nav_",this.setStateCallback=null,this.shortcuts={},this.mockPreviousTouchPoint=new Oe(0,0),this.nextDrawTimer=null,this.nextDrawTimerStart=0;var n,r,i,o,a,s,l,u,c,h=ft({},{htmlId:"figureOneContainer",fontScale:1,color:[this.nextDrawTimerDuration=0,0,0,1],dimColor:[.5,.5,.5,1],font:{family:"Helvetica",size:.2,style:"normal",weight:"100",opacity:1},backgroundColor:[1,1,1,1]},e),f=h.htmlId;if(this.defaultColor=h.color,null==h.font.color&&(h.font.color=this.defaultColor.slice()),this.defaultDimColor=h.dimColor,this.defaultFont=h.font,this.htmlId=f,this.animationFinishedCallback=null,"string"==typeof f){var d=document.getElementById(f);if(d instanceof HTMLElement){for(var p=(this.container=d).children,m=0;m<p.length;m+=1){var y=p[m];y instanceof HTMLCanvasElement&&y.classList.contains("figureone__gl")&&(this.canvasLow=y),y instanceof HTMLCanvasElement&&y.classList.contains("figureone__gl__offscreen")&&(this.canvasOffscreen=y),y instanceof HTMLCanvasElement&&y.classList.contains("figureone__text")&&(this.textCanvasLow=y),y instanceof HTMLCanvasElement&&y.classList.contains("figureone__text__offscreen")&&(this.textCanvasOffscreen=y),y.classList.contains("figureone__html")&&(this.htmlCanvas=y)}var v;null==this.canvasLow&&(this.canvasLow=document.createElement("canvas"),this.canvasLow.classList.add("figureone__gl","figureone__canvas"),d.appendChild(this.canvasLow)),null==this.textCanvasLow&&(this.textCanvasLow=document.createElement("canvas"),this.textCanvasLow.classList.add("figureone__text","figureone__canvas"),d.appendChild(this.textCanvasLow)),null==this.htmlCanvas&&(this.htmlCanvas=document.createElement("div"),this.htmlCanvas.classList.add("figureone__html","figureone__canvas"),d.appendChild(this.htmlCanvas)),(f=document.createElement("style")).type="text/css",d.classList.add("figureone__container"),f.innerHTML="\n .figureone__container {\n position: relative;\n pointer-events: none;\n }\n .figureone__canvas {\n width: 100%;\n height: 100%;\n position: absolute;\n }\n .figureone__html {\n pointer-events: auto;\n }\n ",document.getElementsByTagName("head")[0].appendChild(f),this.backgroundColor=h.backgroundColor,f=new Oi(this.canvasLow,this.backgroundColor),this.webglLow=f,this.canvasOffscreen&&(f=new Oi(this.canvasOffscreen,this.backgroundColor),this.webglOffscreen=f),this.draw2DLow=new Vl(this.textCanvasLow),this.textCanvasOffscreen&&(v=new Vl(this.textCanvasOffscreen),this.draw2DOffscreen=v)}}null==h.gestureCanvas||null!=(v=document.getElementById(h.gestureCanvas))&&(this.gestureCanvas=v),null==this.gestureCanvas&&(this.gestureCanvas=this.htmlCanvas),this instanceof t&&(this.gesture=new Kl(this)),Array.isArray(h.scene)&&(i=(r=jd(h.scene,4))[0],a=r[1],n=r[2],r=r[3],h.scene={style:"2D",left:i,right:n,top:r,bottom:a}),null==h.scene&&(h.scene={style:"2D"}),"2D"===h.scene.style||"orthographic"===h.scene.style?(n=(i=h.scene).left,r=i.right,a=i.top,i=i.bottom,null==n&&null==r&&null==a&&null==i&&(a=this.canvasLow.clientWidth,a=(i=this.canvasLow.clientHeight)<a?(o=a/i*2,2):i/a*(o=2),h.scene.left=-o/2,h.scene.right=o/2,h.scene.bottom=-a/2,h.scene.top=a/2)):(c=(s=h.scene).fieldOfView,s=s.aspectRatio,null==c&&null==s&&(l=this.canvasLow.clientWidth,u=this.canvasLow.clientHeight||1,h.scene.fieldOfView=27*Math.PI/180,h.scene.aspectRatio=l/u)),"perspective"!==h.scene.style&&"orthographic"!==h.scene.style||(s=(c=h.scene).camera,l=c.near,u=c.far,c=c.light,null==s&&(h.scene.camera={}),null!=s&&null!=s.position||(h.scene.camera.position=[1,.5,2]),null==l&&null==u&&(h.scene.near=.1,h.scene.far=20),null==c&&(h.scene.light={directional:[1,.5,.2]})),this.scene=new Pi(h.scene),this.previousCursorPoint=new Oe(0,0),this.isTouchDown=!1,this.fontScale=h.fontScale,this.setDefaultLineWidth(e.lineWidth||null),this.setDefaultLength(e.length||null),this.drawQueued=!1,this.lastDrawTime=0,this.beingMovedElement=null,this.beingTouchedElement=null,this.moveBuffer=[],this.timeKeeper=new ml,this.notifications=new It(this.fnMap),this.recorder=new ws(this.timeKeeper),(this.recorder.figure=this).bindRecorder(),this.pauseTime=this.timeKeeper.now()/1e3,this.shapesLow=this.getShapes(),this.shapes=this.shapesLow,this.primitives=this.shapes,this.collectionsLow=this.getObjects(),this.collections=this.collectionsLow,this.createFigureElements(),""===this.elements.name&&(this.elements.name="figureRoot"),this.state={pause:"unpaused",preparingToStop:!1,preparingToSetState:!1},this.stateTime=this.timeKeeper.now()/1e3,this.focused=!0,window.addEventListener("resize",this.resize.bind(this)),window.addEventListener("focus",this.focusGained.bind(this)),window.addEventListener("blur",this.focusLost.bind(this)),this.sizeHtmlText(),this.isTouchDevice=vt(),this.animateNextFrame(!0,"first frame"),h.elements&&(this.elements=new h.elements(this),this.initElements()),this.waitForFrames=0,this.scrollingFast=!1,this.scrollTimeoutId=null,this.drawTimeoutId=null,this.oldScroll=window.pageYOffset,this.drawAnimationFrames=0,this.cursorShown=!1,this.originalScalePoint=null}var e=[{key:"addSlideNavigator",value:function(t){return t=this.add(ft({},{name:"_nav_",make:"collections.slideNavigator"},{options:t})),this.slideNavigatorElementName="_nav_",t}},{key:"getSlideNavigator",value:function(){return this.getElement(this.slideNavigatorElementName)}},{key:"addCursor",value:function(t){return t=this.add(ft({},{name:"_cursor_",make:"collections.cursor",mods:{isShown:!1}},{options:t})),this.cursorElementName="_cursor_",t}},{key:"getCursor",value:function(){return this.getElement(this.cursorElementName)}},{key:"bindRecorder",value:function(){function t(t){var n=(i=jd(t,4))[0],r=i[1],i=(t=i[2],i[3]);e.selectElement(n,new Oe(r,t,i))}var e=this;this.recorder.addEventType("touchElement",t),this.recorder.addEventType("_autoTouchElement",t),this.recorder.addEventType("cursor",(function(t){var n=(r=jd(t,3))[0],r=(t=r[1],r[2]);"show"===n?(e.showCursor("up",new Oe(t,r)),"recording"===e.recorder.state&&e.recorder.recordEvent("cursor",["show",t,r])):(e.showCursor("hide"),"recording"===e.recorder.state&&e.recorder.recordEvent("cursor",["hide"]))})),this.recorder.addEventType("_autoCursor",(function(t){var n=(r=jd(t,3))[0],r=(t=r[1],r[2]);"show"===n?e.showCursor("up",new Oe(t,r)):e.showCursor("hide")})),this.recorder.addEventType("cursorMove",(function(t){t=(n=jd(t,2))[0];var n=n[1];e.setCursor(new Oe(t,n)),e.touchMove(new Oe(t,n))})),this.recorder.addEventType("_autoCursorMove",(function(t){t=(n=jd(t,2))[0];var n=n[1];e.setCursor(new Oe(t,n)),e.touchMove(new Oe(t,n),!0)})),this.recorder.addEventType("touch",(function(t){var n=(r=jd(t,3))[0],r=(t=r[1],r[2]);"down"===n?e.touchDown(new Oe(t,r),!0):e.touchUp()})),this.recorder.addEventType("_autoTouch",(function(t){var n=(r=jd(t,3))[0],r=(t=r[1],r[2]);"down"===n?e.touchDown(new Oe(t,r),!0,!0):e.touchUp(!0)})),this.recorder.addEventType("exec",(function(t){var n=(r=jd(t,2))[0],r=r[1];e.fnMap.exec(n,r),"recording"===e.recorder.state&&e.recorder.recordEvent("exec",t)})),this.recorder.addEventType("_autoExec",(function(t){t=(n=jd(t,2))[0];var n=n[1];e.fnMap.exec(t,n)}))}},{key:"setDefaultLineWidth",value:function(t){var e,n;null==t?(e=this.scene.right-this.scene.left,n=null!=this.webglLow.gl?this.webglLow.gl.canvas.width:100,this.defaultLineWidth=Math.max(e/n,e/800)):this.defaultLineWidth=t}},{key:"setDefaultLength",value:function(t){this.defaultLength=null==t?(this.scene.right-this.scene.left)/4:t}},{key:"scrollEvent",value:function(){this.scrolled=!0,this.animateNextFrame(!1,"scroll event")}},{key:"enableScrolling",value:function(){document.addEventListener("scroll",this.scrollEvent.bind(this),!1)}},{key:"disableScrolling",value:function(){document.removeEventListener("scroll",this.scrollEvent.bind(this),!1)}},{key:"getState",value:function(t){return this.notifications.publish("getState"),this.stateTime=this.timeKeeper.now()/1e3,(t=Ci(this,["lastDrawTime","elements","stateTime","mockPreviousTouchPoint","isTouchDown","scene","originalScalePoint"],ft({},t,{returnF1Type:!1}))).beingTouchedElement=null,(t.beingMovedElement=null)!=this.beingTouchedElement&&(t.beingTouchedElement={f1Type:"de",state:this.beingTouchedElement.getPath()}),t}},{key:"setState",value:function(t){function e(){o=!0,n.state.preparingToSetState=!1,ft(n,i),n.notifications.publish("setStateInit"),n.elements.setTimeDelta(n.timeKeeper.now()/1e3-n.stateTime),n.elements.stateSet(),n.elements.setPointsFromDefinition(),n.elements.setPrimitiveColors(),null!=n.setStateCallback&&n.fnMap.exec(n.setStateCallback),n.animateNextFrame(),n.notifications.publish("setState",n.timeKeeper.now()/1e3-n.stateTime)}var n=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"instant",i=function t(e,n){if("number"==typeof e)return e;if("string"==typeof e)return e;if("boolean"==typeof e)return e;if(null==e)return e;if(Array.isArray(e)){var r=[];return e.forEach((function(e){r.push(t(e,n))})),r}if(null!=e.f1Type){if("rect"===e.f1Type)return Mn(e);if("p"===e.f1Type)return Ae(e);if("tf"===e.f1Type)return rn(e);if("l"===e.f1Type)return Fe(e);if("rangeBounds"===e.f1Type)return xn(e);if("rectBounds"===e.f1Type)return xn(e);if("lineBounds"===e.f1Type)return xn(e);if("transformBounds"===e.f1Type)return xn(e);if("de"===e.f1Type)return null!=(i=n.getElement(e.state))&&(i._assignAsLinkOnly=!0),i;if("positionAnimationStep"===e.f1Type)return(new Ui)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("rotationAnimationStep"===e.f1Type)return(new fa)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("scaleAnimationStep"===e.f1Type)return(new ga)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("transformAnimationStep"===e.f1Type)return(new ta)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("scenarioAnimationStep"===e.f1Type)return(new So)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("colorAnimationStep"===e.f1Type)return(new Ro)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("opacityAnimationStep"===e.f1Type)return(new Vo)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("pulseAnimationStep"===e.f1Type)return(new Aa)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("customAnimationStep"===e.f1Type)return(new Na)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("delayAnimationStep"===e.f1Type)return(new rs)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("parallelAnimationStep"===e.f1Type)return(new fo)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("serialAnimationStep"===e.f1Type)return(new Xa)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("triggerAnimationStep"===e.f1Type)return(new ja)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper);if("animationBuilder"===e.f1Type)return(new Ul)._fromState(t(e.state,n),n.getElement.bind(n),n.timeKeeper)}var i,o={};return Object.keys(e).forEach((function(r){o[r]=t(e[r],n)})),o}(t,this),o=!1;t={how:"instant",maxDuration:6,allDurationsSame:!(this.state.preparingToSetState=!1),zeroDurationThreshold:1e-5,duration:0},null!=r.velocity&&(t.velocity={position:2,rotation:2*Math.PI/2,scale:1,opacity:.8,color:.8}),"string"==typeof r?t.how=r:t=ft({},t,r),"dissolve"===t.how?(r={dissolveIn:.8,dissolveOut:.8,delay:.2},0===t.duration?t.duration=r:"number"==typeof t.duration?t.duration={dissolveOut:t.duration/10*4.5,dissolveIn:t.duration/10*4.5,delay:t.duration/10*1}:t.duration=ft({},r,t.duration)):null!=t.duration&&"number"!=typeof t.duration&&(t.duration={dissolveOut:0,dissolveIn:0,delay:0}),"instant"===t.how||this.elements.isStateSame(i.elements,!0,["cursor"])?e():"animate"===t.how?(this.elements.stop("freeze"),this.animateToState(i,t,e,"now")):(this.elements.stop("freeze"),this.dissolveToState({state:i,dissolveInDuration:t.duration.dissolveIn,dissolveOutDuration:t.duration.dissolveOut,done:e,delay:t.duration.delay,startTime:"now"})),o||(this.state.preparingToSetState=!0,this.notifications.publish("preparingToSetState")),this.animateNextFrame()}},{key:"animateToState",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0;e=this.elements.animateToState(t.elements,e,!0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:null),null!=n&&(0===e?this.fnMap.exec(n):null!=n&&this.notifications.add("animationsFinished",n,1))}},{key:"dissolveToState",value:function(t){var e=this,n=ft({},{dissolveOutDuration:.8,dissolveInDuration:.8,delay:.2,done:null,startTime:null},t);this.elements.animations.new().opacity({duration:n.dissolveOutDuration,start:1,target:.001}).trigger({callback:function(){e.elements.hideAll(),e.elements.show()}}).delay({duration:n.delay}).trigger({callback:function(){e.dissolveInToState({state:n.state,duration:n.dissolveInDuration,done:n.done,startTime:n.startTime})},duration:0}).start(n.startTime)}},{key:"dissolveInToState",value:function(t){var e=(r=ft({},{duration:.8,done:null,startTime:null},t)).state,n=r.duration,r=(t=r.done,r.startTime);r=this.elements.dissolveInToState(e.elements,n,r),this.elements.getAllElements().forEach((function(t){t.isShown&&!1===t.dependantTransform&&t.setTransform(t.transform)})),null!=t&&(0===r?this.fnMap.exec(t):null!=t&&this.notifications.add("animationsFinished",t,1))}},{key:"add",value:function(t){return this.elements.add(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)}},{key:"getElement",value:function(t){return t===this.elements.name?this.elements:this.elements.getElement(t)}},{key:"getElements",value:function(t){return this.elements.getElements(t)}},{key:"get",value:function(t){return"string"==typeof t?this.getElement(t):this.getElements(t)}},{key:"getShapes",value:function(){var t=[this.webglLow];this.webglOffscreen&&t.push(this.webglOffscreen);var e=[this.draw2DLow];return this.draw2DOffscreen&&e.push(this.draw2DOffscreen),new Au(t,e,this.htmlCanvas,this.scene,this.animateNextFrame.bind(this,!0,"getShapes"),this.defaultColor,this.defaultDimColor,this.defaultFont,this.defaultLineWidth,this.defaultLength,this.timeKeeper,this.recorder)}},{key:"getObjects",value:function(){var t=this.shapesLow;return new Cd(t,this.isTouchDevice,this.animateNextFrame.bind(this,!0,"collections"))}},{key:"sizeHtmlText",value:function(){var t=this.container.getBoundingClientRect(),e=t.width/35,n=document.getElementById("".concat(this.htmlId,"_measure"));null!=n&&(n.style.fontSize="".concat(e,"px"),n=(n.clientWidth+1)/t.width,e=t.width<500?Math.floor(.84/n*e*1e4)/1e4:Math.floor(.85/n*e*1e4)/1e4),this.htmlCanvas.style.fontSize="".concat(e,"px")}},{key:"destroy",value:function(){this.gesture.destroy(),this.webglLow.gl.getExtension("WEBGL_lose_context").loseContext()}},{key:"spaceTransformMatrix",value:function(t,e){return this.elements.spaceTransformMatrix(t,e)}},{key:"transformPoint",value:function(t,e,n){return this.elements.transformPoint(t,e,n,3<arguments.length&&void 0!==arguments[3]?arguments[3]:[[0,0,0],[0,0,1]])}},{key:"initialize",value:function(){}},{key:"initElements",value:function(){var t=this;this.animations=this.elements.animations,this.elements.scene=this.scene,this.elements.getCanvas=function(){return t.canvasLow},this.setupAnimations(),this.elements.setFigure({spaceTransformMatrix:this.spaceTransformMatrix.bind(this),animateNextFrame:this.animateNextFrame.bind(this),animationFinished:this.animationFinished.bind(this),recorder:this.recorder,timeKeeper:this.timeKeeper}),this.setFirstTransform(),this.animateNextFrame()}},{key:"setElements",value:function(t){this.elements=t,this.initElements()}},{key:"getRemainingAnimationTime",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3,e=this.elements.getAllElements(),n=t;"paused"===this.state.pause&&(n=this.pauseTime);for(var r=0,i=0;i<e.length;i+=1){var o=e[i],a=o.animations.getRemainingTime([],n);if(null==a)return null;if(r<a&&(r=a),null==(a=o.getRemainingPulseTime(n)))return null;if(r<a&&(r=a),null==(o=o.getRemainingMovingFreelyTime(n)))return null;r<o&&(r=o)}return r}},{key:"setAnimationFinishedCallback",value:function(t){this.animationFinishedCallback=t}},{key:"animationFinished",value:function(){this.isAnimating()||(this.fnMap.exec(this.animationFinishedCallback),this.notifications.publish("animationsFinished"))}},{key:"setFirstTransform",value:function(){this.elements.setFirstTransform(new Qe)}},{key:"renderAllElementsToTiedCanvases",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]&&arguments[0];null!=this.canvasOffscreen&&(t=!1,Object.keys(this.elements.elements).forEach((function(r){var i=e.elements.elements[r];i.isShown&&(!1===i.isRenderedAsImage||n)&&null!=i.tieToHTML.element&&(i.isRenderedAsImage=!0,e.renderElementToTiedCanvas(r),t=!0)})),t&&(this.drawQueued=!0,this.clearContext(),this.draw2DLow.ctx.clearRect(0,0,this.textCanvasLow.width,this.textCanvasLow.height),this.draw(-1)))}},{key:"renderElementToTiedCanvas",value:function(t){var e=this,n={};Object.keys(this.elements.elements).forEach((function(t){var r=e.elements.elements[t];n[t]=r.isShown})),Object.keys(this.elements.elements).forEach((function(t){e.elements.elements[t].hide()}));var r=this.elements.elements[t];r.show();var i=r.getPosition(),o=r.getScale();(t=document.getElementById(r.tieToHTML.element))instanceof HTMLElement&&(this.canvasOffscreen.style.width="".concat(t.clientWidth,"px"),this.canvasOffscreen.style.height="".concat(t.clientHeight,"px"),this.textCanvasOffscreen.style.width="".concat(t.clientWidth,"px"),this.textCanvasOffscreen.style.height="".concat(t.clientHeight,"px"),this.webglOffscreen.resize(),this.draw2DOffscreen.resize()),r.updateHTMLElementTie(this.canvasOffscreen),t=r.getScale(),r.setPosition(0-t.x*(r.tieToHTML.window.left+r.tieToHTML.window.width/2),0-t.y*(r.tieToHTML.window.bottom+r.tieToHTML.window.height/2)),r.isRenderedAsImage=!1,r.stop("complete"),this.renderToCanvas(r.tieToHTML.element),r.isRenderedAsImage=!0,r.setPosition(i),r.setScale(o),Object.keys(this.elements.elements).forEach((function(t){var r=e.elements.elements[t];!0===n[t]?r.show():r.hide()}))}},{key:"renderToCanvas",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=t;(e="string"==typeof t?document.getElementById(t):e)instanceof HTMLElement&&(this.drawQueued=!0,this.draw(-1,1),(e=document.getElementById("".concat(t,"_webgl")))instanceof HTMLImageElement&&(e.src=this.webglOffscreen.gl.canvas.toDataURL("image/png",.5),e.style.display="block"),(t=document.getElementById("".concat(t,"_2d")))instanceof HTMLImageElement&&(t.src=this.draw2DOffscreen.canvas.toDataURL("image/png",.5),t.style.display="block"),this.clearContext(1))}},{key:"unrenderAll",value:function(){for(var t=0;t<this.elements.drawOrder.length;t+=1)this.elements.elements[this.elements.drawOrder[t]].unrender()}},{key:"resize",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this.webglLow.resize(),this.draw2DLow.resize(),this.sizeHtmlText(),t?this.elements.resize():this.elements.resize(this.canvasLow),this.oldWidth!==this.canvasLow.clientWidth&&(this.renderAllElementsToTiedCanvases(),this.oldWidth=this.canvasLow.clientWidth),this.notifications.publish("resize"),this.animateNextFrame(!0,"resize"),this.drawAnimationFrames=2}},{key:"updateHTMLElementTie",value:function(){null!=this.elements&&this.elements.updateHTMLElementTie(this.canvasLow)}},{key:"show",value:function(){this.elements.show(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"hide",value:function(){this.elements.hide(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"showOnly",value:function(){this.elements.showOnly(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}},{key:"setScenarios",value:function(t){this.elements.setScenarios(t,1<arguments.length&&void 0!==arguments[1]&&arguments[1])}},{key:"toggleCursor",value:function(){this.cursorShown=!this.cursorShown,"recording"===this.recorder.state&&(this.cursorShown?(this.recorder.recordEvent("cursor",["show",this.previousCursorPoint.x,this.previousCursorPoint.y]),this.isTouchDown?this.showCursor("down"):this.showCursor("up"),this.setCursorGLPoint(this.previousCursorPoint)):(this.recorder.recordEvent("cursor",["hide"]),this.showCursor("hide")))}},{key:"showCursor",value:function(t){var e,n,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=this.getCursor();null!=i&&(e=i.getElement("up"),n=i.getElement("down"),null!=e&&null!=n&&("up"===t?(e.showAll(),n.hide()):"down"===t?(e.hide(),n.showAll()):i.hide(),null!=r&&this.setCursor(r),this.animateNextFrame()))}},{key:"isCursorShown",value:function(){var t=this.getElement(this.cursorElementName);return null!=t&&t.isShown}},{key:"touchDownHandlerClient",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return t=this.clientToPixel(t),t=this.transformPoint(t,"pixel","gl"),this.touchDownHandler(t,e),!0}},{key:"touchDownHandler",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return"recording"===this.recorder.state&&(n||this.recorder.recordEvent("touch",["down",t.x,t.y]),this.cursorShown&&this.showCursor("down")),this.previousCursorPoint=this.transformPoint(t,"gl","figure"),this.isPaused&&this.unpause(),"idle"===this.recorder.state&&(this.recorder.lastSeekTime=null),"playing"!==this.recorder.state||e||(this.recorder.pausePlayback(),this.showCursor("hide")),this.isTouchDown=!0,null!=(e=null==(e=this.elements.getSelectionFromBorders(t))?this.getSelectionFromDraw(t):e)&&(this.selectElement(e,t,n),!0)}},{key:"selectElement",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];null!=(t="string"==typeof t?this.get(t):t)&&("recording"===this.recorder.state&&(n||this.recorder.recordEvent("touchElement",[t.getPath(),e.x,e.y,e.z])),t.click(e),(this.beingTouchedElement=t).isMovable&&(this.beingMovedElement=t).startBeingMoved(),null!=this.beingMovedElement&&this.animateNextFrame(!0,"touch down handler"))}},{key:"flushMoveBuffer",value:function(){0<this.moveBuffer.length&&(this.touchMoveHandler(this.moveBuffer[0][0],this.moveBuffer[this.moveBuffer.length-1][1],!1),this.moveBuffer=[])}},{key:"touchUpHandler",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];!1!==this.isTouchDown&&(("playing"===this.recorder.state||"preparingToPlay"===this.recorder.state)&&1<arguments.length&&void 0!==arguments[1]&&arguments[1]||("recording"!==this.recorder.state||t||(this.recorder.recordEvent("touch",["up"]),this.cursorShown&&this.showCursor("up")),this.flushMoveBuffer(),null==this.beingMovedElement||null!=(t=null==this.beingMovedElement.move.element?this.beingMovedElement:"string"==typeof this.beingMovedElement.move.element?this.getElement(this.beingMovedElement.move.element):this.beingMovedElement.move.element)&&t.state.isBeingMoved&&(t.stopBeingMoved(),t.startMovingFreely()),this.originalScalePoint=null,this.isTouchDown=!1,this.beingMovedElement=null,this.beingTouchedElement=null))}},{key:"setCursor",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this.getElement(this.cursorElementName);null!=n&&(n.setPosition(t),e&&this.animateNextFrame())}},{key:"setCursorGLPoint",value:function(t){var e=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this.getElement(this.cursorElementName);null!=n&&(n.setPosition(n.transformPoint(t,"gl","figure")),e&&this.animateNextFrame())}},{key:"touchFreeHandler",value:function(t){"recording"===this.recorder.state&&(t=this.clientToPixel(t),t=this.transformPoint(t,"pixel","gl"),this.previousCursorPoint=t,this.cursorShown?(this.recorder.recordEvent("cursorMove",[t.x,t.y]),this.setCursorGLPoint(t)):this.setCursorGLPoint(t,!1))}},{key:"rotateElement",value:function(t,e,n){var r,i=t.glToPlane(e,"local");e=t.glToPlane(n,"local"),n=t.getPosition("local"),i=i.sub(n),n=e.sub(n),i.isEqualTo(n)?r=0:(r=n.angleTo(i),i.crossProduct(n).normalize().isEqualTo(t.move.plane.n)||(r*=-1)),"number"==typeof(n=t.transform.r())?t.moved(n+r):t.moved(n[1]+r)}},{key:"translateElement",value:function(t,e,n){e=t.glToPlane(e,"local",t.move.plane),n=t.glToPlane(n,"local",t.move.plane).sub(e),null!=(e=t.transform._dup().t())&&t.moved(e.add(n))}},{key:"scaleElement",value:function(t,e,n){var r,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",o=t.glToPlane(e);e=t.glToPlane(n),n=t.getPosition("local"),0===(o=o.sub(n).distance())&&(o=1e-6),e=e.sub(n).distance(),null!=(n=t.transform.s())&&("x"===i?(r=n.x*e/o,t.moved(r)):"y"===i?(r=n.y*e/o,t.moved(r)):"z"===i?(i=n.z*e/o,t.moved(i)):(o=n.x*e/o,t.moved(o)))}},{key:"touchMoveHandlerClient",value:function(t,e){return e=this.clientToPixel(e).transformBy(this.spaceTransformMatrix("pixel","gl")),t=this.clientToPixel(t).transformBy(this.spaceTransformMatrix("pixel","gl")),e.z=-1,t.z=-1,null==this.beingMovedElement||this.beingMovedElement===this.elements?this.touchMoveHandler(t,e):(this.moveBuffer.push([t,e]),!0)}},{key:"touchMoveHandler",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];if(this.previousCursorPoint.x=e.x,this.previousCursorPoint.y=e.y,"recording"!==this.recorder.state||n||(this.recorder.recordEvent("cursorMove",[e.x,e.y]),this.cursorShown&&this.setCursorGLPoint(e)),null==this.beingMovedElement||this.beingMovedElement===this.elements)return!1;var r=this.beingMovedElement;return n=r.move.type,!1===(r=null==r.move.element?r:"string"==typeof r.move.element?this.getElement(r.move.element):r.move.element).state.isBeingMoved&&r.startBeingMoved(),"rotation"===(r.move.type=n)?this.rotateElement(r,t,e):"scale"===n?this.scaleElement(r,t,e):"scaleX"===n?this.scaleElement(r,t,e,"x"):"scaleY"===n?this.scaleElement(r,t,e,"y"):"scaleZ"===n?this.scaleElement(r,t,e,"z"):this.translateElement(r,t,e),this.animateNextFrame(!0,"touch move handler"),!0}},{key:"stop",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"cancel",n=function(){t.notifications.publish("stopped"),t.state.preparingToStop=!1};if(this.elements.isAnimating()){if("freeze"===e||"cancel"===e||"complete"===e)return this.elements.stop(e),void n();if(this.state.preparingToStop=!1,"animateToComplete"===e){this.elements.stop(e);var r=this.elements.getAllElements(),i=0,o=function(){0<i&&--i,0===i&&n()};return r.forEach((function(t){t.state.preparingToStop&&(i+=1,t.notifications.add("stopped",o,1))})),void(0===i?o():0<i&&(this.notifications.publish("preparingToStop"),this.state.preparingToStop=!0))}e=this.getState({}),this.elements.stop("complete"),r=this.getState({}),this.setState(e),this.elements.stop("freeze"),this.setState(r,"dissolve"),this.state.preparingToSetState?(this.notifications.add("setState",n,1),this.notifications.publish("preparingToStop"),this.state.preparingToStop=!0):n()}else n()}},{key:"setupAnimations",value:function(){var t=this;this.elements.fnMap.add("_cameraCallback",(function(e,n){var r=n.start;n=n.target,e={position:r.position.add(n.position.sub(r.position).scale(e)),lookAt:r.lookAt.add(n.lookAt.sub(r.lookAt).scale(e)),up:r.up.add(n.up.sub(r.up).scale(e))},t.scene.setCamera(e)})),this.animations.camera=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=ft.apply(void 0,[{},{progression:"easeinout"}].concat(n));return i.customProperties={start:ft({},t.scene.camera,i.start||{}),target:ft({},t.scene.camera,i.target||{})},i.customProperties.start.position=Ae(i.customProperties.start.position),i.customProperties.start.lookAt=Ae(i.customProperties.start.lookAt),i.customProperties.start.up=Ae(i.customProperties.start.up),i.customProperties.target.position=Ae(i.customProperties.target.position),i.customProperties.target.lookAt=Ae(i.customProperties.target.lookAt),i.customProperties.target.up=Ae(i.customProperties.target.up),i.callback="_cameraCallback",i.timeKeeper=t.timeKeeper,new Na(i)},this.animations.customSteps.push({step:this.animations.camera.bind(this),name:"camera"})}},{key:"createFigureElements",value:function(){this.elements=this.collections.collection({name:"rootCollection"}),this.initElements()}},{key:"setElementsToCollection",value:function(t){this.elements=t,this.initElements()}},{key:"clearContext",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;0===e?((t=this.webglLow.gl).bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,t.canvas.width,t.canvas.height),this.webglLow.gl.clearColor(this.backgroundColor[0],this.backgroundColor[1],this.backgroundColor[2],this.backgroundColor[3]),this.webglLow.gl.clear(this.webglLow.gl.COLOR_BUFFER_BIT|this.webglLow.gl.DEPTH_BUFFER_BIT)):(this.webglOffscreen.gl.clearColor(0,0,0,0),this.webglOffscreen.gl.clear(this.webglLow.gl.COLOR_BUFFER_BIT)),this.elements.clear(e)}},{key:"setupForSelectionDraw",value:function(){var t;0===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)&&((t=this.webglLow.gl).bindFramebuffer(t.FRAMEBUFFER,this.webglLow.targetTexture.fb),t.viewport(0,0,t.canvas.width,t.canvas.height),t.enable(t.DEPTH_TEST),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))}},{key:"getSelectionFromPixel",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=this.webglLow.gl;this.setupForSelectionDraw(),this.elements.draw(0,this.scene,[new Qe],1,!0);var i=t/r.canvas.clientWidth*r.canvas.width;return t=r.canvas.height-e*r.canvas.height/r.canvas.clientHeight-1,e=new Uint8Array(4),r.readPixels(i,t,1,1,r.RGBA,r.UNSIGNED_BYTE,e),n||this.animateNextFrame(),this.elements.getUniqueColorElement(e)}},{key:"showTouchable",value:function(){this.getSelectionFromPixel(0,0,!0)}},{key:"showTouchBorders",value:function(){this.showBorders("touchBorder",0<arguments.length&&void 0!==arguments[0]?arguments[0]:"touchable",1<arguments.length&&void 0!==arguments[1]?arguments[1]:[[0,0,1,1],[0,1,1,1],[1,0,1,1],[0,1,0,1],[1,0,0,1],[1,.5,0,1],[0,0,0,1]])}},{key:"showBorders",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"border",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[[0,0,1,1],[0,1,1,1],[1,0,1,1],[0,1,0,1],[1,0,0,1],[1,.5,0,1],[0,0,0,1]],r=[];null==e||"touchable"===e?(r=this.elements.getAllElements().slice(1),"touchable"===e&&(r=r.filter((function(t){return t.isTouchable})))):r="string"==typeof e?this.getElements(e):[e];for(var i=0,o=0;o<r.length;o+=1){var a=r[o];if(null==a.drawingObject||null!=a.drawBorderBuffer){var s=a.getBorder("figure",t);if(0<s[0].length){for(var l=0;l<s.length;l+=1){var u="__".concat(t).concat(o).concat(l);null!=(u=this.get(u))?u.custom.updatePoints({points:s[l]}):this.add({name:"__".concat(t).concat(o).concat(l),make:"polyline",options:{points:s[l],width:.01,color:n[i%n.length],dash:[.02,.02],close:!0}})}i+=1}}}this.animateNextFrame()}},{key:"getSelectionFromDraw",value:function(t){return t=t.transformBy(this.spaceTransformMatrix("gl","pixel")),this.getSelectionFromPixel(t.x,t.y)}},{key:"drawNow",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;this.drawQueued=!0,this.draw(t)}},{key:"pause",value:function(){"pause"!==this.state.pause&&"preparingToPause"!==this.state.pause&&"preparingToUnpause"!==this.state.pause&&(this.state.pause="paused",this.pauseTime=this.timeKeeper.now()/1e3,this.clearDrawTimeout())}},{key:"unpause",value:function(){"unpaused"!==this.state.pause&&"preparingToPause"!==this.state.pause&&"preparingToUnpause"!==this.state.pause&&(this.state.pause="unpaused",this.isPaused=!1,this.elements.setTimeDelta(this.timeKeeper.now()/1e3-this.pauseTime),this.animateNextFrame(),this.notifications.publish("unpaused"))}},{key:"touchDown",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=Ae(t);t=r.transformBy(this.spaceTransformMatrix("figure","gl")),this.touchDownHandler(t,e,n),this.mockPreviousTouchPoint=t,null!=this.elements.elements[this.cursorElementName]&&this.showCursor("down",r)}},{key:"touchUp",value:function(){this.touchUpHandler(0<arguments.length&&void 0!==arguments[0]&&arguments[0]),null!=this.elements.elements[this.cursorElementName]&&this.showCursor("up")}},{key:"touchMove",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];t=Ae(t).transformBy(this.spaceTransformMatrix("figure","gl")),this.touchMoveHandler(this.mockPreviousTouchPoint,t,e),this.mockPreviousTouchPoint=t}},{key:"clearDrawTimeout",value:function(){this.timeKeeper.clearTimeout(this.nextDrawTimer),this.nextDrawTimer=null}},{key:"draw",value:function(t){var e,n,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;null!=this.elements.__frameRate_&&(n=new zt,window.figureOneDebug.draw=[],window.figureOneDebug.setupDraw=[],window.figureOneDebug.misc=[]),this.clearDrawTimeout(),"paused"!==this.state.pause&&(-1===(e=t)&&(e=this.lastDrawTime),this.lastDrawTime=e,!0===this.scrolled&&(this.scrolled=!1,Math.abs(window.pageYOffset-this.oldScroll)>this.webglLow.gl.canvas.clientHeight/4&&(this.renderAllElementsToTiedCanvases(),this.scrollingFast=!0,this.scrollTimeoutId&&(clearTimeout(this.scrollTimeoutId),this.scrollTimeoutId=null),this.scrollTimeoutId=setTimeout(this.centerDrawingLens.bind(this,!0),100))),!1!==this.drawQueued&&(this.drawQueued=!1,this.flushMoveBuffer(),null!=this.elements.__frameRate_&&n.stamp("m1"),this.notifications.publish("beforeDraw"),null!=this.elements.__frameRate_&&n.stamp("beforeDraw"),null!=this.elements.__frameRate_&&null!=this.frameRate.information&&this.elements.__frameRate_.custom.updateText({text:this.frameRate.information}),this.elements.setupDraw(e,r),null!=this.elements.__frameRate_&&n.stamp("setupDraw"),this.clearContext(r),null!=this.elements.__frameRate_&&n.stamp("clearContext"),this.elements.draw(e,this.scene,[new Qe],1,!1),null!=this.elements.__frameRate_&&n.stamp("draw"),this.elements.isAnyElementMoving()&&this.animateNextFrame(!0,"is moving"),0<this.drawAnimationFrames&&(--this.drawAnimationFrames,this.animateNextFrame(!0,"queued frames")),this.notifications.publish("afterDraw"),null!=this.elements.__frameRate_&&(n.stamp("afterDraw"),t=n.deltas(),null!=this.elements.__frameRate_&&(r=(this.timeKeeper.now()-(this.timeKeeper.lastDrawTime||0))/1e3,e=t[0],n=t[4][1],t=t[5][1],this.frameRate.history.push([r,e,n,t]),this.frameRate.history.length===this.frameRate.num&&(e=this.frameRate.history.reduce((function(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2],t[3]+e[3]]}),[0,0,0,0]),n=this.frameRate.history.reduce((function(t,e){return[(e[0]>t[0]?e:t)[0],(e[1]>t[1]?e:t)[1],(e[2]>t[2]?e:t)[2],(e[3]>t[3]?e:t)[3]]}),[0,0,0,0]),t=this.frameRate.num,t=[m(1/(e[0]/t),0).toFixed(0).padStart(3),m(e[1]/t,1).toFixed(1).padStart(5),m(e[2]/t,1).toFixed(1).padStart(5),m(e[3]/t,1).toFixed(1).padStart(5)],n=[m(1/n[0],0).toFixed(0).padStart(3),m(n[1],1).toFixed(1).padStart(5),m(n[2],1).toFixed(1).padStart(5),m(n[3],1).toFixed(1).padStart(5)],this.frameRate.information=["Ave: ".concat(t[0]," fps, ").concat(t[1]," ms, (").concat(t[2],", ").concat(t[3],")"),"Max: ".concat(n[0]," fps, ").concat(n[1]," ms, (").concat(n[2],", ").concat(n[3],")")],this.frameRate.history=[]))),this.setDrawTimeout()))}},{key:"centerDrawingLens",value:function(){0<arguments.length&&void 0!==arguments[0]&&arguments[0]&&(this.scrollingFast=!1);var t=window.innerHeight||0;null!=document.documentElement&&(t=Math.max(document.documentElement.clientHeight,window.innerHeight||0));var e=window.pageYOffset+t/2-this.webglLow.gl.canvas.clientHeight/2;t="".concat(e=e<0?0:e,"px"),this.webglLow.gl.canvas.style.top!==t&&(this.webglLow.gl.canvas.style.top="".concat(e,"px"),this.draw2DLow.canvas.style.top="".concat(e,"px"),this.updateHTMLElementTie()),this.oldScroll=window.pageYOffset}},{key:"setDrawTimeout",value:function(){var t,e=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;1e-8<(n=null==(n=n<0?this.elements.getNextAnimationFinishTime():n)?.1:n)&&(t=this.timeKeeper.now()/1e3,(null==this.nextDrawTimer&&0<n||null!=this.nextDrawTimer&&0<this.nextDrawTimerStart&&0<this.nextDrawTimerDuration&&this.nextDrawTimerStart+this.nextDrawTimerDuration>t+n+.001||this.nextDrawTimerStart+this.nextDrawTimerDuration<=t)&&(this.clearDrawTimeout(),this.nextDrawTimerStart=t,this.nextDrawTimerDuration=n,this.nextDrawTimer=this.timeKeeper.setTimeout((function(){e.nextDrawTimer=null,e.setupDraw(),e.animateNextFrame()}),1e3*n,"drawTimeout")))}},{key:"focusLost",value:function(){this.focused=!1,this.setDrawTimeout(.1)}},{key:"focusGained",value:function(){this.focused=!0}},{key:"setupDraw",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.timeKeeper.now()/1e3;this.notifications.publish("beforeDraw"),this.elements.setupDraw(t),this.focused?this.setDrawTimeout():this.setDrawTimeout(.1)}},{key:"animateNextFrame",value:function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];this.fromWhere=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",this.drawQueued||(t&&(this.drawQueued=!0),this.timeKeeper.queueNextFrame(this.draw.bind(this)))}},{key:"isAnimating",value:function(){return this.elements.isAnimating()}},{key:"clientToPixel",value:function(t){var e=this.canvasLow.getBoundingClientRect();return new Oe(t.x-e.left,t.y-e.top)}},{key:"pixelToClient",value:function(t){var e=this.canvasLow.getBoundingClientRect();return new Oe(t.x+e.left,t.y+e.top)}},{key:"debugShowTouchBorders",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.setFirstTransform(),this.elements.getElements(t).forEach((function(t,i){t=t.getBorder("figure","touchBorder"),t=e.primitives.polyline(ft({},n,{points:t[0],close:!0})),e.add("__touchBorder_".concat(i+r),t)}))}},{key:"setManualFrames",value:function(){this.timeKeeper.setManualFrames()}},{key:"endManualFrames",value:function(){this.timeKeeper.endManualFrames()}},{key:"frame",value:function(t){this.timeKeeper.frame(t)}},{key:"addFrameRate",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.frameRate.num=t,e=this.add(ft({},{name:"_frameRate_",make:"primitives.textLines",text:["Ave:","Max:"],position:[this.scene.left,this.scene.bottom],xAlign:"left",yAlign:"bottom",font:{size:(this.scene.right-this.scene.left)/30}},e)),window.figureOneDebug={cumTimes:[],draw:[],setupDraw:[],misc:[],history:[],animationManager:[]},e}}];return function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();var Hd=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";Wd(this,t),this.id=e,Array.isArray(n)?this.classes=n:0<n.length?this.classes=n.split(" "):this.classes=[]}return qd(t,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return function(t,e,n,r){return r=" ".repeat(3<arguments.length&&void 0!==r?r:0),t=t?' id="'.concat(t,'"'):"",e=e?" ".concat(e.join(" ")):"",e="".concat(r,"<div").concat(t,' class="equation_element').concat(e,'">\n'),(e+="".concat(n,"\n"))+"".concat(r,"</div>")}(this.id,this.classes,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",t)}}]),t}(),Ud=function(){Id(e,Hd);var t=Ld(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return Wd(this,e),(i=t.call(this,r,i)).classes.push("equation_text"),i.text=n,i}return qd(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return Fd(zd(e.prototype),"render",this).call(this,t,"".concat(" ".repeat(t+2)).concat(this.text))}}]),e}(),Kd=function(){Id(e,Hd);var t=Ld(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];Wd(this,e),i=t.call(this,r,i);var o=[];return n.forEach((function(t){null!==t&&o.push(t)})),i.content=o,i}return qd(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return Fd(zd(e.prototype),"render",this).call(this,t,this.content.map((function(e){return e.render(t+2)})).join("\n"))}}]),e}(),Vd=function(){Id(e,Hd);var t=Ld(e);function e(n,r){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return Wd(this,e),(o=t.call(this,i,o)).classes.push("fraction"),o.numerator=n,o.denominator=r,o}return qd(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),r="";return r+="".concat(n,'<div class="numerator">\n'),r+=this.numerator.render(t+4),r+="\n".concat(n,"</div>\n"),r+="".concat(n,'<div class="fraction_line"> </div>\n'),r+="".concat(n,'<div class="denominator">\n'),r+=this.denominator.render(t+4),r+="\n".concat(n,"</div>"),Fd(zd(e.prototype),"render",this).call(this,t,r)}}]),e}(),Gd=function(){Id(e,Hd);var t=Ld(e);function e(n,r,i){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:"";return Wd(this,e),(a=t.call(this,o,a)).classes.push("supersub"),a.superscript=r,a.subscript=i,a.content=n,a}return qd(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),r="";return r+="".concat(n,'<div class="supsub_content element">\n'),r+=this.content.render(t+2),r+="\n".concat(n,"</div>\n"),r+="".concat(n,'<div class="super_sub element">\n'),r+="".concat(n,'<div class="super_sub_super superscript_text element">\n'),null!==this.superscript&&(r+=this.superscript.render(t+4)),r+="\n".concat(n,"</div>\n"),r+="".concat(n,'<div class="super_sub_sub subscript_text element">\n'),null!==this.subscript&&(r+=this.subscript.render(t+4)),r+="\n".concat(n,"</div>"),r+="\n".concat(n,"</div>\n"),Fd(zd(e.prototype),"render",this).call(this,t,r)}}]),e}(),Yd=function(){Id(e,Gd);var t=Ld(e);function e(n,r){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";return Wd(this,e),-1<(o=(i=t.call(this,n,null,r,i,o)).classes.indexOf("supersub"))&&i.classes.splice(o,1),i.classes.push("subscript"),i}return e}(),Xd=function(){Id(e,Gd);var t=Ld(e);function e(n,r){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";return Wd(this,e),-1<(o=(i=t.call(this,n,r,null,i,o)).classes.indexOf("supersub"))&&i.classes.splice(o,1),i.classes.push("superscript"),i}return e}(),$d=function(){Id(e,Hd);var t=Ld(e);function e(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return Wd(this,e),(i=t.call(this,r,i)).content=n,i}return qd(e,[{key:"render",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=" ".repeat(t+2),r="";return r+="".concat(n,'<div class="square_root element">\n'),r+="".concat(n,' <div class="equation_element radical element">\n'),r+="".concat(n," &radic;\n"),r+="".concat(n," </div>\n"),r+=this.content.render(t+4),r+="\n".concat(n,"</div>"),Fd(zd(e.prototype),"render",this).call(this,t,r)}}]),e}();function Jd(t){if(t instanceof Kd)return t;if(t instanceof Ud||t instanceof Hd)return new Kd([t]);if("string"==typeof t)return new Kd([new Ud(t)]);var e=[];return t.forEach((function(t){"string"==typeof t?e.push(new Ud(t)):e.push(t)})),new Kd(e)}const Zd={tools:{math:t,g2:a,m3:i,color:c,css:d,html:f,misc:e,lines:l,m2:s,morph:u},Figure:ss,Recorder:ws,FunctionMap:X,GlobalFunctionMap:Y,SlideNavigator:_d,FigureElement:Cl,FigureElementCollection:Rl,FigureElementPrimitive:jl,DrawContext2D:Vl,WebGLInstance:Oi,DrawingObject:xs,VertexGeneric:Us,TextObject:cl,FigureText:al,FigureFont:il,HTMLObject:ks,CollectionsAngle:jf,CollectionsLine:wf,CollectionsPolyline:zf,EquationLabel:uf,EquationForm:Qu,Equation:lf,HTMLEquation:function(){Id(e,Kd);var t=Ld(e);function e(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];return Wd(this,e),t.call(this,[],n,r)}return qd(e,[{key:"createEq",value:function(t){var e=this,n=[];t.forEach((function(t){"string"==typeof t?n.push(new Ud(t)):n.push(t),e.content=n}))}},{key:"htmlElement",value:function(){var t=document.createElement("div");return t.setAttribute("id",this.id),t.innerHTML=this.render(),this.classes.forEach((function(e){e&&t.classList.add(e)})),t}},{key:"el",value:function(t){return new Ud(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",2<arguments.length&&void 0!==arguments[2]?arguments[2]:[])}},{key:"supsub",value:function(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"",i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[];return new Gd(Jd(t),Jd(e),Jd(n),r,i)}},{key:"sub",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new Yd(Jd(t),Jd(e),n,r)}},{key:"sup",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new Xd(Jd(t),Jd(e),n,r)}},{key:"frac",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];return new Vd(Jd(t),Jd(e),n,r)}},{key:"sqrt",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return new $d(Jd(t),e,n)}}]),e}(),Animation:h,Scene:Pi,Point:Oe,Plane:He,Line:Ie,Rect:En,Transform:Qe,parsePoint:Ae,LineBounds:wn,RectBounds:bn,RangeBounds:gn,minAngleDiff:Pe,getTriangleCenter:yr,polarToRect:Ke,rectToPolar:Ve,threePointAngle:je,threePointAngleMin:Re,clipAngle:Ee,getPoint:Ae,getPoints:ke,getScale:_e,getLine:Fe,getRect:Mn,getPlane:qe,getTransform:rn,surfaceGrid:br,cube:$n,sphere:Dn,polygon:ir,revolve:zn,surface:o,cone:Wn,cylinder:qn,line3:Nn,getMaxTimeFromVelocity:dr,toNumbers:Vn,pointsToNumbers:Un,joinObjects:ft,m3:i,morph:u,misc:e,round:m,roundNum:p,range:_,randSign:O,randInt:P,rand:E,randElement:M,randElements:j,removeRandElement:C,TimeKeeper:ml}})(),r.default})()}));