@netless/appliance-plugin 1.0.0-beta.7 → 1.0.0-beta.8

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.
@@ -563,4 +563,4 @@ void main() {
563
563
  gl_FragColor = color;
564
564
  }`},function(d,r,t){t.r(r),(function(e,n){t.d(r,"requestAnimationFrame",function(){return a}),t.d(r,"cancelAnimationFrame",function(){return s}),t(1).glMatrix.setMatrixArrayType(Array);function i(){if(typeof performance<"u"&&performance.now)return performance.now();if(typeof e<"u"&&e.hrtime){const[o,f]=e.hrtime();return o*1e3+f*1e-6}return Date.now?Date.now():new Date().getTime()}let a,s;typeof n<"u"&&typeof n.requestAnimationFrame=="function"?(a=n.requestAnimationFrame,s=n.cancelAnimationFrame):(a=function(o){return setTimeout(()=>{o(i())},16)},s=function(o){return clearTimeout(o)})}).call(this,t(69),t(22))},function(d,r){var t=d.exports={},e,n;function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?e=setTimeout:e=i}catch{e=i}try{typeof clearTimeout=="function"?n=clearTimeout:n=a}catch{n=a}})();function s(T){if(e===setTimeout)return setTimeout(T,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(T,0);try{return e(T,0)}catch{try{return e.call(null,T,0)}catch{return e.call(this,T,0)}}}function o(T){if(n===clearTimeout)return clearTimeout(T);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(T);try{return n(T)}catch{try{return n.call(null,T)}catch{return n.call(this,T)}}}var f=[],v=!1,l,p=-1;function y(){!v||!l||(v=!1,l.length?f=l.concat(f):p=-1,f.length&&O())}function O(){if(!v){var T=s(y);v=!0;for(var c=f.length;c;){for(l=f,f=[];++p<c;)l&&l[p].run();p=-1,c=f.length}l=null,v=!1,o(T)}}t.nextTick=function(T){var c=new Array(arguments.length-1);if(arguments.length>1)for(var h=1;h<arguments.length;h++)c[h-1]=arguments[h];f.push(new x(T,c)),f.length===1&&!v&&s(O)};function x(T,c){this.fun=T,this.array=c}x.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={};function m(){}t.on=m,t.addListener=m,t.once=m,t.off=m,t.removeListener=m,t.removeAllListeners=m,t.emit=m,t.prependListener=m,t.prependOnceListener=m,t.listeners=function(T){return[]},t.binding=function(T){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(T){throw new Error("process.chdir is not supported")},t.umask=function(){return 0}},function(d,r,t){t.r(r),t.d(r,"default",function(){return I});var e=t(1),n=t(71),i=t(73),a=t(213),s=t(214),o=t(215),f=t(216);t(1).glMatrix.setMatrixArrayType(Array);function v(b,E){var L=Object.keys(b);if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(b);E&&(D=D.filter(function(R){return Object.getOwnPropertyDescriptor(b,R).enumerable})),L.push.apply(L,D)}return L}function l(b){for(var E=1;E<arguments.length;E++){var L=arguments[E]!=null?arguments[E]:{};E%2?v(Object(L),!0).forEach(function(D){p(b,D,L[D])}):Object.getOwnPropertyDescriptors?Object.defineProperties(b,Object.getOwnPropertyDescriptors(L)):v(Object(L)).forEach(function(D){Object.defineProperty(b,D,Object.getOwnPropertyDescriptor(L,D))})}return b}function p(b,E,L){return E in b?Object.defineProperty(b,E,{value:L,enumerable:!0,configurable:!0,writable:!0}):b[E]=L,b}const y=Symbol.for("spritejs_changedAttrs"),O=Symbol.for("spritejs_attributes"),x=Symbol("resolution"),m=Symbol("animations"),T=Symbol("eventListeners"),c=Symbol("captureEventListeners"),h=Symbol("filters"),u=Symbol("display"),g=Symbol("program"),M=Symbol("shaderAttrs"),A=Symbol("uniforms");class I{constructor(E={}){this.attributes=new this.constructor.Attr(this),this[x]={width:300,height:150},Object.assign(this.attributes,E),this[m]=new Set,this[T]={},this[c]={}}get ancestors(){let E=this.parent;const L=[];for(;E;)L.push(E),E=E.parent;return L}get animations(){return this[m]}get filters(){return this[h]||this.parent&&this.parent.filters}get isVisible(){return!1}get layer(){return this.parent?this.parent.layer:null}get localMatrix(){const E=this.transformMatrix,{x:L,y:D}=this.attributes;return E[4]+=L,E[5]+=D,E}get opacity(){let E=this.attributes.opacity;return this.parent&&this.parent.opacity!=null&&(E*=this.parent.opacity),E}get parentNode(){return this.parent}get nextSibling(){return this.getNodeNearBy(1)}get previousSibling(){return this.getNodeNearBy(-1)}get program(){return this[g]}get renderer(){return this.parent?this.parent.renderer:null}get renderMatrix(){if(this.__cacheRenderMatrix)return this.__cacheRenderMatrix;let E=this.localMatrix;const L=this.parent;if(L){const D=L.__cacheRenderMatrix||L.renderMatrix;D&&(E=e.mat2d.multiply(Array.of(0,0,0,0,0,0),D,E))}return E}get worldScaling(){const E=this.renderMatrix;return[Math.hypot(E[0],E[1]),Math.hypot(E[2],E[3])]}get worldRotation(){const E=this.renderMatrix;return Math.atan2(E[1],E[3])}get worldPosition(){const E=this.renderMatrix;return[E[4],E[5]]}get uniforms(){return this[A]}get className(){return this.attributes.className}set className(E){this.attributes.className=E}get id(){return this.attributes.id}set id(E){this.attributes.id=E}get name(){return this.attributes.name}set name(E){this.attributes.name=E}get zIndex(){return this.attributes.zIndex}set zIndex(E){this.attributes.zIndex=E}get mesh(){return null}get shaderAttrs(){return this[M]||{}}activateAnimations(){const E=this.layer;if(E){const L=this[m];L.forEach(R=>{R.baseTimeline=E.timeline,R.play(),R.finished.then(()=>{L.delete(R)})});const D=this.children;D&&D.forEach(R=>{R.activateAnimations&&R.activateAnimations()})}}addEventListener(E,L,D={}){E==="mousewheel"&&(E="wheel"),typeof D=="boolean"&&(D={capture:D});const{capture:R,once:C}=D,W=R?c:T;return this[W][E]=this[W][E]||[],this[W][E].push({listener:L,once:C}),this}animate(E,L){const D=new i.default(this,E,L);return this.effects&&D.applyEffects(this.effects),this.layer&&(D.baseTimeline=this.layer.timeline,D.play(),D.finished.then(()=>{this[m].delete(D)})),this[m].add(D),D}attr(...E){if(E.length===0)return this.attributes[O];if(E.length>1){let[L,D]=E;return typeof D=="function"&&(D=D(this.attr(L))),this.setAttribute(L,D),this}return typeof E[0]=="string"?this.getAttribute(E[0]):(Object.assign(this.attributes,E[0]),this)}cloneNode(){const E=new this.constructor,L=this.attributes[y];return E.attr(L),E}connect(E,L){Object.defineProperty(this,"parent",{value:E,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:L,writable:!1,configurable:!0}),E.timeline&&this.activateAnimations(),this.setResolution(E.getResolution()),this.forceUpdate(),this.dispatchEvent({type:"append",detail:{parent:E,zOrder:L}})}contains(E){for(;E&&this!==E;)E=E.parent;return!!E}deactivateAnimations(){this[m].forEach(L=>L.cancel());const E=this.children;E&&E.forEach(L=>{L.deactivateAnimations&&L.deactivateAnimations()})}disconnect(){const{parent:E,zOrder:L}=this;delete this.parent,delete this.zOrder,this.deactivateAnimations(),this.dispatchEvent({type:"remove",detail:{parent:E,zOrder:L}}),E&&E.forceUpdate()}dispatchEvent(E){E instanceof s.default||(E=new s.default(E)),E.target=this;let L=E.type;L==="mousewheel"&&(L="wheel");const D=[this];let R=this.parent;for(;E.bubbles&&R;)D.push(R),R=R.parent;for(let C=D.length-1;C>=0;C--){const W=D[C],z=W[c]&&W[c][L];if(z&&z.length&&(E.currentTarget=W,z.forEach(({listener:H,once:X})=>{H.call(this,E),X&&D.removeEventListener(H)}),delete E.currentTarget),!E.bubbles&&E.cancelBubble)break}if(!E.cancelBubble)for(let C=0;C<D.length;C++){const W=D[C],z=W[T]&&W[T][L];if(z&&z.length&&(E.currentTarget=W,z.forEach(({listener:H,once:X})=>{H.call(this,E),X&&D.removeEventListener(H)}),delete E.currentTarget),!E.bubbles||E.cancelBubble)break}}dispatchPointerEvent(E){const{layerX:L,layerY:D}=E;return this.isPointCollision(L,D)?(this.dispatchEvent(E),!0):!1}draw(E=[]){const L=this.mesh;if(L){if(Object(o.applyFilters)(L,this.filters),E.push(L),this[g]){L.setProgram(this[g]);const D=this[M];D&&Object.entries(D).forEach(([C,W])=>{L.setAttribute(C,W)});const R=this[A];if(this[A]){const C={};Object.entries(R).forEach(([W,z])=>{typeof z=="function"&&(z=z(this,W)),C[W]=z}),L.setUniforms(C)}}Object(f.default)(this,L)}return E}forceUpdate(){this.parent&&this.parent.forceUpdate()}getAttribute(E){return this.attributes[E]}getListeners(E,{capture:L=!1}={}){return[...this[L?c:T][E]||[]]}getNodeNearBy(E=1){if(!this.parent)return null;if(E===0)return this;const L=this.parent.children,D=L.indexOf(this);return L[D+E]}getWorldPosition(E,L){const D=this.renderMatrix,R=E*D[0]+L*D[2]+D[4],C=E*D[1]+L*D[3]+D[5];return[R,C]}getOffsetPosition(E,L){const D=e.mat2d.invert(Array.of(0,0,0,0,0,0),this.renderMatrix),R=E*D[0]+L*D[2]+D[4],C=E*D[1]+L*D[3]+D[5];return[R,C]}getResolution(){return l({},this[x])}isPointCollision(E,L){if(!this.mesh)return!1;const D=this.attributes.pointerEvents;if(D==="none"||D!=="all"&&!this.isVisible)return!1;let R="both";return D==="visibleFill"&&(R="fill"),D==="visibleStroke"&&(R="stroke"),this.mesh.isPointCollision(E,L,R)}onPropertyChange(E,L,D){E!=="id"&&E!=="name"&&E!=="className"&&E!=="pointerEvents"&&E!=="passEvents"&&this.forceUpdate(),E==="filter"&&(this[h]=Object(o.parseFilterString)(L)),E==="zIndex"&&this.parent&&this.parent.reorder()}setAttribute(E,L){E==="attrs"&&this.attr(L),this.attributes[E]=L}setMouseCapture(){this.layer&&(this.layer.__mouseCapturedTarget=this)}setProgram(E){this[g]=E,this.forceUpdate()}setShaderAttribute(E,L){this[M]=this[M]||{},this[M][E]=L,this.forceUpdate()}setUniforms(E){this[A]=this[A]||{},Object.assign(this[A],E),this.forceUpdate()}setResolution({width:E,height:L}){const{width:D,height:R}=this[x];(D!==E||R!==L)&&(this[x]={width:E,height:L},this.forceUpdate(),this.dispatchEvent({type:"resolutionchange",detail:{width:E,height:L}}))}show(){this.attributes.display==="none"&&(this.attributes.display=this[u]||"")}hide(){this.attributes.display!=="none"&&(this[u]=this.attributes.display,this.attributes.display="none")}releaseMouseCapture(){this.layer&&this.layer.__mouseCapturedTarget===this&&(this.layer.__mouseCapturedTarget=null)}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}removeAllListeners(E,L={}){typeof L=="boolean"&&(L={capture:L});const R=L.capture?c:T;return this[R][E]&&(this[R][E]=[]),this}removeAttribute(E){this.setAttribute(E,null)}removeEventListener(E,L,D={}){typeof D=="boolean"&&(D={capture:D});const C=D.capture?c:T;if(this[C][E]){const W=this[C][E];if(W)for(let z=0;z<W.length;z++){const{listener:H}=W[z];if(H===L){this[C][E].splice(z,1);break}}}return this}transition(E,L="linear"){const D=this,R=Symbol("animation");L=L||"linear";let C=0;return typeof E=="object"&&(C=E.delay||0,E=E.duration),{[R]:null,cancel(W=!1){const z=this[R];z&&z.cancel(W)},end(){const W=this[R];W&&(W.playState==="running"||W.playState==="pending")&&W.finish()},reverse(){const W=this[R];if(W)if(W.playState==="running"||W.playState==="pending")W.playbackRate=-W.playbackRate;else{const z=W.timing.direction;W.timing.direction=z==="reverse"?"normal":"reverse",W.play()}return W.finished},attr(W,z){return this.end(),typeof W=="string"&&(W={[W]:z}),Object.entries(W).forEach(([H,X])=>{typeof X=="function"&&(W[H]=X(D.attr(H)))}),this[R]=D.animate([W],{duration:E*1e3,delay:C*1e3,fill:"forwards",easing:L}),this[R].finished}}}updateContours(){}}p(I,"Attr",n.default),a.default.registerNode(I,"node")},function(d,r,t){t.r(r),t.d(r,"default",function(){return I});var e=t(1),n=t(12),i=t(72);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttributeDefault"),s=Symbol.for("spritejs_declareAlias"),o=Symbol.for("spritejs_setAttribute"),f=Symbol.for("spritejs_getAttribute"),v=Symbol.for("spritejs_attributes"),l=Symbol.for("spritejs_changedAttrs"),p=Symbol("subject"),y=Symbol("attr"),O=Symbol("default"),x=Symbol("alias");function m(b,[E,L]){let D=e.mat2d.fromValues(1,0,0,1,0,0);return[...b].forEach(([R,C])=>{if((E||L)&&(D=e.mat2d.translate(Array.of(0,0,0,0,0,0),D,[E,L])),R==="matrix")D=e.mat2d.multiply(D,D,C);else if(R==="offsetTranslate")D[4]+=C[0],D[5]+=C[1];else if(R==="offsetRotate")D=e.mat2d.rotate(Array.of(0,0,0,0,0,0),D,C);else if(R==="skew"){const[W,z]=C;D=e.mat2d.multiply(D,D,e.mat2d.fromValues(1,Math.tan(z),Math.tan(W),1,0,0))}else e.mat2d[R](D,D,C);(E||L)&&(D=e.mat2d.translate(Array.of(0,0,0,0,0,0),D,[-E,-L]))}),D}const T=Symbol("transformMatrix"),c=Symbol("transforms"),h=Symbol("changedAttrs"),u=Symbol("lastChangedAttr"),g=Symbol("offsetFigure");function M(b,E,L){const D=b[y][E];if(b[o](E,L,!1)||b[u]!==E){const C=b[c];C.has(E)&&C.delete(E),L&&(E==="rotate"&&(L=Math.PI*L/180),E==="scale"&&(L=L.map(W=>Math.abs(W)>1e-5?W:1/W>0?1e-5:-1e-5)),C.set(E,L)),b[T]=null,b[p].onPropertyChange(E,L,D,b)}}function A(b){const E=b[g],L=b.offsetDistance*E.getTotalLength(),D=E.getPointAtLength(L);if(D){const R=b[c];let C=b.offsetRotate;C==="auto"?C=D.angle:C==="reverse"?C=Math.PI+D.angle:C=Math.PI*C/180,R.set("offsetRotate",C),R.set("offsetTranslate",[D.x,D.y]),b[T]=null}}class I{static setDefault(E,...L){return E[a](...L)}static declareAlias(E,...L){return E[s](...L)}static setAttribute(E,...L){return E[o](...L)}static getAttribute(E,...L){return E[f](...L)}static getAttributes(E){return E[v]}static getChangedAttributes(E){return E[l]}constructor(E){this[p]=E,this[y]={},this[T]=e.mat2d.fromValues(1,0,0,1,0,0),this[c]=new Map,this[O]={},this[x]=[],Object.defineProperty(E,"transformMatrix",{get:()=>(this[T]||(this[T]=m(this[c],this.transformOrigin)),[...this[T]])}),this[a]({id:"",name:"",className:"",x:0,y:0,transformOrigin:[0,0],transform:"",translate:[0,0],rotate:0,scale:[1,1],skew:[0,0],opacity:1,zIndex:0,offsetPath:void 0,offsetDistance:0,offsetRotate:"auto",pointerEvents:"visible",filter:"none",display:""}),this[s]("class","pos"),this[h]=new Set,this[g]=new n.Figure2D({scale:5,simplify:0})}get[l](){const E={};return[...this[h]].forEach(L=>{E[L]=this[y][L]}),E}get[v](){const E=Object.assign({},this[y]);for(let L=0;L<this[x].length;L++){const D=this[x][L];E[D]=this[D]}return E}[a](E){Object.assign(this[O],E),Object.assign(this[y],E)}[s](...E){this[x].push(...E)}[o](E,L,D=!0){const R=this[y][E],C=this[p];return L==null&&(L=this[O][E]),Object(i.compareValue)(R,L)?!1:(this[y][E]=L,this[h].has(E)&&this[h].delete(E),this[h].add(E),this[u]=E,D&&C.onPropertyChange(E,L,R,this),!0)}[f](E){return this[y][E]}set id(E){this[o]("id",E)}get id(){return this[f]("id")}set name(E){this[o]("name",E)}get name(){return this[f]("name")}set className(E){this[o]("className",E)}get className(){return this[f]("className")}set class(E){this.className=E}get class(){return this.className}get x(){return this[f]("x")}set x(E){this[o]("x",Object(i.toNumber)(E))}get y(){return this[f]("y")}set y(E){this[o]("y",Object(i.toNumber)(E))}get pos(){return[this.x,this.y]}set pos(E){E=Object(i.toArray)(E),Array.isArray(E)||(E=[E,E]),this.x=E[0],this.y=E[1]}get transform(){return this[f]("transform")}set transform(E){let L=null;if(Array.isArray(E)&&(L=E,E=`matrix(${E.map(i.toNumber).join()})`),typeof E=="string")E=E.replace(/\s*,\s*/g,",");else if(E!=null)throw new TypeError("Invalid transform value.");const D=this[y].transform;if(this[o]("transform",E,!1)){const R=this[c];if(R.has("matrix")&&R.delete("matrix"),L)R.set("matrix",L);else if(E){const C=E.match(/(matrix|translate|rotate|scale|skew)\([^()]+\)/g);if(C){let W=e.mat2d.fromValues(1,0,0,1,0,0);for(let z=0;z<C.length;z++){const X=C[z].match(/^(matrix|translate|rotate|scale|skew)\(([^()]+)\)/);if(X){let[,Z,j]=X;Z==="rotate"?j=Math.PI*parseFloat(j)/180:j=j.trim().split(/[\s,]+/).map(G=>Object(i.toNumber)(G)),Z==="matrix"?W=e.mat2d.multiply(W,W,j):Z==="skew"?W=e.mat2d.multiply(W,W,e.mat2d.fromValues(1,Math.tan(j[1]),Math.tan(j[0]),1,0,0)):e.mat2d[Z](W,W,j),R.set("matrix",W)}}}else throw new TypeError("Invalid transform value.")}this[T]=null,this[p].onPropertyChange("transform",E,D,this)}}get transformOrigin(){return this[f]("transformOrigin")}set transformOrigin(E){E=Object(i.toArray)(E,!0),E!=null&&!Array.isArray(E)&&(E=[E,E]),this[o]("transformOrigin",E)&&(this[T]=null)}get rotate(){return this[f]("rotate")}set rotate(E){M(this,"rotate",E)}get translate(){return this[f]("translate")}set translate(E){E=Object(i.toArray)(E,!0),E!=null&&!Array.isArray(E)&&(E=[E,E]),M(this,"translate",E)}get scale(){return this[f]("scale")}set scale(E){E=Object(i.toArray)(E,!0),E!=null&&!Array.isArray(E)&&(E=[E,E]),M(this,"scale",E)}get skew(){return this[f]("skew")}set skew(E){E=Object(i.toArray)(E,!0),E!=null&&!Array.isArray(E)&&(E=[E,E]),M(this,"skew",E)}get opacity(){return this[f]("opacity")}set opacity(E){E!=null&&(E=Number(E)),this[o]("opacity",E)}get zIndex(){return this[f]("zIndex")}set zIndex(E){E!=null&&(E=Number(E)),this[o]("zIndex",E)}get offsetPath(){return this[f]("offsetPath")}set offsetPath(E){this[o]("offsetPath",E)&&(this[g].beginPath(),E!=null&&this[g].addPath(E),A(this))}get offsetDistance(){return this[f]("offsetDistance")}set offsetDistance(E){this[o]("offsetDistance",Object(i.toNumber)(E))&&A(this)}get offsetRotate(){return this[f]("offsetRotate")}set offsetRotate(E){this[o]("offsetRotate",E),A(this)}get pointerEvents(){return this[f]("pointerEvents")}set pointerEvents(E){if(E!=null&&E!=="none"&&E!=="visible"&&E!=="visibleFill"&&E!=="visibleStroke"&&E!=="all")throw new TypeError("Invalid pointerEvents type.");this[o]("pointerEvents",E)}get filter(){return this[f]("filter")}set filter(E){this[o]("filter",E)}get display(){return this[f]("display")}set display(E){this[o]("display",E)}set offset(E){}}},function(d,r,t){t.r(r),t.d(r,"sizeToPixel",function(){return e}),t.d(r,"toString",function(){return n}),t.d(r,"toNumber",function(){return i}),t.d(r,"toArray",function(){return a}),t.d(r,"compareValue",function(){return s}),t(1).glMatrix.setMatrixArrayType(Array);function e(o,f){const v=o.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/);v?o={size:parseFloat(v[1]),unit:v[2]}:o={size:parseFloat(o),unit:"px"};let{size:l,unit:p}=o;if(p==="pt")l/=.75;else if(p==="pc")l*=16;else if(p==="in")l*=96;else if(p==="cm")l*=96/2.54;else if(p==="mm")l*=96/25.4;else if(p==="em"||p==="rem"||p==="ex"){if(!f&&typeof getComputedStyle=="function"&&typeof document<"u"){const y=getComputedStyle(document.documentElement).fontSize;y?f=e(y,16):f=16}l*=f,p==="ex"&&(l/=2)}else if(p==="q")l*=96/25.4/4;else if(p==="vw"||p==="vh"){if(typeof document<"u"){const y=p==="vw"?window.innerWidth||document.documentElement.clientWidth:window.innerHeight||document.documentElement.clientHeight;l*=y/100}}else if((p==="vmax"||p==="vmin")&&typeof document<"u"){const y=window.innerWidth||document.documentElement.clientWidth,O=window.innerHeight||document.documentElement.clientHeight;p==="vmax"?l*=Math.max(y,O)/100:l*=Math.min(y,O)/100}return l}function n(o){return o==null?o:String(o)}function i(o){if(o==null)return o;if(typeof o=="string"&&(o=e(o)),!Number.isFinite(o))throw new TypeError("Invalid value");return o}function a(o,f=!1){return o===""?null:(typeof o=="string"&&(o=o.split(/[\s,]+/g)),Array.isArray(o)&&(f&&(o=o.map(i)),o.length===1)?o[0]:o)}function s(o,f){if(Array.isArray(o)&&Array.isArray(f)){if(o.length!==f.length)return!1;for(let v=0;v<o.length;v++)if(o[v]!==f[v])return!1;return!0}return o==null&&f==null||o===f}},function(d,r,t){t.r(r),t.d(r,"default",function(){return p});var e=t(74),n=t(32),i=t.n(n),a=t(68),s=t(72);t(1).glMatrix.setMatrixArrayType(Array);function o(){return o=Object.assign||function(y){for(var O=1;O<arguments.length;O++){var x=arguments[O];for(var m in x)Object.prototype.hasOwnProperty.call(x,m)&&(y[m]=x[m])}return y},o.apply(this,arguments)}function f(y){if(typeof y=="string"){if(y=y.trim(),/^[0-9.]+%$/.test(y))return parseFloat(y)/100;if(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/.test(y))return Object(s.sizeToPixel)(y)}return y}function v(y,O,x,m,T){return typeof y=="string"&&(y=i()(y)),typeof O=="string"&&(O=i()(O)),e.Effects.default(y,O,x,m,T)}function l(y,O,x,m,T){return e.Effects.default(y,O,x,m,T)}e.Effects.default=function(y,O,x,m,T){return Array.isArray(y)&&Array.isArray(O)?y.map((c,h)=>c+(x-m)/(T-m)*(O[h]-c)):typeof y=="number"&&typeof O=="number"?y+(x-m)/(T-m)*(O-y):x-m>T-x?O:y},e.Effects.fillColor=v,e.Effects.strokeColor=v,e.Effects.bgcolor=v,e.Effects.borderColor=v,e.Effects.text=l;class p extends e.Animator{constructor(O,x,m){const T=O.attr();Object.entries(T).forEach(([c,h])=>{T[c]=e.Effects[c]?h:f(h)}),x=x.map(c=>{let h=o({},c);const u={};return Object.entries(h).forEach(([g,M])=>{u[g]=e.Effects[g]?M:f(M)}),u}),super(T,x,m),this.target=O,this.setter=function(c,h){h.attr(c)}}get playState(){return this.target.parent?super.playState:"idle"}get finished(){return super.finished.then(()=>{const O=this;return new Promise(x=>{function m(){O.setter(O.frame,O.target);const T=O.playState;T==="finished"||T==="idle"?(Object(a.cancelAnimationFrame)(O.requestId),x()):Object(a.requestAnimationFrame)(m)}m()})})}finish(){super.finish(),Object(a.cancelAnimationFrame)(this.requestId),this.setter(this.frame,this.target)}play(){if(!this.target.parent||this.playState==="running")return;super.play(),this.setter(this.frame,this.target);const O=this;this.ready.then(()=>{O.setter(O.frame,O.target),O.requestId=Object(a.requestAnimationFrame)(function x(){const m=O.target;if(typeof document<"u"&&document.documentElement&&document.documentElement.contains&&m.layer&&m.layer.canvas&&!document.documentElement.contains(m.layer.canvas)){O.cancel();return}const T=O.playState;O.setter(O.frame,O.target),T!=="idle"&&(T==="running"?O.requestId=Object(a.requestAnimationFrame)(x):(T==="paused"||T==="pending"&&O.timeline.currentTime<0)&&O.ready.then(()=>{O.setter(O.frame,O.target),O.requestId=Object(a.requestAnimationFrame)(x)}))})})}cancel(O=!1){Object(a.cancelAnimationFrame)(this.requestId),O?(this.setter(this.frame,this.target),super.cancel()):(super.cancel(),this.setter(this.frame,this.target))}}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.Timeline=r.Effects=r.Easings=r.Animator=void 0;var e=t(75),n=v(e),i=t(187),a=v(i),s=t(188),o=t(190),f=v(o);function v(l){return l&&l.__esModule?l:{default:l}}r.Animator=f.default,r.Easings=s.Easings,r.Effects=a.default,r.Timeline=n.default},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});var e=t(76),n=c(e),i=t(133),a=c(i),s=t(141),o=c(s),f=t(164),v=c(f),l=t(170),p=c(l),y=t(171),O=c(y),x=t(175),m=c(x),T=t(186);function c(D){return D&&D.__esModule?D:{default:D}}var h=(0,T.createNowTime)(),u={originTime:0,playbackRate:1},g=(0,m.default)("timeMark"),M=(0,m.default)("playbackRate"),A=(0,m.default)("timers"),I=(0,m.default)("originTime"),b=(0,m.default)("setTimer"),E=(0,m.default)("parent"),L=function(){function D(R,C){(0,p.default)(this,D),R instanceof D&&(C=R,R={}),R=(0,v.default)({},u,R),C&&(this[E]=C);var W=R.nowtime||h;if(C)Object.defineProperty(this,"globalTime",{get:function(){return C.currentTime}});else{var z=W();Object.defineProperty(this,"globalTime",{get:function(){return W()-z}})}this[g]=[{globalTime:this.globalTime,localTime:-R.originTime,entropy:-R.originTime,playbackRate:R.playbackRate,globalEntropy:0}],this[E]&&(this[g][0].globalEntropy=this[E].entropy),this[I]=R.originTime,this[M]=R.playbackRate,this[A]=new o.default}return(0,O.default)(D,[{key:"markTime",value:function(){var C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},W=C.time,z=W===void 0?this.currentTime:W,H=C.entropy,X=H===void 0?this.entropy:H,Z=C.playbackRate,j=Z===void 0?this.playbackRate:Z,G={globalTime:this.globalTime,localTime:z,entropy:X,playbackRate:j,globalEntropy:this.globalEntropy};this[g].push(G)}},{key:"fork",value:function(C){return new D(C,this)}},{key:"seekGlobalTime",value:function(C){var W=this.seekTimeMark(C),z=this[g][W],H=z.entropy,X=z.playbackRate,Z=z.globalTime;return Z+(C-H)/Math.abs(X)}},{key:"seekLocalTime",value:function(C){var W=this.seekTimeMark(C),z=this[g][W],H=z.localTime,X=z.entropy,Z=z.playbackRate;return Z>0?H+(C-X):H-(C-X)}},{key:"seekTimeMark",value:function(C){var W=this[g],z=0,H=W.length-1;if(C<=W[z].entropy)return z;if(C>=W[H].entropy)return H;for(var X=Math.floor((z+H)/2);X>z&&X<H;){if(C===W[X].entropy)return X;C<W[X].entropy?H=X:C>W[X].entropy&&(z=X),X=Math.floor((z+H)/2)}return z}},{key:"updateTimers",value:function(){var C=this,W=[].concat((0,a.default)(this[A]));W.forEach(function(z){var H=(0,n.default)(z,2),X=H[0],Z=H[1];C[b](Z.handler,Z.time,X)})}},{key:"clearTimeout",value:function(R){function C(W){return R.apply(this,arguments)}return C.toString=function(){return R.toString()},C}(function(R){var C=this[A].get(R);C&&C.timerID!=null&&(this[E]?this[E].clearTimeout(C.timerID):clearTimeout(C.timerID)),this[A].delete(R)})},{key:"clearInterval",value:function(C){return this.clearTimeout(C)}},{key:"clear",value:function(){var C=this,W=this[A];[].concat((0,a.default)(W.keys())).forEach(function(z){C.clearTimeout(z)})}},{key:"setTimeout",value:function(C){var W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0};return this[b](C,W)}},{key:"setInterval",value:function(C){var W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0},z=this,H=this[b](function X(){z[b](X,W,H),C()},W);return H}},{key:b,value:function(C,W){var z=this,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:(0,m.default)("timerID");W=(0,T.formatDelay)(W);var X=this[A].get(H),Z=void 0,j=null,G=void 0,Q=void 0;X?(this.clearTimeout(H),W.isEntropy?Z=(W.delay-(this.entropy-X.startEntropy))/Math.abs(this.playbackRate):Z=(W.delay-(this.currentTime-X.startTime))/this.playbackRate,G=X.startTime,Q=X.startEntropy):(Z=W.delay/(W.isEntropy?Math.abs(this.playbackRate):this.playbackRate),G=this.currentTime,Q=this.entropy);var tt=this[E],et=tt?tt.setTimeout.bind(tt):setTimeout,at=W.heading;return!tt&&at===!1&&Z<0&&(Z=1/0),(isFinite(Z)||tt)&&(Z=Math.ceil(Z),et!==setTimeout&&(Z={delay:Z,heading:at}),j=et(function(){z[A].delete(H),C()},Z)),this[A].set(H,{timerID:j,handler:C,time:W,startTime:G,startEntropy:Q}),H}},{key:"parent",get:function(){return this[E]}},{key:"lastTimeMark",get:function(){return this[g][this[g].length-1]}},{key:"currentTime",get:function(){var C=this.lastTimeMark,W=C.localTime,z=C.globalTime;return W+(this.globalTime-z)*this.playbackRate},set:function(C){var W=this,z=this.currentTime,H=C,X=this[A];this.markTime({time:C}),[].concat((0,a.default)(X)).forEach(function(Z){var j=(0,n.default)(Z,2),G=j[0],Q=j[1];if(X.has(G)){var tt=Q.time,et=tt.isEntropy,at=tt.delay,q=tt.heading,pt=Q.handler,dt=Q.startTime;if(et)at===0&&(pt(),W.clearTimeout(G));else{var B=dt+at;(at===0||q!==!1&&(H-z)*at<=0||z<=B&&B<=H||z>=B&&B>=H)&&(pt(),W.clearTimeout(G))}}}),this.updateTimers()}},{key:"entropy",get:function(){var C=this.lastTimeMark,W=C.entropy,z=C.globalEntropy;return W+Math.abs((this.globalEntropy-z)*this.playbackRate)},set:function(C){if(this.entropy>C){var W=this.seekTimeMark(C);this[g].length=W+1}this.markTime({entropy:C}),this.updateTimers()}},{key:"globalEntropy",get:function(){return this[E]?this[E].entropy:this.globalTime}},{key:"playbackRate",get:function(){return this[M]},set:function(C){C!==this.playbackRate&&(this.markTime({playbackRate:C}),this[M]=C,this.updateTimers())}},{key:"paused",get:function(){if(this.playbackRate===0)return!0;for(var C=this.parent;C;){if(C.playbackRate===0)return!0;C=C.parent}return!1}}]),D}();r.default=L},function(d,r,t){r.__esModule=!0;var e=t(77),n=s(e),i=t(129),a=s(i);function s(o){return o&&o.__esModule?o:{default:o}}r.default=function(){function o(f,v){var l=[],p=!0,y=!1,O=void 0;try{for(var x=(0,a.default)(f),m;!(p=(m=x.next()).done)&&(l.push(m.value),!(v&&l.length===v));p=!0);}catch(T){y=!0,O=T}finally{try{!p&&x.return&&x.return()}finally{if(y)throw O}}return l}return function(f,v){if(Array.isArray(f))return f;if((0,n.default)(Object(f)))return o(f,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},function(d,r,t){d.exports={default:t(78),__esModule:!0}},function(d,r,t){t(79),t(125),d.exports=t(127)},function(d,r,t){t(80);for(var e=t(91),n=t(95),i=t(83),a=t(122)("toStringTag"),s="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),o=0;o<s.length;o++){var f=s[o],v=e[f],l=v&&v.prototype;l&&!l[a]&&n(l,a,f),i[f]=i.Array}},function(d,r,t){var e=t(81),n=t(82),i=t(83),a=t(84);d.exports=t(88)(Array,"Array",function(s,o){this._t=a(s),this._i=0,this._k=o},function(){var s=this._t,o=this._k,f=this._i++;return!s||f>=s.length?(this._t=void 0,n(1)):o=="keys"?n(0,f):o=="values"?n(0,s[f]):n(0,[f,s[f]])},"values"),i.Arguments=i.Array,e("keys"),e("values"),e("entries")},function(d,r){d.exports=function(){}},function(d,r){d.exports=function(t,e){return{value:e,done:!!t}}},function(d,r){d.exports={}},function(d,r,t){var e=t(85),n=t(87);d.exports=function(i){return e(n(i))}},function(d,r,t){var e=t(86);d.exports=Object("z").propertyIsEnumerable(0)?Object:function(n){return e(n)=="String"?n.split(""):Object(n)}},function(d,r){var t={}.toString;d.exports=function(e){return t.call(e).slice(8,-1)}},function(d,r){d.exports=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}},function(d,r,t){var e=t(89),n=t(90),i=t(106),a=t(95),s=t(83),o=t(107),f=t(121),v=t(123),l=t(122)("iterator"),p=!([].keys&&"next"in[].keys()),y="@@iterator",O="keys",x="values",m=function(){return this};d.exports=function(T,c,h,u,g,M,A){o(h,c,u);var I=function(j){if(!p&&j in D)return D[j];switch(j){case O:return function(){return new h(this,j)};case x:return function(){return new h(this,j)}}return function(){return new h(this,j)}},b=c+" Iterator",E=g==x,L=!1,D=T.prototype,R=D[l]||D[y]||g&&D[g],C=R||I(g),W=g?E?I("entries"):C:void 0,z=c=="Array"&&D.entries||R,H,X,Z;if(z&&(Z=v(z.call(new T)),Z!==Object.prototype&&Z.next&&(f(Z,b,!0),!e&&typeof Z[l]!="function"&&a(Z,l,m))),E&&R&&R.name!==x&&(L=!0,C=function(){return R.call(this)}),(!e||A)&&(p||L||!D[l])&&a(D,l,C),s[c]=C,s[b]=m,g)if(H={values:E?C:I(x),keys:M?C:I(O),entries:W},A)for(X in H)X in D||i(D,X,H[X]);else n(n.P+n.F*(p||L),c,H);return H}},function(d,r){d.exports=!0},function(d,r,t){var e=t(91),n=t(92),i=t(93),a=t(95),s=t(105),o="prototype",f=function(v,l,p){var y=v&f.F,O=v&f.G,x=v&f.S,m=v&f.P,T=v&f.B,c=v&f.W,h=O?n:n[l]||(n[l]={}),u=h[o],g=O?e:x?e[l]:(e[l]||{})[o],M,A,I;O&&(p=l);for(M in p)A=!y&&g&&g[M]!==void 0,!(A&&s(h,M))&&(I=A?g[M]:p[M],h[M]=O&&typeof g[M]!="function"?p[M]:T&&A?i(I,e):c&&g[M]==I?function(b){var E=function(L,D,R){if(this instanceof b){switch(arguments.length){case 0:return new b;case 1:return new b(L);case 2:return new b(L,D)}return new b(L,D,R)}return b.apply(this,arguments)};return E[o]=b[o],E}(I):m&&typeof I=="function"?i(Function.call,I):I,m&&((h.virtual||(h.virtual={}))[M]=I,v&f.R&&u&&!u[M]&&a(u,M,I)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,d.exports=f},function(d,r){var t=d.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=t)},function(d,r){var t=d.exports={version:"2.6.11"};typeof __e=="number"&&(__e=t)},function(d,r,t){var e=t(94);d.exports=function(n,i,a){if(e(n),i===void 0)return n;switch(a){case 1:return function(s){return n.call(i,s)};case 2:return function(s,o){return n.call(i,s,o)};case 3:return function(s,o,f){return n.call(i,s,o,f)}}return function(){return n.apply(i,arguments)}}},function(d,r){d.exports=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}},function(d,r,t){var e=t(96),n=t(104);d.exports=t(100)?function(i,a,s){return e.f(i,a,n(1,s))}:function(i,a,s){return i[a]=s,i}},function(d,r,t){var e=t(97),n=t(99),i=t(103),a=Object.defineProperty;r.f=t(100)?Object.defineProperty:function(o,f,v){if(e(o),f=i(f,!0),e(v),n)try{return a(o,f,v)}catch{}if("get"in v||"set"in v)throw TypeError("Accessors not supported!");return"value"in v&&(o[f]=v.value),o}},function(d,r,t){var e=t(98);d.exports=function(n){if(!e(n))throw TypeError(n+" is not an object!");return n}},function(d,r){d.exports=function(t){return typeof t=="object"?t!==null:typeof t=="function"}},function(d,r,t){d.exports=!t(100)&&!t(101)(function(){return Object.defineProperty(t(102)("div"),"a",{get:function(){return 7}}).a!=7})},function(d,r,t){d.exports=!t(101)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(d,r){d.exports=function(t){try{return!!t()}catch{return!0}}},function(d,r,t){var e=t(98),n=t(91).document,i=e(n)&&e(n.createElement);d.exports=function(a){return i?n.createElement(a):{}}},function(d,r,t){var e=t(98);d.exports=function(n,i){if(!e(n))return n;var a,s;if(i&&typeof(a=n.toString)=="function"&&!e(s=a.call(n))||typeof(a=n.valueOf)=="function"&&!e(s=a.call(n))||!i&&typeof(a=n.toString)=="function"&&!e(s=a.call(n)))return s;throw TypeError("Can't convert object to primitive value")}},function(d,r){d.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}},function(d,r){var t={}.hasOwnProperty;d.exports=function(e,n){return t.call(e,n)}},function(d,r,t){d.exports=t(95)},function(d,r,t){var e=t(108),n=t(104),i=t(121),a={};t(95)(a,t(122)("iterator"),function(){return this}),d.exports=function(s,o,f){s.prototype=e(a,{next:n(1,f)}),i(s,o+" Iterator")}},function(d,r,t){var e=t(97),n=t(109),i=t(119),a=t(116)("IE_PROTO"),s=function(){},o="prototype",f=function(){var v=t(102)("iframe"),l=i.length,p="<",y=">",O;for(v.style.display="none",t(120).appendChild(v),v.src="javascript:",O=v.contentWindow.document,O.open(),O.write(p+"script"+y+"document.F=Object"+p+"/script"+y),O.close(),f=O.F;l--;)delete f[o][i[l]];return f()};d.exports=Object.create||function(l,p){var y;return l!==null?(s[o]=e(l),y=new s,s[o]=null,y[a]=l):y=f(),p===void 0?y:n(y,p)}},function(d,r,t){var e=t(96),n=t(97),i=t(110);d.exports=t(100)?Object.defineProperties:function(s,o){n(s);for(var f=i(o),v=f.length,l=0,p;v>l;)e.f(s,p=f[l++],o[p]);return s}},function(d,r,t){var e=t(111),n=t(119);d.exports=Object.keys||function(a){return e(a,n)}},function(d,r,t){var e=t(105),n=t(84),i=t(112)(!1),a=t(116)("IE_PROTO");d.exports=function(s,o){var f=n(s),v=0,l=[],p;for(p in f)p!=a&&e(f,p)&&l.push(p);for(;o.length>v;)e(f,p=o[v++])&&(~i(l,p)||l.push(p));return l}},function(d,r,t){var e=t(84),n=t(113),i=t(115);d.exports=function(a){return function(s,o,f){var v=e(s),l=n(v.length),p=i(f,l),y;if(a&&o!=o){for(;l>p;)if(y=v[p++],y!=y)return!0}else for(;l>p;p++)if((a||p in v)&&v[p]===o)return a||p||0;return!a&&-1}}},function(d,r,t){var e=t(114),n=Math.min;d.exports=function(i){return i>0?n(e(i),9007199254740991):0}},function(d,r){var t=Math.ceil,e=Math.floor;d.exports=function(n){return isNaN(n=+n)?0:(n>0?e:t)(n)}},function(d,r,t){var e=t(114),n=Math.max,i=Math.min;d.exports=function(a,s){return a=e(a),a<0?n(a+s,0):i(a,s)}},function(d,r,t){var e=t(117)("keys"),n=t(118);d.exports=function(i){return e[i]||(e[i]=n(i))}},function(d,r,t){var e=t(92),n=t(91),i="__core-js_shared__",a=n[i]||(n[i]={});(d.exports=function(s,o){return a[s]||(a[s]=o!==void 0?o:{})})("versions",[]).push({version:e.version,mode:t(89)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(d,r){var t=0,e=Math.random();d.exports=function(n){return"Symbol(".concat(n===void 0?"":n,")_",(++t+e).toString(36))}},function(d,r){d.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(d,r,t){var e=t(91).document;d.exports=e&&e.documentElement},function(d,r,t){var e=t(96).f,n=t(105),i=t(122)("toStringTag");d.exports=function(a,s,o){a&&!n(a=o?a:a.prototype,i)&&e(a,i,{configurable:!0,value:s})}},function(d,r,t){var e=t(117)("wks"),n=t(118),i=t(91).Symbol,a=typeof i=="function",s=d.exports=function(o){return e[o]||(e[o]=a&&i[o]||(a?i:n)("Symbol."+o))};s.store=e},function(d,r,t){var e=t(105),n=t(124),i=t(116)("IE_PROTO"),a=Object.prototype;d.exports=Object.getPrototypeOf||function(s){return s=n(s),e(s,i)?s[i]:typeof s.constructor=="function"&&s instanceof s.constructor?s.constructor.prototype:s instanceof Object?a:null}},function(d,r,t){var e=t(87);d.exports=function(n){return Object(e(n))}},function(d,r,t){var e=t(126)(!0);t(88)(String,"String",function(n){this._t=String(n),this._i=0},function(){var n=this._t,i=this._i,a;return i>=n.length?{value:void 0,done:!0}:(a=e(n,i),this._i+=a.length,{value:a,done:!1})})},function(d,r,t){var e=t(114),n=t(87);d.exports=function(i){return function(a,s){var o=String(n(a)),f=e(s),v=o.length,l,p;return f<0||f>=v?i?"":void 0:(l=o.charCodeAt(f),l<55296||l>56319||f+1===v||(p=o.charCodeAt(f+1))<56320||p>57343?i?o.charAt(f):l:i?o.slice(f,f+2):(l-55296<<10)+(p-56320)+65536)}}},function(d,r,t){var e=t(128),n=t(122)("iterator"),i=t(83);d.exports=t(92).isIterable=function(a){var s=Object(a);return s[n]!==void 0||"@@iterator"in s||i.hasOwnProperty(e(s))}},function(d,r,t){var e=t(86),n=t(122)("toStringTag"),i=e(function(){return arguments}())=="Arguments",a=function(s,o){try{return s[o]}catch{}};d.exports=function(s){var o,f,v;return s===void 0?"Undefined":s===null?"Null":typeof(f=a(o=Object(s),n))=="string"?f:i?e(o):(v=e(o))=="Object"&&typeof o.callee=="function"?"Arguments":v}},function(d,r,t){d.exports={default:t(130),__esModule:!0}},function(d,r,t){t(79),t(125),d.exports=t(131)},function(d,r,t){var e=t(97),n=t(132);d.exports=t(92).getIterator=function(i){var a=n(i);if(typeof a!="function")throw TypeError(i+" is not iterable!");return e(a.call(i))}},function(d,r,t){var e=t(128),n=t(122)("iterator"),i=t(83);d.exports=t(92).getIteratorMethod=function(a){if(a!=null)return a[n]||a["@@iterator"]||i[e(a)]}},function(d,r,t){r.__esModule=!0;var e=t(134),n=i(e);function i(a){return a&&a.__esModule?a:{default:a}}r.default=function(a){if(Array.isArray(a)){for(var s=0,o=Array(a.length);s<a.length;s++)o[s]=a[s];return o}else return(0,n.default)(a)}},function(d,r,t){d.exports={default:t(135),__esModule:!0}},function(d,r,t){t(125),t(136),d.exports=t(92).Array.from},function(d,r,t){var e=t(93),n=t(90),i=t(124),a=t(137),s=t(138),o=t(113),f=t(139),v=t(132);n(n.S+n.F*!t(140)(function(l){Array.from(l)}),"Array",{from:function(p){var y=i(p),O=typeof this=="function"?this:Array,x=arguments.length,m=x>1?arguments[1]:void 0,T=m!==void 0,c=0,h=v(y),u,g,M,A;if(T&&(m=e(m,x>2?arguments[2]:void 0,2)),h!=null&&!(O==Array&&s(h)))for(A=h.call(y),g=new O;!(M=A.next()).done;c++)f(g,c,T?a(A,m,[M.value,c],!0):M.value);else for(u=o(y.length),g=new O(u);u>c;c++)f(g,c,T?m(y[c],c):y[c]);return g.length=c,g}})},function(d,r,t){var e=t(97);d.exports=function(n,i,a,s){try{return s?i(e(a)[0],a[1]):i(a)}catch(f){var o=n.return;throw o!==void 0&&e(o.call(n)),f}}},function(d,r,t){var e=t(83),n=t(122)("iterator"),i=Array.prototype;d.exports=function(a){return a!==void 0&&(e.Array===a||i[n]===a)}},function(d,r,t){var e=t(96),n=t(104);d.exports=function(i,a,s){a in i?e.f(i,a,n(0,s)):i[a]=s}},function(d,r,t){var e=t(122)("iterator"),n=!1;try{var i=[7][e]();i.return=function(){n=!0},Array.from(i,function(){throw 2})}catch{}d.exports=function(a,s){if(!s&&!n)return!1;var o=!1;try{var f=[7],v=f[e]();v.next=function(){return{done:o=!0}},f[e]=function(){return v},a(f)}catch{}return o}},function(d,r,t){d.exports={default:t(142),__esModule:!0}},function(d,r,t){t(143),t(125),t(79),t(144),t(157),t(160),t(162),d.exports=t(92).Map},function(d,r){},function(d,r,t){var e=t(145),n=t(151),i="Map";d.exports=t(152)(i,function(a){return function(){return a(this,arguments.length>0?arguments[0]:void 0)}},{get:function(s){var o=e.getEntry(n(this,i),s);return o&&o.v},set:function(s,o){return e.def(n(this,i),s===0?0:s,o)}},e,!0)},function(d,r,t){var e=t(96).f,n=t(108),i=t(146),a=t(93),s=t(147),o=t(148),f=t(88),v=t(82),l=t(149),p=t(100),y=t(150).fastKey,O=t(151),x=p?"_s":"size",m=function(T,c){var h=y(c),u;if(h!=="F")return T._i[h];for(u=T._f;u;u=u.n)if(u.k==c)return u};d.exports={getConstructor:function(T,c,h,u){var g=T(function(M,A){s(M,g,c,"_i"),M._t=c,M._i=n(null),M._f=void 0,M._l=void 0,M[x]=0,A!=null&&o(A,h,M[u],M)});return i(g.prototype,{clear:function(){for(var A=O(this,c),I=A._i,b=A._f;b;b=b.n)b.r=!0,b.p&&(b.p=b.p.n=void 0),delete I[b.i];A._f=A._l=void 0,A[x]=0},delete:function(M){var A=O(this,c),I=m(A,M);if(I){var b=I.n,E=I.p;delete A._i[I.i],I.r=!0,E&&(E.n=b),b&&(b.p=E),A._f==I&&(A._f=b),A._l==I&&(A._l=E),A[x]--}return!!I},forEach:function(A){O(this,c);for(var I=a(A,arguments.length>1?arguments[1]:void 0,3),b;b=b?b.n:this._f;)for(I(b.v,b.k,this);b&&b.r;)b=b.p},has:function(A){return!!m(O(this,c),A)}}),p&&e(g.prototype,"size",{get:function(){return O(this,c)[x]}}),g},def:function(T,c,h){var u=m(T,c),g,M;return u?u.v=h:(T._l=u={i:M=y(c,!0),k:c,v:h,p:g=T._l,n:void 0,r:!1},T._f||(T._f=u),g&&(g.n=u),T[x]++,M!=="F"&&(T._i[M]=u)),T},getEntry:m,setStrong:function(T,c,h){f(T,c,function(u,g){this._t=O(u,c),this._k=g,this._l=void 0},function(){for(var u=this,g=u._k,M=u._l;M&&M.r;)M=M.p;return!u._t||!(u._l=M=M?M.n:u._t._f)?(u._t=void 0,v(1)):g=="keys"?v(0,M.k):g=="values"?v(0,M.v):v(0,[M.k,M.v])},h?"entries":"values",!h,!0),l(c)}}},function(d,r,t){var e=t(95);d.exports=function(n,i,a){for(var s in i)a&&n[s]?n[s]=i[s]:e(n,s,i[s]);return n}},function(d,r){d.exports=function(t,e,n,i){if(!(t instanceof e)||i!==void 0&&i in t)throw TypeError(n+": incorrect invocation!");return t}},function(d,l,t){var e=t(93),n=t(137),i=t(138),a=t(97),s=t(113),o=t(132),f={},v={},l=d.exports=function(p,y,O,x,m){var T=m?function(){return p}:o(p),c=e(O,x,y?2:1),h=0,u,g,M,A;if(typeof T!="function")throw TypeError(p+" is not iterable!");if(i(T)){for(u=s(p.length);u>h;h++)if(A=y?c(a(g=p[h])[0],g[1]):c(p[h]),A===f||A===v)return A}else for(M=T.call(p);!(g=M.next()).done;)if(A=n(M,c,g.value,y),A===f||A===v)return A};l.BREAK=f,l.RETURN=v},function(d,r,t){var e=t(91),n=t(92),i=t(96),a=t(100),s=t(122)("species");d.exports=function(o){var f=typeof n[o]=="function"?n[o]:e[o];a&&f&&!f[s]&&i.f(f,s,{configurable:!0,get:function(){return this}})}},function(d,r,t){var e=t(118)("meta"),n=t(98),i=t(105),a=t(96).f,s=0,o=Object.isExtensible||function(){return!0},f=!t(101)(function(){return o(Object.preventExtensions({}))}),v=function(x){a(x,e,{value:{i:"O"+ ++s,w:{}}})},l=function(x,m){if(!n(x))return typeof x=="symbol"?x:(typeof x=="string"?"S":"P")+x;if(!i(x,e)){if(!o(x))return"F";if(!m)return"E";v(x)}return x[e].i},p=function(x,m){if(!i(x,e)){if(!o(x))return!0;if(!m)return!1;v(x)}return x[e].w},y=function(x){return f&&O.NEED&&o(x)&&!i(x,e)&&v(x),x},O=d.exports={KEY:e,NEED:!1,fastKey:l,getWeak:p,onFreeze:y}},function(d,r,t){var e=t(98);d.exports=function(n,i){if(!e(n)||n._t!==i)throw TypeError("Incompatible receiver, "+i+" required!");return n}},function(d,r,t){var e=t(91),n=t(90),i=t(150),a=t(101),s=t(95),o=t(146),f=t(148),v=t(147),l=t(98),p=t(121),y=t(96).f,O=t(153)(0),x=t(100);d.exports=function(m,T,c,h,u,g){var M=e[m],A=M,I=u?"set":"add",b=A&&A.prototype,E={};return!x||typeof A!="function"||!(g||b.forEach&&!a(function(){new A().entries().next()}))?(A=h.getConstructor(T,m,u,I),o(A.prototype,c),i.NEED=!0):(A=T(function(L,D){v(L,A,m,"_c"),L._c=new M,D!=null&&f(D,u,L[I],L)}),O("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),function(L){var D=L=="add"||L=="set";L in b&&!(g&&L=="clear")&&s(A.prototype,L,function(R,C){if(v(this,A,L),!D&&g&&!l(R))return L=="get"?void 0:!1;var W=this._c[L](R===0?0:R,C);return D?this:W})}),g||y(A.prototype,"size",{get:function(){return this._c.size}})),p(A,m),E[m]=A,n(n.G+n.W+n.F,E),g||h.setStrong(A,m,u),A}},function(d,r,t){var e=t(93),n=t(85),i=t(124),a=t(113),s=t(154);d.exports=function(o,f){var v=o==1,l=o==2,p=o==3,y=o==4,O=o==6,x=o==5||O,m=f||s;return function(T,c,h){for(var u=i(T),g=n(u),M=e(c,h,3),A=a(g.length),I=0,b=v?m(T,A):l?m(T,0):void 0,E,L;A>I;I++)if((x||I in g)&&(E=g[I],L=M(E,I,u),o)){if(v)b[I]=L;else if(L)switch(o){case 3:return!0;case 5:return E;case 6:return I;case 2:b.push(E)}else if(y)return!1}return O?-1:p||y?y:b}}},function(d,r,t){var e=t(155);d.exports=function(n,i){return new(e(n))(i)}},function(d,r,t){var e=t(98),n=t(156),i=t(122)("species");d.exports=function(a){var s;return n(a)&&(s=a.constructor,typeof s=="function"&&(s===Array||n(s.prototype))&&(s=void 0),e(s)&&(s=s[i],s===null&&(s=void 0))),s===void 0?Array:s}},function(d,r,t){var e=t(86);d.exports=Array.isArray||function(i){return e(i)=="Array"}},function(d,r,t){var e=t(90);e(e.P+e.R,"Map",{toJSON:t(158)("Map")})},function(d,r,t){var e=t(128),n=t(159);d.exports=function(i){return function(){if(e(this)!=i)throw TypeError(i+"#toJSON isn't generic");return n(this)}}},function(d,r,t){var e=t(148);d.exports=function(n,i){var a=[];return e(n,!1,a.push,a,i),a}},function(d,r,t){t(161)("Map")},function(d,r,t){var e=t(90);d.exports=function(n){e(e.S,n,{of:function(){for(var a=arguments.length,s=new Array(a);a--;)s[a]=arguments[a];return new this(s)}})}},function(d,r,t){t(163)("Map")},function(d,r,t){var e=t(90),n=t(94),i=t(93),a=t(148);d.exports=function(s){e(e.S,s,{from:function(f){var v=arguments[1],l,p,y,O;return n(this),l=v!==void 0,l&&n(v),f==null?new this:(p=[],l?(y=0,O=i(v,arguments[2],2),a(f,!1,function(x){p.push(O(x,y++))})):a(f,!1,p.push,p),new this(p))}})}},function(d,r,t){d.exports={default:t(165),__esModule:!0}},function(d,r,t){t(166),d.exports=t(92).Object.assign},function(d,r,t){var e=t(90);e(e.S+e.F,"Object",{assign:t(167)})},function(d,r,t){var e=t(100),n=t(110),i=t(168),a=t(169),s=t(124),o=t(85),f=Object.assign;d.exports=!f||t(101)(function(){var v={},l={},p=Symbol(),y="abcdefghijklmnopqrst";return v[p]=7,y.split("").forEach(function(O){l[O]=O}),f({},v)[p]!=7||Object.keys(f({},l)).join("")!=y})?function(l,p){for(var y=s(l),O=arguments.length,x=1,m=i.f,T=a.f;O>x;)for(var c=o(arguments[x++]),h=m?n(c).concat(m(c)):n(c),u=h.length,g=0,M;u>g;)M=h[g++],(!e||T.call(c,M))&&(y[M]=c[M]);return y}:f},function(d,r){r.f=Object.getOwnPropertySymbols},function(d,r){r.f={}.propertyIsEnumerable},function(d,r,t){r.__esModule=!0,r.default=function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}},function(d,r,t){r.__esModule=!0;var e=t(172),n=i(e);function i(a){return a&&a.__esModule?a:{default:a}}r.default=function(){function a(s,o){for(var f=0;f<o.length;f++){var v=o[f];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),(0,n.default)(s,v.key,v)}}return function(s,o,f){return o&&a(s.prototype,o),f&&a(s,f),s}}()},function(d,r,t){d.exports={default:t(173),__esModule:!0}},function(d,r,t){t(174);var e=t(92).Object;d.exports=function(i,a,s){return e.defineProperty(i,a,s)}},function(d,r,t){var e=t(90);e(e.S+e.F*!t(100),"Object",{defineProperty:t(96).f})},function(d,r,t){d.exports={default:t(176),__esModule:!0}},function(d,r,t){t(177),t(143),t(184),t(185),d.exports=t(92).Symbol},function(d,r,t){var e=t(91),n=t(105),i=t(100),a=t(90),s=t(106),o=t(150).KEY,f=t(101),v=t(117),l=t(121),p=t(118),y=t(122),O=t(178),x=t(179),m=t(180),T=t(156),c=t(97),h=t(98),u=t(124),g=t(84),M=t(103),A=t(104),I=t(108),b=t(181),E=t(183),L=t(168),D=t(96),R=t(110),C=E.f,W=D.f,z=b.f,H=e.Symbol,X=e.JSON,Z=X&&X.stringify,j="prototype",G=y("_hidden"),Q=y("toPrimitive"),tt={}.propertyIsEnumerable,et=v("symbol-registry"),at=v("symbols"),q=v("op-symbols"),pt=Object[j],dt=typeof H=="function"&&!!L.f,B=e.QObject,F=!B||!B[j]||!B[j].findChild,V=i&&f(function(){return I(W({},"a",{get:function(){return W(this,"a",{value:7}).a}})).a!=7})?function(ot,st,ft){var vt=C(pt,st);vt&&delete pt[st],W(ot,st,ft),vt&&ot!==pt&&W(pt,st,vt)}:W,J=function(ot){var st=at[ot]=I(H[j]);return st._k=ot,st},N=dt&&typeof H.iterator=="symbol"?function(ot){return typeof ot=="symbol"}:function(ot){return ot instanceof H},$=function(st,ft,vt){return st===pt&&$(q,ft,vt),c(st),ft=M(ft,!0),c(vt),n(at,ft)?(vt.enumerable?(n(st,G)&&st[G][ft]&&(st[G][ft]=!1),vt=I(vt,{enumerable:A(0,!1)})):(n(st,G)||W(st,G,A(1,{})),st[G][ft]=!0),V(st,ft,vt)):W(st,ft,vt)},S=function(st,ft){c(st);for(var vt=m(ft=g(ft)),mt=0,gt=vt.length,St;gt>mt;)$(st,St=vt[mt++],ft[St]);return st},P=function(st,ft){return ft===void 0?I(st):S(I(st),ft)},w=function(st){var ft=tt.call(this,st=M(st,!0));return this===pt&&n(at,st)&&!n(q,st)?!1:ft||!n(this,st)||!n(at,st)||n(this,G)&&this[G][st]?ft:!0},U=function(st,ft){if(st=g(st),ft=M(ft,!0),!(st===pt&&n(at,ft)&&!n(q,ft))){var vt=C(st,ft);return vt&&n(at,ft)&&!(n(st,G)&&st[G][ft])&&(vt.enumerable=!0),vt}},K=function(st){for(var ft=z(g(st)),vt=[],mt=0,gt;ft.length>mt;)!n(at,gt=ft[mt++])&&gt!=G&&gt!=o&&vt.push(gt);return vt},Y=function(st){for(var ft=st===pt,vt=z(ft?q:g(st)),mt=[],gt=0,St;vt.length>gt;)n(at,St=vt[gt++])&&(!ft||n(pt,St))&&mt.push(at[St]);return mt};dt||(H=function(){if(this instanceof H)throw TypeError("Symbol is not a constructor!");var st=p(arguments.length>0?arguments[0]:void 0),ft=function(vt){this===pt&&ft.call(q,vt),n(this,G)&&n(this[G],st)&&(this[G][st]=!1),V(this,st,A(1,vt))};return i&&F&&V(pt,st,{configurable:!0,set:ft}),J(st)},s(H[j],"toString",function(){return this._k}),E.f=U,D.f=$,t(182).f=b.f=K,t(169).f=w,L.f=Y,i&&!t(89)&&s(pt,"propertyIsEnumerable",w,!0),O.f=function(ot){return J(y(ot))}),a(a.G+a.W+a.F*!dt,{Symbol:H});for(var k="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;k.length>rt;)y(k[rt++]);for(var it=R(y.store),lt=0;it.length>lt;)x(it[lt++]);a(a.S+a.F*!dt,"Symbol",{for:function(ot){return n(et,ot+="")?et[ot]:et[ot]=H(ot)},keyFor:function(st){if(!N(st))throw TypeError(st+" is not a symbol!");for(var ft in et)if(et[ft]===st)return ft},useSetter:function(){F=!0},useSimple:function(){F=!1}}),a(a.S+a.F*!dt,"Object",{create:P,defineProperty:$,defineProperties:S,getOwnPropertyDescriptor:U,getOwnPropertyNames:K,getOwnPropertySymbols:Y});var ut=f(function(){L.f(1)});a(a.S+a.F*ut,"Object",{getOwnPropertySymbols:function(st){return L.f(u(st))}}),X&&a(a.S+a.F*(!dt||f(function(){var ot=H();return Z([ot])!="[null]"||Z({a:ot})!="{}"||Z(Object(ot))!="{}"})),"JSON",{stringify:function(st){for(var ft=[st],vt=1,mt,gt;arguments.length>vt;)ft.push(arguments[vt++]);if(gt=mt=ft[1],!(!h(mt)&&st===void 0||N(st)))return T(mt)||(mt=function(St,It){if(typeof gt=="function"&&(It=gt.call(this,St,It)),!N(It))return It}),ft[1]=mt,Z.apply(X,ft)}}),H[j][Q]||t(95)(H[j],Q,H[j].valueOf),l(H,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},function(d,r,t){r.f=t(122)},function(d,r,t){var e=t(91),n=t(92),i=t(89),a=t(178),s=t(96).f;d.exports=function(o){var f=n.Symbol||(n.Symbol=i?{}:e.Symbol||{});o.charAt(0)!="_"&&!(o in f)&&s(f,o,{value:a.f(o)})}},function(d,r,t){var e=t(110),n=t(168),i=t(169);d.exports=function(a){var s=e(a),o=n.f;if(o)for(var f=o(a),v=i.f,l=0,p;f.length>l;)v.call(a,p=f[l++])&&s.push(p);return s}},function(d,r,t){var e=t(84),n=t(182).f,i={}.toString,a=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(o){try{return n(o)}catch{return a.slice()}};d.exports.f=function(f){return a&&i.call(f)=="[object Window]"?s(f):n(e(f))}},function(d,r,t){var e=t(111),n=t(119).concat("length","prototype");r.f=Object.getOwnPropertyNames||function(a){return e(a,n)}},function(d,r,t){var e=t(169),n=t(104),i=t(84),a=t(103),s=t(105),o=t(99),f=Object.getOwnPropertyDescriptor;r.f=t(100)?f:function(l,p){if(l=i(l),p=a(p,!0),o)try{return f(l,p)}catch{}if(s(l,p))return n(!e.f.call(l,p),l[p])}},function(d,r,t){t(179)("asyncIterator")},function(d,r,t){t(179)("observable")},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.createNowTime=e,r.formatDelay=n;function e(){var i=null;return Date.now?i=Date.now:i=function(){return new Date().getTime()},i}function n(i){return typeof i=="number"?i={delay:i}:"entropy"in i&&(i={delay:i.entropy,isEntropy:!0}),i}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.default={default:function(n,i,a,s,o){return typeof n=="number"&&typeof i=="number"?n+(a-s)/(o-s)*(i-n):a-s>o-a?i:n}}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.parseEasing=r.Easings=void 0;var e=t(76),n=f(e),i=t(133),a=f(i),s=t(141),o=f(s);function f(T){return T&&T.__esModule?T:{default:T}}var v=t(189),l=new o.default;function p(){for(var T=arguments.length,c=Array(T),h=0;h<T;h++)c[h]=arguments[h];var u=l.get(c);return u||(u=v.apply(void 0,c),l.set(c,u),u)}function y(T){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"end";return function(h,u){for(var g=1;g<u.length;g++){var M=u[g].offset;if(h<=M){var A=u[g-1].offset,I=M,b=(h-A)/(I-A),E=1/T,L=b/E;return c==="end"?L=Math.floor(L):L=Math.ceil(L),E*L*(I-A)+A}}return 0}}function O(T){var c=/^cubic-bezier\((.*)\)/,h=T.match(c);if(h){var u=h[1].trim();return u=u.split(",").map(function(E){return parseFloat(E.trim())}),p.apply(void 0,(0,a.default)(u))}if(c=/^steps\((.*)\)/,h=T.match(c),h){var g=h[1].trim();g=g.split(",").map(function(E){return E.trim()});var M=g,A=(0,n.default)(M,2),I=A[0],b=A[1];return y(parseInt(I,10),b)}return T}var x={linear:function(c){return c},ease:p(.25,.1,.25,1),"ease-in":p(.42,0,1,1),"ease-out":p(0,0,.58,1),"ease-in-out":p(.42,0,.58,1),"step-start":y(1,"start"),"step-end":y(1,"end")};function m(T){return typeof T=="string"?x[T]?T=x[T]:T=O(T):T.type==="cubic-bezier"?T=p.apply(void 0,(0,a.default)(T.value)):T.type==="steps"&&(T=y(T.step,T.pos)),T}r.Easings=x,r.parseEasing=m},function(d,r){var t=4,e=.001,n=1e-7,i=10,a=11,s=1/(a-1),o=typeof Float32Array=="function";function f(T,c){return 1-3*c+3*T}function v(T,c){return 3*c-6*T}function l(T){return 3*T}function p(T,c,h){return((f(c,h)*T+v(c,h))*T+l(c))*T}function y(T,c,h){return 3*f(c,h)*T*T+2*v(c,h)*T+l(c)}function O(T,c,h,u,g){var M,A,I=0;do A=c+(h-c)/2,M=p(A,u,g)-T,M>0?h=A:c=A;while(Math.abs(M)>n&&++I<i);return A}function x(T,c,h,u){for(var g=0;g<t;++g){var M=y(c,h,u);if(M===0)return c;var A=p(c,h,u)-T;c-=A/M}return c}function m(T){return T}d.exports=function(c,h,u,g){if(!(0<=c&&c<=1&&0<=u&&u<=1))throw new Error("bezier x values must be in [0, 1] range");if(c===h&&u===g)return m;for(var M=o?new Float32Array(a):new Array(a),A=0;A<a;++A)M[A]=p(A*s,c,u);function I(b){for(var E=0,L=1,D=a-1;L!==D&&M[L]<=b;++L)E+=s;--L;var R=(b-M[L])/(M[L+1]-M[L]),C=E+R*s,W=y(C,c,u);return W>=e?x(b,C,c,u):W===0?C:O(b,E,E+s,c,u)}return function(E){return E===0?0:E===1?1:p(I(E),h,g)}}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});var e=t(191),n=h(e),i=t(204),a=h(i),s=t(164),o=h(s),f=t(170),v=h(f),l=t(171),p=h(l),y=t(175),O=h(y),x=t(75),m=h(x),T=t(208),c=t(188);function h(W){return W&&W.__esModule?W:{default:W}}var u=(0,O.default)("timing"),g=(0,O.default)("keyframes"),M=(0,O.default)("initState"),A=(0,O.default)("readyDefer"),I=(0,O.default)("finishedDefer"),b=(0,O.default)("effects"),E=(0,O.default)("activeReadyTimer"),L=(0,O.default)("activeFinishTimer"),D=(0,O.default)("removeDefer"),R={delay:0,endDelay:0,fill:"auto",iterations:1,playbackRate:1,direction:"normal",easing:"linear",effect:null},C=function(){function W(z,H,X){var Z=this;if((0,v.default)(this,W),Array.isArray(z)){var j=[z[0],z,H];z=j[0],H=j[1],X=j[2]}typeof X=="number"&&(X={duration:X}),this[u]=(0,o.default)({},R,X),this[u].easing=(0,c.parseEasing)(this[u].easing),this[g]=(0,T.calculateFramesOffset)(H);var G=this[g][this[g].length-1];this[M]={},(0,a.default)(G).forEach(function(Q){Object.prototype.hasOwnProperty.call(z,Q)&&Q!=="easing"&&Q!=="offset"&&(Z[M][Q]=z[Q])}),this[g]=this[g].map(function(Q){return(0,o.default)({},Z[M],Q)}),this[g][0].offset!==0&&this[g].unshift((0,o.default)({},this[M],{offset:0})),G.offset<1&&this[g].push((0,o.default)({},G,{offset:1})),this[b]={},this.timeline=null}return(0,p.default)(W,[{key:"pause",value:function(){this.timeline.playbackRate=0}},{key:E,value:function(){var H=this;this[A]&&!this[A].timerID&&(this.timeline.currentTime<0?this[A].timerID=this.timeline.setTimeout(function(){H[A].resolve(),delete H[A]},{delay:-this.timeline.currentTime,heading:!1}):this[A].timerID=this.timeline.setTimeout(function(){H[A].resolve(),delete H[A]},{delay:0,isEntropy:!0}))}},{key:L,value:function(){var H=this,X=this[u],Z=X.duration,j=X.iterations,G=X.endDelay,Q=Math.ceil(Z*j+G-this.timeline.currentTime)+1;this[I]&&!this[I].timerID&&(this[I].timerID=this.timeline.setTimeout(function(){H[I].resolve(),H[D](A),H[D](I)},{delay:Q,heading:!1}),this[I].reverseTimerID=this.timeline.setTimeout(function(){H[I].resolve(),H[D](A),H[D](I),H.timeline=null},{delay:-this[u].delay-1,heading:!1}))}},{key:"play",value:function(){if(this.playState==="finished"&&this.cancel(),this.playState==="idle"){if(this.playbackRate<=0)return;var H=this[u],X=H.delay,Z=H.playbackRate,j=H.timeline;this.timeline=new m.default({originTime:X,playbackRate:Z},j),this[E](),this[L]()}else this.playState==="paused"&&(this.timeline.playbackRate=this.playbackRate,this[E]())}},{key:D,value:function(H){var X=this[H],Z=this.timeline;X&&Z&&(Z.clearTimeout(X.timerID),X.reverseTimerID&&Z.clearTimeout(X.reverseTimerID)),delete this[H]}},{key:"cancel",value:function(){this[D](A),this[D](I),this.timeline=null}},{key:"finish",value:function(){this.timeline&&(this.timeline.currentTime=1/0/this.playbackRate),this[D](A),this[D](I)}},{key:"applyEffects",value:function(H){return(0,o.default)(this[b],H)}},{key:"playbackRate",get:function(){return this[u].playbackRate},set:function(H){this.timeline&&(this.timeline.playbackRate=H),this[u].playbackRate=H}},{key:"playState",get:function(){var H=this.timeline,X=this[u],Z=X.iterations,j=X.duration,G=X.endDelay,Q="running";if(H==null)Q="idle";else if(H.paused)Q="paused";else if(H.currentTime<0)Q="pending";else{var tt=H.currentTime-Z*j;tt>0&&tt<G?Q="pending":tt>=G&&(Q="finished")}return Q}},{key:"progress",get:function(){if(!this.timeline)return 0;var H=this[u],X=H.duration,Z=H.iterations,j=this.timeline,G=this.playState,Q=void 0;if(G==="idle")Q=0;else if(G==="paused"&&j.currentTime<0)Q=0;else if(G==="pending")if(j.currentTime<0)Q=0;else{var tt=j.seekLocalTime(Z*X);Q=(0,T.periodicity)(tt,X)[1]/X}else(G==="running"||G==="paused")&&(Q=(0,T.periodicity)(j.currentTime,X)[1]/X);return G==="finished"&&(Q=(0,T.periodicity)(Z,1)[1]),Q}},{key:"frame",get:function(){var H=this.playState,X=this[M],Z=this[u].fill;if(H==="idle")return X;var j=this.timeline.currentTime,G=this[g].slice(0),Q=(0,T.getProgress)(this.timeline,this[u],this.progress),tt=Q.p,et=Q.inverted,at=X;return j<0&&H==="pending"?(Z==="backwards"||Z==="both")&&(at=et?G[G.length-1]:G[0]):(H!=="pending"&&H!=="finished"||Z==="forwards"||Z==="both")&&(at=(0,T.getCurrentFrame)(this[u],G,this[b],tt)),at}},{key:"timing",get:function(){return this[u]}},{key:"effects",get:function(){return this[b]}},{key:"baseTimeline",set:function(H){this[u].timeline=H},get:function(){return this[u].timeline}},{key:"ready",get:function(){return this[A]?this[A].promise:this.timeline&&this.timeline.currentTime>=0&&this.playState!=="paused"?n.default.resolve():(this[A]=(0,T.defer)(),this.timeline&&this[E](),this[A]?this[A].promise:n.default.resolve())}},{key:"finished",get:function(){return this.playState==="finished"?n.default.resolve():(this[I]||(this[I]=(0,T.defer)(),this.timeline&&this[L]()),this[I].promise)}}]),W}();r.default=C},function(d,r,t){d.exports={default:t(192),__esModule:!0}},function(d,r,t){t(143),t(125),t(79),t(193),t(202),t(203),d.exports=t(92).Promise},function(d,r,t){var e=t(89),n=t(91),i=t(93),a=t(128),s=t(90),o=t(98),f=t(94),v=t(147),l=t(148),p=t(194),y=t(195).set,O=t(197)(),x=t(198),m=t(199),T=t(200),c=t(201),h="Promise",u=n.TypeError,g=n.process,M=g&&g.versions,A=M&&M.v8||"",I=n[h],b=a(g)=="process",E=function(){},L,D,R,C,W=D=x.f,z=!!function(){try{var et=I.resolve(1),at=(et.constructor={})[t(122)("species")]=function(q){q(E,E)};return(b||typeof PromiseRejectionEvent=="function")&&et.then(E)instanceof at&&A.indexOf("6.6")!==0&&T.indexOf("Chrome/66")===-1}catch{}}(),H=function(et){var at;return o(et)&&typeof(at=et.then)=="function"?at:!1},X=function(et,at){if(!et._n){et._n=!0;var q=et._c;O(function(){for(var pt=et._v,dt=et._s==1,B=0,F=function(V){var J=dt?V.ok:V.fail,N=V.resolve,$=V.reject,S=V.domain,P,w,U;try{J?(dt||(et._h==2&&G(et),et._h=1),J===!0?P=pt:(S&&S.enter(),P=J(pt),S&&(S.exit(),U=!0)),P===V.promise?$(u("Promise-chain cycle")):(w=H(P))?w.call(P,N,$):N(P)):$(pt)}catch(K){S&&!U&&S.exit(),$(K)}};q.length>B;)F(q[B++]);et._c=[],et._n=!1,at&&!et._h&&Z(et)})}},Z=function(et){y.call(n,function(){var at=et._v,q=j(et),pt,dt,B;if(q&&(pt=m(function(){b?g.emit("unhandledRejection",at,et):(dt=n.onunhandledrejection)?dt({promise:et,reason:at}):(B=n.console)&&B.error&&B.error("Unhandled promise rejection",at)}),et._h=b||j(et)?2:1),et._a=void 0,q&&pt.e)throw pt.v})},j=function(et){return et._h!==1&&(et._a||et._c).length===0},G=function(et){y.call(n,function(){var at;b?g.emit("rejectionHandled",et):(at=n.onrejectionhandled)&&at({promise:et,reason:et._v})})},Q=function(et){var at=this;at._d||(at._d=!0,at=at._w||at,at._v=et,at._s=2,at._a||(at._a=at._c.slice()),X(at,!0))},tt=function(et){var at=this,q;if(!at._d){at._d=!0,at=at._w||at;try{if(at===et)throw u("Promise can't be resolved itself");(q=H(et))?O(function(){var pt={_w:at,_d:!1};try{q.call(et,i(tt,pt,1),i(Q,pt,1))}catch(dt){Q.call(pt,dt)}}):(at._v=et,at._s=1,X(at,!1))}catch(pt){Q.call({_w:at,_d:!1},pt)}}};z||(I=function(at){v(this,I,h,"_h"),f(at),L.call(this);try{at(i(tt,this,1),i(Q,this,1))}catch(q){Q.call(this,q)}},L=function(at){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},L.prototype=t(146)(I.prototype,{then:function(at,q){var pt=W(p(this,I));return pt.ok=typeof at=="function"?at:!0,pt.fail=typeof q=="function"&&q,pt.domain=b?g.domain:void 0,this._c.push(pt),this._a&&this._a.push(pt),this._s&&X(this,!1),pt.promise},catch:function(et){return this.then(void 0,et)}}),R=function(){var et=new L;this.promise=et,this.resolve=i(tt,et,1),this.reject=i(Q,et,1)},x.f=W=function(et){return et===I||et===C?new R(et):D(et)}),s(s.G+s.W+s.F*!z,{Promise:I}),t(121)(I,h),t(149)(h),C=t(92)[h],s(s.S+s.F*!z,h,{reject:function(at){var q=W(this),pt=q.reject;return pt(at),q.promise}}),s(s.S+s.F*(e||!z),h,{resolve:function(at){return c(e&&this===C?I:this,at)}}),s(s.S+s.F*!(z&&t(140)(function(et){I.all(et).catch(E)})),h,{all:function(at){var q=this,pt=W(q),dt=pt.resolve,B=pt.reject,F=m(function(){var V=[],J=0,N=1;l(at,!1,function($){var S=J++,P=!1;V.push(void 0),N++,q.resolve($).then(function(w){P||(P=!0,V[S]=w,--N||dt(V))},B)}),--N||dt(V)});return F.e&&B(F.v),pt.promise},race:function(at){var q=this,pt=W(q),dt=pt.reject,B=m(function(){l(at,!1,function(F){q.resolve(F).then(pt.resolve,dt)})});return B.e&&dt(B.v),pt.promise}})},function(d,r,t){var e=t(97),n=t(94),i=t(122)("species");d.exports=function(a,s){var o=e(a).constructor,f;return o===void 0||(f=e(o)[i])==null?s:n(f)}},function(d,r,t){var e=t(93),n=t(196),i=t(120),a=t(102),s=t(91),o=s.process,f=s.setImmediate,v=s.clearImmediate,l=s.MessageChannel,p=s.Dispatch,y=0,O={},x="onreadystatechange",m,T,c,h=function(){var g=+this;if(O.hasOwnProperty(g)){var M=O[g];delete O[g],M()}},u=function(g){h.call(g.data)};(!f||!v)&&(f=function(M){for(var A=[],I=1;arguments.length>I;)A.push(arguments[I++]);return O[++y]=function(){n(typeof M=="function"?M:Function(M),A)},m(y),y},v=function(M){delete O[M]},t(86)(o)=="process"?m=function(g){o.nextTick(e(h,g,1))}:p&&p.now?m=function(g){p.now(e(h,g,1))}:l?(T=new l,c=T.port2,T.port1.onmessage=u,m=e(c.postMessage,c,1)):s.addEventListener&&typeof postMessage=="function"&&!s.importScripts?(m=function(g){s.postMessage(g+"","*")},s.addEventListener("message",u,!1)):x in a("script")?m=function(g){i.appendChild(a("script"))[x]=function(){i.removeChild(this),h.call(g)}}:m=function(g){setTimeout(e(h,g,1),0)}),d.exports={set:f,clear:v}},function(d,r){d.exports=function(t,e,n){var i=n===void 0;switch(e.length){case 0:return i?t():t.call(n);case 1:return i?t(e[0]):t.call(n,e[0]);case 2:return i?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return i?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return i?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(d,r,t){var e=t(91),n=t(195).set,i=e.MutationObserver||e.WebKitMutationObserver,a=e.process,s=e.Promise,o=t(86)(a)=="process";d.exports=function(){var f,v,l,p=function(){var m,T;for(o&&(m=a.domain)&&m.exit();f;){T=f.fn,f=f.next;try{T()}catch(c){throw f?l():v=void 0,c}}v=void 0,m&&m.enter()};if(o)l=function(){a.nextTick(p)};else if(i&&!(e.navigator&&e.navigator.standalone)){var y=!0,O=document.createTextNode("");new i(p).observe(O,{characterData:!0}),l=function(){O.data=y=!y}}else if(s&&s.resolve){var x=s.resolve(void 0);l=function(){x.then(p)}}else l=function(){n.call(e,p)};return function(m){var T={fn:m,next:void 0};v&&(v.next=T),f||(f=T,l()),v=T}}},function(d,r,t){var e=t(94);function n(i){var a,s;this.promise=new i(function(o,f){if(a!==void 0||s!==void 0)throw TypeError("Bad Promise constructor");a=o,s=f}),this.resolve=e(a),this.reject=e(s)}d.exports.f=function(i){return new n(i)}},function(d,r){d.exports=function(t){try{return{e:!1,v:t()}}catch(e){return{e:!0,v:e}}}},function(d,r,t){var e=t(91),n=e.navigator;d.exports=n&&n.userAgent||""},function(d,r,t){var e=t(97),n=t(98),i=t(198);d.exports=function(a,s){if(e(a),n(s)&&s.constructor===a)return s;var o=i.f(a),f=o.resolve;return f(s),o.promise}},function(d,r,t){var e=t(90),n=t(92),i=t(91),a=t(194),s=t(201);e(e.P+e.R,"Promise",{finally:function(o){var f=a(this,n.Promise||i.Promise),v=typeof o=="function";return this.then(v?function(l){return s(f,o()).then(function(){return l})}:o,v?function(l){return s(f,o()).then(function(){throw l})}:o)}})},function(d,r,t){var e=t(90),n=t(198),i=t(199);e(e.S,"Promise",{try:function(a){var s=n.f(this),o=i(a);return(o.e?s.reject:s.resolve)(o.v),s.promise}})},function(d,r,t){d.exports={default:t(205),__esModule:!0}},function(d,r,t){t(206),d.exports=t(92).Object.keys},function(d,r,t){var e=t(124),n=t(110);t(207)("keys",function(){return function(a){return n(e(a))}})},function(d,r,t){var e=t(90),n=t(92),i=t(101);d.exports=function(a,s){var o=(n.Object||{})[a]||Object[a],f={};f[a]=s(o),e(e.S+e.F*i(function(){o(1)}),"Object",f)}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});var e=t(76),n=O(e),i=t(209),a=O(i),s=t(164),o=O(s),f=t(191),v=O(f);r.defer=x,r.periodicity=m,r.calculateFramesOffset=T,r.getProgress=c,r.getCurrentFrame=u;var l=t(188),p=t(187),y=O(p);function O(g){return g&&g.__esModule?g:{default:g}}function x(){var g={};return g.promise=new v.default(function(M,A){g.resolve=M,g.reject=A}),g}function m(g,M){var A=Math.floor(g/M),I=g-A*M;return I===0&&A>0&&(I=M,A--),[A,I]}function T(g){g=g.slice(0);var M=g[0],A=g[g.length-1];A.offset=A.offset||1,M.offset=M.offset||0;for(var I=0,b=-1,E=0;E<g.length;E++){var L=g[E];if(L.offset!=null){var D=E-b;if(D>1)for(var R=(L.offset-I)/D,C=0;C<D-1;C++)g[b+C+1].offset=I+R*(C+1);I=L.offset,b=E}if(L.easing!=null&&(L.easing=(0,l.parseEasing)(L.easing)),E>0){var W=g[E].easing!=null;g[E]=(0,o.default)({},g[E-1],g[E]),W||delete g[E].easing}}return g}function c(g,M,A){var I=g.currentTime,b=M.direction,E=M.duration,L=!1;if(b==="reverse")A=1-A,L=!0;else if(b==="alternate"||b==="alternate-reverse"){var D=Math.floor(I/E);A===1&&D--,D%2^b==="alternate-reverse"&&(A=1-A,L=!0)}return{p:A,inverted:L}}function h(g,M,A,I){var b={};return(0,a.default)(M).forEach(function(E){var L=(0,n.default)(E,2),D=L[0],R=L[1];if(D!=="offset"&&D!=="easing"){var C=A[D]||A.default,W=C(g[D],R,I,g.offset,M.offset);W!=null&&(b[D]=W)}}),b}function u(g,M,A,I){var b=g.easing,E=g.effect;E||(A=(0,o.default)({},y.default,A));var L={};I=b(I,M);for(var D=1;D<M.length;D++){var R=M[D],C=R.offset;if(C>=I||D===M.length-1){var W=M[D-1],z=W.offset,H=W.easing,X=I;if(H){var Z=C-z;X=H((I-z)/Z)*Z+z}E?L=E(W,R,X,z,C):L=h(W,R,A,X);break}}return L}},function(d,r,t){d.exports={default:t(210),__esModule:!0}},function(d,r,t){t(211),d.exports=t(92).Object.entries},function(d,r,t){var e=t(90),n=t(212)(!0);e(e.S,"Object",{entries:function(a){return n(a)}})},function(d,r,t){var e=t(100),n=t(110),i=t(84),a=t(169).f;d.exports=function(s){return function(o){for(var f=i(o),v=n(f),l=v.length,p=0,y=[],O;l>p;)O=v[p++],(!e||a.call(f,O))&&y.push(s?[O,f[O]]:f[O]);return y}}},function(d,r,t){t.r(r),t(1).glMatrix.setMatrixArrayType(Array);const e=new Map;function n(a,s={},o=[]){a=a.toLowerCase();const f=e.get(a);if(!f)throw new TypeError(`Invalid node: ${a}`);const v=new f(s);return o.forEach(l=>{v.appendChild(l)}),v}const i={registerNode(a,s,o=100){if(s=s.toLowerCase(),e.has(s))throw new TypeError(`Cannot registerNode, ${s} has been taken.`);e.set(s,a),Object.defineProperties(a.prototype,{nodeType:{value:o},tagName:{value:s.toUpperCase()},nodeName:{value:s},ownerDocument:{value:i},namespaceURI:{value:`http://spritejs.com/${s}`}})},createElement:n,createElementNS(a,s){return n(s)},isSpriteNode(a){return e.has(a.toLowerCase())}};r.default=i},function(d,r,t){t.r(r),t.d(r,"default",function(){return s}),t(1).glMatrix.setMatrixArrayType(Array);const e=Symbol("type"),n=Symbol("bubbles"),i=Symbol("originalEvent"),a=Symbol("detail");class s{constructor(f,{bubbles:v=null}={}){if(typeof f=="string"?(this[e]=f,this[n]=!!v):(this[e]=f.type,this[i]=f,this[n]=v!=null?!!v:!!f.bubbles,f.detail&&(this[a]=f.detail)),!this[e])throw new TypeError("Invalid event type.");this.cancelBubble=!1}setOriginalEvent(f){this[i]=f}get originalEvent(){return this[i]}get type(){return this[e]}get bubbles(){return this[n]}get detail(){return this[a]}stopPropagation(){this.cancelBubble=!0}}},function(d,r,t){t.r(r),t.d(r,"parseFilterString",function(){return n}),t.d(r,"applyFilters",function(){return i});var e=t(72);t(1).glMatrix.setMatrixArrayType(Array);function n(a){if(a=a.trim(),!a||a==="none")return null;const s=/^(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+$/i,o=a.match(/(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+?/ig),f=[];return o&&o.forEach(v=>{const l=v.match(s);if(!l)throw new TypeError("Invalid fitler string.");let[,p,y]=l;p=p.toLowerCase(),y=y.trim().match(/([^( )]+|([^( )]+\(.*\)))(?=\s|$)/g).map((O,x)=>{let m;return p==="url"||p==="drop-shadow"&&x===3?m=O:m=Object(e.toNumber)(O),/%$/.test(O)&&(m/=100),m}),f.push({type:p,args:y})}),f}function i(a,s){a.clearFilter(),s&&s.forEach(({type:o,args:f})=>{let v=o;v==="drop-shadow"?v="dropShadow":v==="hue-rotate"&&(v="hueRotate"),a[v](...f)})}},function(d,r,t){t.r(r),t.d(r,"default",function(){return e}),t(1).glMatrix.setMatrixArrayType(Array);function e(n,i){if(!i)return;const a=n.getListeners("beforerender"),s=n.getListeners("afterrender");a.length&&!i.beforeRender?i.beforeRender=o=>{n.dispatchEvent({type:"beforerender",detail:{context:o}})}:a.length||(i.beforeRender=null),s.length&&!i.afterRender?i.afterRender=o=>{n.dispatchEvent({type:"afterrender",detail:{context:o}})}:s.length||(i.afterRender=null)}},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(12),n=t(218),i=t(70),a=t(213);t(1).glMatrix.setMatrixArrayType(Array);const s=Symbol("amount"),o=Symbol("meshCloud");class f extends i.default{constructor(l,p=1){super(),this.meshNode=l,l.connect(this),this[s]=p,this[o]=null}get meshCloud(){const l=this.meshNode,p=this[s];return!this[o]&&l.mesh&&(this[o]=new e.MeshCloud(l.mesh,p)),this[o]}get isVisible(){return!!this.meshNode&&this.meshNode.isVisible}get amount(){return this[s]}set amount(l){this[s]=l,this[o]&&(this[o].amount=l)}brightness(l,p){this.meshCloud&&(this.meshCloud.brightness(l,p),this.forceUpdate())}contrast(l,p){this.meshCloud&&(this.meshCloud.contrast(l,p),this.forceUpdate())}delete(l){this.meshCloud&&(this.meshCloud.delete(l),this[s]--,this.forceUpdate())}draw(l=[]){if(super.draw(l),this.meshCloud){if(this.program){this.meshCloud.setProgram(this.program);const p=this.shaderAttrs;p&&Object.entries(p).forEach(([O,x])=>{this.meshCloud.mesh.setAttribute(O,x)});const y=this.uniforms;if(this.uniforms){const O={};Object.entries(y).forEach(([x,m])=>{typeof m=="function"&&(m=m(this,x)),O[x]=m}),this.meshCloud.mesh.setUniforms(O)}}this.meshNode.textureImage&&Object(n.drawTexture)(this.meshNode,this.meshNode.mesh),l.push(this.meshCloud)}return l}getTransform(l){if(this.meshCloud)return this.meshCloud.getTransform(l)}grayscale(l,p){this.meshCloud&&(this.meshCloud.grayscale(l,p),this.forceUpdate())}hueRotate(l,p){this.meshCloud&&(this.meshCloud.hueRotate(l,p),this.forceUpdate())}invert(l,p){this.meshCloud&&(this.meshCloud.invert(l,p),this.forceUpdate())}isPointCollision(l,p){if(!this.meshCloud)return!1;const y=this.attributes.pointerEvents;if(y==="none"||y!=="all"&&!this.isVisible)return!1;let O="both";y==="visibleFill"&&(O="fill"),y==="visibleStroke"&&(O="stroke");for(let x=0;x<this[s];x++)if(!this.meshCloud.isPointCollision(x,[l,p],O))return!1;return!0}setOpacity(l,p){this.meshCloud&&(this.meshCloud.opacity(l,p),this.forceUpdate())}rotate(l,p,[y,O]=[0,0]){const x=Math.PI*p/180;if(this.meshCloud){const{x:m,y:T}=this.meshNode.attributes;this.meshCloud.rotate(l,x,[y+m,O+T]),this.forceUpdate()}}saturate(l,p){this.meshCloud&&(this.meshCloud.saturate(l,p),this.forceUpdate())}scale(l,[p,y=p],[O,x]=[0,0]){if(this.meshCloud){const{x:m,y:T}=this.meshNode.attributes,c=1e-5;Math.abs(p)<c&&(p=1/p>0?c:-c),Math.abs(y)<c&&(y=1/y>0?c:-c),this.meshCloud.scale(l,[p,y],[O+m,x+T]),this.forceUpdate()}}setColorTransform(l,p){this.meshCloud&&(this.meshCloud.setColorTransform(l,p),this.forceUpdate())}setFillColor(l,p){this.meshCloud&&(Array.isArray(p)&&(p=[...p],p[0]/=255,p[1]/=255,p[2]/=255),this.meshCloud.setFillColor(l,p),this.forceUpdate())}sepia(l,p){this.meshCloud&&(this.meshCloud.sepia(l,p),this.forceUpdate())}setResolution({width:l,height:p}){super.setResolution({width:l,height:p}),this.meshNode.setResolution({width:l,height:p})}setStrokeColor(l,p){this.meshCloud&&(Array.isArray(p)&&(p=[...p],p[0]/=255,p[1]/=255,p[2]/=255),this.meshCloud.setStrokeColor(l,p),this.forceUpdate())}setTransform(l,p){this.meshCloud&&(this.meshCloud.setTransform(l,p),this.forceUpdate())}skew(l,[p,y=p],[O,x]=[0,0]){if(this.meshCloud){const{x:m,y:T}=this.meshNode.attributes;this.meshCloud.skew(l,[p,y],[O+m,x+T]),this.forceUpdate()}}transform(l,p){this.meshCloud&&(this.meshCloud.transform(l,p),this.forceUpdate())}transformColor(l,p){this.meshCloud&&(this.meshCloud.transformColor(l,p),this.forceUpdate())}translate(l,[p,y]){this.meshCloud&&(this.meshCloud.translate(l,[p,y]),this.forceUpdate())}updateMesh(){this[o]&&(this[o].mesh=this.meshNode.mesh,this.forceUpdate())}}a.default.registerNode(f,"cloud")},function(d,r,t){t.r(r),t.d(r,"loadTexture",function(){return a}),t.d(r,"applyTexture",function(){return s}),t.d(r,"createTexture",function(){return f}),t.d(r,"deleteTexture",function(){return v}),t.d(r,"drawTexture",function(){return p}),t.d(r,"loadFrames",function(){return y});var e=t(12),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i={};function a(O,x){if(i[O])return i[O];const m=e.ENV.loadImage(O,{alias:x,useImageBitmap:!1});return m??O}async function s(O,x,m){let T=x;if(typeof x=="string"&&(T=a(x)),T&&typeof T.then=="function"&&(T=await T),x===O.attributes.texture){T&&T.image&&(T.sourceRect&&(O.attributes.sourceRect=T.sourceRect),O.textureImageRotated=!!T.rotated,T=T.image);const{width:c,height:h,textureRect:u}=O.attributes,g=O.textureImage;O.textureImage=T,m&&g!==T&&!u&&(c==null||h==null)&&O.updateContours(),O.forceUpdate()}return T}const o=Symbol("textureMap");function f(O,x){if(x[o]=x[o]||new Map,x[o].has(O))return x[o].get(O);const m=x.createTexture(O);return!/^blob:/.test(O.src)&&typeof O.getContext!="function"&&x[o].set(O,m),m}function v(O,x){if(x[o]&&x[o].has(O)){const m=x[o].get(O);return x.deleteTexture(m),x[o].delete(O),!0}return!1}const l=Symbol("textureContext");function p(O,x){const m=O.textureImage instanceof String?String(O.textureImage):O.textureImage,T=O.textureImageRotated,c=x.texture,h=O.renderer;if(m){const u=O.originalContentRect;let g=O.attributes.textureRect;const M=O.attributes.textureRepeat,A=O.attributes.sourceRect;if(!c||O[l]&&O[l]!==h||c.image!==m||c.options.repeat!==M||!Object(n.compareValue)(c.options.rect,g)||!Object(n.compareValue)(c.options.srcRect,A)){const I=f(m,h);g?(g[0]+=u[0],g[1]+=u[1]):g=u;let b=null;c&&!h[o].has(c.image)&&(!c.options||!c.options.hidden)&&(b=x.uniforms.u_texSampler),x.setTexture(I,{rect:g,repeat:M,srcRect:A,rotated:T}),b&&b.delete&&b.delete(),O[l]=h}}else if(c){let u=null;!h[o].has(c.image)&&(!c.options||!c.options.hidden)&&(u=x.uniforms.u_texSampler),x.setTexture(null),u&&u.delete&&u.delete()}}async function y(O,x){typeof x=="string"&&(x=await(await fetch(x,{method:"GET",mode:"cors",cache:"default"})).json());const m=await a(O),T=x.frames;return Object.entries(T).forEach(([c,h])=>{const{x:u,y:g,w:M,h:A}=h.frame;let I=[u,g,M,A];const b=h.rotated;b&&(I=[I[0],I[1],I[3],I[2]]),i[c]={image:m,sourceRect:I,rotated:b}}),m}},function(d,r,t){t.r(r),t.d(r,"default",function(){return y});var e=t(1),n=t(12),i=t(70),a=t(220),s=t(221),o=t(222),f=t(213),v=t(223);t(1).glMatrix.setMatrixArrayType(Array);function l(O,x,m){return x in O?Object.defineProperty(O,x,{value:m,enumerable:!0,configurable:!0,writable:!0}):O[x]=m,O}const p=Symbol("mesh");class y extends i.default{constructor(x={}){super(x)}get borderSize(){const{paddingTop:x,paddingRight:m,paddingBottom:T,paddingLeft:c,borderWidth:h}=this.attributes,[u,g]=this.contentSize;return[c+u+m+h,x+g+T+h]}get clientSize(){const{paddingTop:x,paddingRight:m,paddingBottom:T,paddingLeft:c}=this.attributes,[h,u]=this.contentSize;return[c+h+m,x+u+T]}get contentSize(){let{width:x,height:m,boxSizing:T,paddingTop:c,paddingRight:h,paddingBottom:u,paddingLeft:g}=this.attributes;if(x=x||0,m=m||0,T==="border-box"){const M=2*this.attributes.borderWidth;x-=M+h+g,m-=M+c+u,x=Math.max(0,x),m=Math.max(0,m)}return[x,m]}get hasBorder(){return this.attributes.borderWidth>0}get isVisible(){const[x,m]=this.borderSize;return x>0&&m>0}get mesh(){if(this.attributes.display==="none")return null;const x=this.clientBox;if(x){let m=this[p];if(m)m.box!==x&&(m.contours=x.contours,m.box=x);else{m=new n.Mesh2D(x),m.box=x;const c=this.attributes.bgcolor;if(Object(s.setFillColor)(m,{color:c}),this.hasBorder){const{borderColor:u,borderWidth:g,borderDash:M,borderDashOffset:A}=this.attributes;Object(s.setStrokeColor)(m,{color:u,lineWidth:g,lineDash:M,lineDashOffset:A})}this[p]=m;const h=this.attributes.clipPath;h&&this[p].setClipPath(h)}const T=this.opacity;return m.getOpacity()!==T&&m.setOpacity(T),m.setTransform(...this.renderMatrix),m}return null}get offsetSize(){const{paddingTop:x,paddingRight:m,paddingBottom:T,paddingLeft:c,borderWidth:h}=this.attributes,[u,g]=this.contentSize,M=2*h;return[c+u+m+M,x+g+T+M]}get originalClientRect(){if(this.mesh){const x=this.mesh.boundingBox;return[x[0][0],x[0][1],x[1][0]-x[0][0],x[1][1]-x[0][1]]}return[0,0,0,0]}get originalContentRect(){const[x,m,T,c]=this.originalClientRect,h=this.attributes.padding;return[x+h[0],m+h[1],T-h[0]-h[2],c-h[1]-h[3]]}getBoundingClientRect(){let x=this.renderMatrix;this.layer&&this.layer.layerTransformInvert&&(x=e.mat2d.multiply(Array.of(0,0,0,0,0,0),this.layer.transformMatrix,x));let m=null;if(this.mesh){m=[...this.mesh.boundingBox];const T=this.attributes.borderWidth;T&&(m[0]=[m[0][0]-T,m[0][1]-T],m[1]=[m[1][0]+T,m[1][1]+T])}return Object(v.default)(m,x)}onPropertyChange(x,m,T){if(super.onPropertyChange(x,m,T),(x==="anchorX"||x==="anchorY"||x==="boxSizing"||x==="width"||x==="height"||x==="borderWidth"||x==="paddingLeft"||x==="paddingRight"||x==="paddingTop"||x==="paddingBottom"||/^border(TopLeft|TopRight|BottomRight|BottomLeft)Radius$/.test(x))&&this.updateContours(),this[p]&&x==="clipPath"&&this[p].setClipPath(m),this[p]&&x==="bgcolor"&&Object(s.setFillColor)(this[p],{color:m}),this[p]&&(x==="borderColor"||x==="borderWidth"||x==="borderDash"||x==="borderDashOffset")){const{borderColor:c,borderWidth:h,borderDash:u,borderDashOffset:g}=this.attributes;Object(s.setStrokeColor)(this[p],{color:c,lineWidth:h,lineDash:h?u:0,lineDashOffset:g})}}updateContours(){const{anchorX:x,anchorY:m,borderWidth:T,borderRadius:c}=this.attributes,[h,u]=this.borderSize,g=this.offsetSize,M=.5*T,A=-x*g[0]+M,I=-m*g[1]+M;this.clientBox=new n.Figure2D,Object(o.createRadiusBox)(this.clientBox,[A,I,h,u],c)}}l(y,"Attr",a.default),f.default.registerNode(y,"block")},function(d,r,t){t.r(r),t.d(r,"default",function(){return v});var e=t(71),n=t(72),i=t(221);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute"),o=Symbol.for("spritejs_setAttributeDefault"),f=Symbol.for("spritejs_declareAlias");class v extends e.default{constructor(p){super(p),this[o]({anchorX:0,anchorY:0,width:void 0,height:void 0,borderWidth:0,borderColor:"rgba(0,0,0,1)",borderDash:void 0,borderDashOffset:0,borderTopLeftRadius:[0,0],borderTopRightRadius:[0,0],borderBottomRightRadius:[0,0],borderBottomLeftRadius:[0,0],bgcolor:"rgba(0,0,0,0)",paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,boxSizing:"content-box",clipPath:void 0}),this[f]("anchor","size","border","borderRadius","padding")}get anchorX(){return this[s]("anchorX")}set anchorX(p){this[a]("anchorX",Object(n.toNumber)(p))}get anchorY(){return this[s]("anchorY")}set anchorY(p){this[a]("anchorY",Object(n.toNumber)(p))}get anchor(){return[this.anchorX,this.anchorY]}set anchor(p){p=Object(n.toArray)(p),Array.isArray(p)||(p=[p,p]),this.anchorX=p[0],this.anchorY=p[1]}get width(){return this[s]("width")}set width(p){this[a]("width",Object(n.toNumber)(p))}get height(){return this[s]("height")}set height(p){this[a]("height",Object(n.toNumber)(p))}get size(){return[this.width,this.height]}set size(p){p=Object(n.toArray)(p),Array.isArray(p)||(p=[p,p]),this.width=p[0],this.height=p[1]}get borderWidth(){return this[s]("borderWidth")}set borderWidth(p){this[a]("borderWidth",Object(n.toNumber)(p))}get borderColor(){return this[s]("borderColor")}set borderColor(p){this[a]("borderColor",Object(i.parseColor)(p))}get border(){return[this.borderWidth,this.borderColor]}set border(p){p=Object(n.toArray)(p),Array.isArray(p)||(p=[p]),this.borderWidth=p[0],p[1]!=null&&(this.borderColor=p[1])}get borderDash(){return this[s]("borderDash")}set borderDash(p){p=Object(n.toArray)(p,!0),p!=null&&!Array.isArray(p)&&(p=[p]),this[a]("borderDash",p?p.map(n.toNumber):null)}get borderDashOffset(){return this[s]("borderDashOffset")}set borderDashOffset(p){this[a]("borderDashOffset",Object(n.toNumber)(p))}get borderTopLeftRadius(){return this[s]("borderTopLeftRadius")}set borderTopLeftRadius(p){p=Object(n.toArray)(p,!0),Array.isArray(p)||(p=[p,p]),this[a]("borderTopLeftRadius",p.map(n.toNumber))}get borderTopRightRadius(){return this[s]("borderTopRightRadius")}set borderTopRightRadius(p){p=Object(n.toArray)(p,!0),Array.isArray(p)||(p=[p,p]),this[a]("borderTopRightRadius",p.map(n.toNumber))}get borderBottomRightRadius(){return this[s]("borderBottomRightRadius")}set borderBottomRightRadius(p){p=Object(n.toArray)(p,!0),Array.isArray(p)||(p=[p,p]),this[a]("borderBottomRightRadius",p.map(n.toNumber))}get borderBottomLeftRadius(){return this[s]("borderBottomLeftRadius")}set borderBottomLeftRadius(p){p=Object(n.toArray)(p,!0),Array.isArray(p)||(p=[p,p]),this[a]("borderBottomLeftRadius",p.map(n.toNumber))}get borderRadius(){return[...this.borderTopLeftRadius,...this.borderTopRightRadius,...this.borderBottomRightRadius,...this.borderBottomLeftRadius]}set borderRadius(p){if(p=Object(n.toArray)(p),!Array.isArray(p))p=Array(8).fill(p);else if(p.length===2)p=[p[0],p[1],p[0],p[1],p[0],p[1],p[0],p[1]];else if(p.length===4)p=[p[0],p[1],p[2],p[3],p[0],p[1],p[2],p[3]];else if(p.length===6)p=[p[0],p[1],p[2],p[3],p[4],p[5],p[2],p[3]];else if(p.length!==8)throw new TypeError("Invalid borderRadius value.");this.borderTopLeftRadius=[p[0],p[1]],this.borderTopRightRadius=[p[2],p[3]],this.borderBottomRightRadius=[p[4],p[5]],this.borderBottomLeftRadius=[p[6],p[7]]}get bgcolor(){return this[s]("bgcolor")}set bgcolor(p){this[a]("bgcolor",Object(i.parseColor)(p))}get paddingTop(){return this[s]("paddingTop")}set paddingTop(p){this[a]("paddingTop",Object(n.toNumber)(p))}get paddingRight(){return this[s]("paddingRight")}set paddingRight(p){this[a]("paddingRight",Object(n.toNumber)(p))}get paddingBottom(){return this[s]("paddingBottom")}set paddingBottom(p){this[a]("paddingBottom",Object(n.toNumber)(p))}get paddingLeft(){return this[s]("paddingLeft")}set paddingLeft(p){this[a]("paddingLeft",Object(n.toNumber)(p))}get padding(){return[this.paddingTop,this.paddingRight,this.paddingBottom,this.paddingLeft]}set padding(p){p=Object(n.toArray)(p),Array.isArray(p)?p.length===2?p=[p[0],p[1],p[0],p[1]]:p.length===3&&(p=[p[0],p[1],p[2],p[1]]):p=[p,p,p,p],this.paddingTop=p[0],this.paddingRight=p[1],this.paddingBottom=p[2],this.paddingLeft=p[3]}get clipPath(){return this[s]("clipPath")}set clipPath(p){this[a]("clipPath",p)}get boxSizing(){return this[s]("boxSizing")}set boxSizing(p){if(p!=null&&p!=="border-box"&&p!=="content-box")throw new TypeError("Invalid boxSizing type.");this[a]("boxSizing",p)}}},function(d,r,t){t.r(r),t.d(r,"Gradient",function(){return i}),t.d(r,"isTransparent",function(){return a}),t.d(r,"parseColor",function(){return s}),t.d(r,"setFillColor",function(){return f}),t.d(r,"setStrokeColor",function(){return v}),t.d(r,"Color",function(){return l});var e=t(32),n=t.n(e);t(1).glMatrix.setMatrixArrayType(Array);class i{constructor({vector:y,colors:O}){if(!Array.isArray(y)||y.length!==4&&y.length!==6&&y.length!==3)throw new TypeError("Invalid gradient");this.vector=y,this.colors=O.map(({offset:x,color:m})=>({offset:x,color:s(m)}))}toString(){return JSON.stringify({vector:this.vector,colors:this.colors})}}function a(p){return p instanceof i?!1:p==null?!0:n()(p)[3]===0}function s(p){if(p==null||(p||(p="transparent"),p instanceof i))return p;const y=n()(p);if(!y||!y.length)throw new TypeError("Invalid color value.");return`rgba(${y.join()})`}function o(p,y,O){const x=p.boundingBox[0];if(O.vector){let{vector:m,colors:T}=O;m.length===4?(m=[m[0]+x[0],m[1]+x[1],m[2]+x[0],m[3]+x[1]],p.setLinearGradient({vector:m,colors:T,type:y})):m.length===3?(m=[m[0]+x[0],m[1]+x[1],m[2]],p.setCircularGradient({vector:m,colors:T,type:y})):(m=[m[0]+x[0],m[1]+x[1],m[2],m[3]+x[0],m[4]+x[1],m[5]],p.setRadialGradient({vector:m,colors:T,type:y}))}else p.gradient&&p.gradient[y]&&(delete p.gradient[y],delete p.uniforms.u_radialGradientVector)}function f(p,{color:y,rule:O="nonzero"}){return o(p,"fill",y),y.vector||p.setFill({color:y,rule:O}),p}function v(p,{color:y,lineWidth:O,lineCap:x,lineJoin:m,lineDash:T,lineDashOffset:c,miterLimit:h,roundSegments:u}){o(p,"stroke",y),y.vector&&(y=[0,0,0,1]),p.setStroke({color:y,thickness:O,cap:x,join:m,miterLimit:h,lineDash:T,lineDashOffset:c,roundSegments:u})}class l extends Array{constructor(y=0,O=0,x=0,m=0){return Array.isArray(y)&&([y,O,x,m]=y),typeof y=="string"&&([y,O,x,m]=n()(y),y/=255,O/=255,x/=255),super(y,O,x,m),this}get r(){return Math.round(this[0]*255)}set r(y){this[0]=y/255}get g(){return Math.round(this[1]*255)}set g(y){this[1]=y/255}get b(){return Math.round(this[2]*255)}set b(y){this[2]=y/255}get a(){return this[3]}set a(y){this[3]=y}get hex(){const y=`0${this.r.toString(16)}`.slice(-2),O=`0${this.g.toString(16)}`.slice(-2),x=`0${this.b.toString(16)}`.slice(-2);let m;return this.a<1&&(m=Math.round(this[3]*255),m=`0${m.toString(16)}`.slice(-2)),`#${y}${O}${x}${m||""}`}get rgba(){return`rgba(${this.r},${this.g},${this.b},${this.a})`}fromColor(y){return typeof y=="string"&&(y=n()(y),y[0]/=255,y[1]/=255,y[2]/=255),this[0]=y[0],this[1]=y[1],this[2]=y[2],this[3]=y[3],this}}},function(d,r,t){t.r(r),t.d(r,"createRadiusBox",function(){return n}),t(1).glMatrix.setMatrixArrayType(Array);function e(i,a,s,o,f,v="leftTop"){const l=.5522848,p=o/2*l,y=f/2*l,O=a+o,x=s+f,m=a+o/2,T=s+f/2;v==="leftTop"?(i.moveTo(a,T),i.bezierCurveTo(a,T-y,m-p,s,m,s)):v==="rightTop"?i.bezierCurveTo(m+p,s,O,T-y,O,T):v==="rightBottom"?i.bezierCurveTo(O,T+y,m+p,x,m,x):v==="leftBottom"&&i.bezierCurveTo(m-p,x,a,T+y,a,T)}function n(i,[a,s,o,f],v){if(!v||Array.isArray(v)&&v.every(l=>l===0))i.beginPath(),i.rect(a,s,o,f);else{typeof v=="number"&&(v=Array(8).fill(v));const[l,p,y,O,x,m,T,c]=v.map((h,u)=>u%2?Math.min(h,f/2):Math.min(h,o/2));i.beginPath(),i.moveTo(a,s+p),e(i,a,s,l*2,p*2,"leftTop"),i.lineTo(a+o-y,s),e(i,a+o-y*2,s,y*2,O*2,"rightTop"),i.lineTo(a+o,s+f-m),e(i,a+o-x*2,s+f-m*2,x*2,m*2,"rightBottom"),i.lineTo(a+T,s+f),e(i,a,s+f-c*2,T*2,c*2,"leftBottom"),i.closePath()}return i}},function(d,r,t){t.r(r),t(1).glMatrix.setMatrixArrayType(Array),r.default=function(e,n){if(!e)return{x:0,y:0,width:0,height:0,left:0,top:0,right:0,bottom:0};const[[i,a],[s,o]]=e,f=i*n[0]+a*n[2]+n[4],v=i*n[1]+a*n[3]+n[5],l=s*n[0]+a*n[2]+n[4],p=s*n[1]+a*n[3]+n[5],y=s*n[0]+o*n[2]+n[4],O=s*n[1]+o*n[3]+n[5],x=i*n[0]+o*n[2]+n[4],m=i*n[1]+o*n[3]+n[5],T=Math.min(f,l,y,x),c=Math.min(v,p,O,m),h=Math.max(f,l,y,x),u=Math.max(v,p,O,m);return{x:T,y:c,width:h-T,height:u-c,left:T,top:c,right:h,bottom:u}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(218),n=t(219),i=t(225),a=t(213);t(1).glMatrix.setMatrixArrayType(Array);function s(v,l,p){return l in v?Object.defineProperty(v,l,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[l]=p,v}const o=Symbol("textureTask");class f extends n.default{constructor(l={}){typeof l=="string"&&(l={texture:l}),super(l)}get contentSize(){let[l,p]=super.contentSize;const{width:y,height:O}=this.attributes;if(y==null||O==null){const x=this.textureImage,m=this.attributes.textureRect,T=this.attributes.sourceRect;if(m)y==null&&(l=m[0]+m[2]),O==null&&(p=m[1]+m[3]);else if(T){const c=this.layer?this.layer.displayRatio:1;y==null&&(l=T[2]/c),O==null&&(p=T[3]/c)}else if(x){const c=this.layer?this.layer.displayRatio:1;y==null&&(l=x.width/c),O==null&&(p=x.height/c)}}return[l,p]}get textureImageReady(){return this[o]||Promise.resolve()}draw(l=[]){super.draw(l);const p=this.mesh;return p&&Object(e.drawTexture)(this,p),l}onPropertyChange(l,p,y){if(super.onPropertyChange(l,p,y),l==="texture"&&(this[o]=Object(e.applyTexture)(this,p,!0)),l==="textureRect"){const{width:O,height:x}=this.attributes;(O==null||x==null)&&this.updateContours()}}}s(f,"Attr",i.default),a.default.registerNode(f,"sprite")},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(220);t(1).glMatrix.setMatrixArrayType(Array);const n=Symbol.for("spritejs_setAttributeDefault"),i=Symbol.for("spritejs_setAttribute"),a=Symbol.for("spritejs_getAttribute");class s extends e.default{constructor(f){super(f),this[n]({texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0})}get texture(){return this[a]("texture")}set texture(f){this[i]("texture",f)}get textureRect(){return this[a]("textureRect")}set textureRect(f){this[i]("textureRect",f)}get sourceRect(){return this[a]("sourceRect")}set sourceRect(f){this[i]("sourceRect",f)}get textureRepeat(){return this[a]("textureRepeat")}set textureRepeat(f){this[i]("textureRepeat",!!f)}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return O});var e=t(12),n=t(227),i=t.n(n),a=t(70),s=t(228),o=t(221),f=t(218),v=t(213),l=t(223);t(1).glMatrix.setMatrixArrayType(Array);function p(x,m,T){return m in x?Object.defineProperty(x,m,{value:T,enumerable:!0,configurable:!0,writable:!0}):x[m]=T,x}const y=Symbol("mesh");class O extends a.default{constructor(m={}){typeof m=="string"&&(m={d:m}),super(m),this.effects={d(T,c,h,u,g){const M=(h-u)/(g-u);if(M<=0)return T;if(M>=1)return c;const A=i.a._preprocessing(i.a.path2shapes(T),i.a.path2shapes(c)),I=i.a._lerp(...A,M)[0];return I.reduce((E,L)=>`${E}${L.slice(2).join(" ")} `,`M${I[0][0]} ${I[0][1]}C`).trim()}}}get isVisible(){return!!this.d}get mesh(){if(this.attributes.display==="none")return null;const m=this.path;if(m){let T=this[y];if(T)T.path!==m&&(T.contours=m.contours,T.path=m);else{T=new e.Mesh2D(this.path),T.path=m;const h=this.attributes.fillColor,u=this.attributes.fillRule;h&&Object(o.setFillColor)(T,{color:h,rule:u});const g=this.attributes.lineWidth,M=this.attributes.strokeColor;if(M&&g>0){const{lineCap:I,lineJoin:b,miterLimit:E,lineDash:L,lineDashOffset:D,roundSegments:R}=this.attributes;Object(o.setStrokeColor)(T,{color:M,lineWidth:g,lineCap:I,lineJoin:b,miterLimit:E,lineDash:L,lineDashOffset:D,roundSegments:R})}this[y]=T;const A=this.attributes.clipPath;A&&this[y].setClipPath(A)}const c=this.opacity;return T.getOpacity()!==c&&T.setOpacity(c),T.setTransform(...this.renderMatrix),T}return null}get originalContentRect(){if(this.path){const m=this.path.boundingBox;return[m[0][0],m[0][1],m[1][0]-m[0][0],m[1][1]-m[0][1]]}return[0,0,0,0]}get originalClientRect(){if(this.mesh){const m=this.mesh.boundingBox;return[m[0][0],m[0][1],m[1][0]-m[0][0],m[1][1]-m[0][1]]}return[0,0,0,0]}get originalClientCenter(){return this.mesh?this.mesh.boundingCenter:[0,0]}set d(m){this.attributes.d=m}get d(){return this.attributes.d}draw(m=[]){super.draw(m);const T=this.mesh;return T&&Object(f.drawTexture)(this,T),m}getBoundingClientRect(){let m=null;return this.mesh&&(m=this.mesh.boundingBox),Object(l.default)(m,this.renderMatrix)}getPathLength(){return this.mesh?this.mesh.getTotalLength():0}getPointAtLength(m){if(this.mesh){const T=this.mesh.getPointAtLength(m);if(T)return[T.x,T.y]}return[0,0]}onPropertyChange(m,T,c){if(super.onPropertyChange(m,T,c),(m==="d"||m==="normalize")&&this.updateContours(),this[y]&&(m==="fillColor"||m==="fillRule")){const{fillColor:h,fillRule:u}=this.attributes;Object(o.setFillColor)(this[y],{color:h,rule:u})}if(this[y]&&(m==="strokeColor"||m==="lineWidth"||m==="lineCap"||m==="lineJoin"||m==="lineDash"||m==="lineDashOffset"||m==="roundSegments")){const{strokeColor:h,lineWidth:u}=this.attributes;if(h&&u>0){const{lineCap:g,lineJoin:M,lineDash:A,lineDashOffset:I,miterLimit:b,roundSegments:E}=this.attributes;Object(o.setStrokeColor)(this[y],{color:h,lineCap:g,lineJoin:M,lineWidth:u,lineDash:A,lineDashOffset:I,miterLimit:b,roundSegments:E})}}this[y]&&m==="clipPath"&&this[y].setClipPath(T),m==="texture"&&Object(f.applyTexture)(this,T)}updateContours(){this.path=new e.Figure2D,this.path.addPath(this.attributes.d),this.attributes.normalize&&this.path.normalize(...this.path.boundingCenter)}}p(O,"Attr",s.default),v.default.registerNode(O,"path")},function(d,r,t){(function(e,n){d.exports=n()})(this,function(){var e=function(){function L(D,R){var C=[],W=!0,z=!1,H=void 0;try{for(var X=D[Symbol.iterator](),Z;!(W=(Z=X.next()).done)&&(C.push(Z.value),!(R&&C.length===R));W=!0);}catch(j){z=!0,H=j}finally{try{!W&&X.return&&X.return()}finally{if(z)throw H}}return C}return function(D,R){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return L(D,R);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=Math.PI*2,i=function(D,R,C,W,z,H,X){var Z=D.x,j=D.y;Z*=R,j*=C;var G=W*Z-z*j,Q=z*Z+W*j;return{x:G+H,y:Q+X}},a=function(D,R){var C=1.3333333333333333*Math.tan(R/4),W=Math.cos(D),z=Math.sin(D),H=Math.cos(D+R),X=Math.sin(D+R);return[{x:W-z*C,y:z+W*C},{x:H+X*C,y:X-H*C},{x:H,y:X}]},s=function(D,R,C,W){var z=D*W-R*C<0?-1:1,H=Math.sqrt(D*D+R*R),X=Math.sqrt(D*D+R*R),Z=D*C+R*W,j=Z/(H*X);return j>1&&(j=1),j<-1&&(j=-1),z*Math.acos(j)},o=function(D,R,C,W,z,H,X,Z,j,G,Q,tt){var et=Math.pow(z,2),at=Math.pow(H,2),q=Math.pow(Q,2),pt=Math.pow(tt,2),dt=et*at-et*pt-at*q;dt<0&&(dt=0),dt/=et*pt+at*q,dt=Math.sqrt(dt)*(X===Z?-1:1);var B=dt*z/H*tt,F=dt*-H/z*Q,V=G*B-j*F+(D+C)/2,J=j*B+G*F+(R+W)/2,N=(Q-B)/z,$=(tt-F)/H,S=(-Q-B)/z,P=(-tt-F)/H,w=s(1,0,N,$),U=s(N,$,S,P);return Z===0&&U>0&&(U-=n),Z===1&&U<0&&(U+=n),[V,J,w,U]},f=function(D){var R=D.px,C=D.py,W=D.cx,z=D.cy,H=D.rx,X=D.ry,Z=D.xAxisRotation,j=Z===void 0?0:Z,G=D.largeArcFlag,Q=G===void 0?0:G,tt=D.sweepFlag,et=tt===void 0?0:tt,at=[];if(H===0||X===0)return[];var q=Math.sin(j*n/360),pt=Math.cos(j*n/360),dt=pt*(R-W)/2+q*(C-z)/2,B=-q*(R-W)/2+pt*(C-z)/2;if(dt===0&&B===0)return[];H=Math.abs(H),X=Math.abs(X);var F=Math.pow(dt,2)/Math.pow(H,2)+Math.pow(B,2)/Math.pow(X,2);F>1&&(H*=Math.sqrt(F),X*=Math.sqrt(F));var V=o(R,C,W,z,H,X,Q,et,q,pt,dt,B),J=e(V,4),N=J[0],$=J[1],S=J[2],P=J[3],w=Math.max(Math.ceil(Math.abs(P)/(n/4)),1);P/=w;for(var U=0;U<w;U++)at.push(a(S,P)),S+=P;return at.map(function(K){var Y=i(K[0],H,X,pt,q,N,$),k=Y.x,rt=Y.y,it=i(K[1],H,X,pt,q,N,$),lt=it.x,ut=it.y,ot=i(K[2],H,X,pt,q,N,$),st=ot.x,ft=ot.y;return{x1:k,y1:rt,x2:lt,y2:ut,x:st,y:ft}})},v={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},l=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function p(L){var D=[];return L.replace(l,function(R,C,W){var z=C.toLowerCase();for(W=O(W),z=="m"&&W.length>2&&(D.push([C].concat(W.splice(0,2))),z="l",C=C=="m"?"l":"L");;){if(W.length==v[z])return W.unshift(C),D.push(W);if(W.length<v[z])throw new Error("malformed path data");D.push([C].concat(W.splice(0,v[z])))}}),D}var y=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function O(L){var D=L.match(y);return D?D.map(Number):[]}function x(L){var D=L[0][0],R=L[0][1],C=D,W=R;return L.forEach(function(z){var H=z[0],X=z[2],Z=z[4],j=z[6],G=z[1],Q=z[3],tt=z[5],et=z[7];D=Math.min(D,H,X,Z,j),R=Math.min(R,G,Q,tt,et),C=Math.max(C,H,X,Z,j),W=Math.max(W,G,Q,tt,et)}),[D,R,C,W]}function m(L,D){return Math.sqrt(Math.pow(L[0]-D[0],2)+Math.pow(L[1]-D[1],2))+Math.sqrt(Math.pow(L[2]-D[2],2)+Math.pow(L[3]-D[3],2))}function T(L,D){var R=L[0],C=L[2],W=L[4],z=L[6],H=L[1],X=L[3],Z=L[5],j=L[7],G=D[0],Q=D[2],tt=D[4],et=D[6],at=D[1],q=D[3],pt=D[5],dt=D[7];return Math.sqrt(Math.pow(G-R,2)+Math.pow(at-H,2))+Math.sqrt(Math.pow(Q-C,2)+Math.pow(q-X,2))+Math.sqrt(Math.pow(tt-W,2)+Math.pow(pt-Z,2))+Math.sqrt(Math.pow(et-z,2)+Math.pow(dt-j,2))}function c(L,D){var R=u(L.length),C=[];R.forEach(function(z){var H=0,X=0;z.forEach(function(Z){H+=T(L[Z],D[X++])}),C.push({index:z,distance:H})}),C.sort(function(z,H){return z.distance-H.distance});var W=[];return C[0].index.forEach(function(z){W.push(L[z])}),W}function h(L,D){var R=g(L.length),C=[];R.forEach(function(z){var H=0;z.forEach(function(X){H+=m(x(L[X]),x(D[X]))}),C.push({index:z,distance:H})}),C.sort(function(z,H){return z.distance-H.distance});var W=[];return C[0].index.forEach(function(z){W.push(L[z])}),W}function u(L){for(var D=[],R=0;R<L;R++){for(var C=[],W=0;W<L;W++){var z=W+R;z>L-1&&(z-=L),C[z]=W}D.push(C)}return D}function g(L){for(var D=[],R=0;R<L;R++)D.push(R);return M(D)}function M(L){var D=[],R=[];function C(W){var z,H;for(z=0;z<W.length;z++)H=W.splice(z,1)[0],R.push(H),W.length==0&&D.push(R.slice()),C(W),W.splice(z,0,H),R.pop();return D}return C(L)}var A={};A.parser=p,A.lerpCurve=function(L,D,R){return A.lerpPoints(L[0],L[1],D[0],D[1],R).concat(A.lerpPoints(L[2],L[3],D[2],D[3],R)).concat(A.lerpPoints(L[4],L[5],D[4],D[5],R)).concat(A.lerpPoints(L[6],L[7],D[6],D[7],R))},A.lerpPoints=function(L,D,R,C,W){return[L+(R-L)*W,D+(C-D)*W]},A.q2b=function(L,D,R,C,W,z){return[L,D,(L+2*R)/3,(D+2*C)/3,(W+2*R)/3,(z+2*C)/3,W,z]},A.path2shapes=function(L){for(var D=A.parser(L),R=0,C=0,W=0,z=D.length,H=[],X=null,Z=void 0,j=void 0,G=void 0,Q=void 0,tt=void 0,et=void 0,at=void 0;W<z;W++){var q=D[W],pt=q[0],dt=D[W-1];switch(pt){case"m":tt=H.length,H[tt]=[],X=H[tt],R=R+q[1],C=C+q[2];break;case"M":tt=H.length,H[tt]=[],X=H[tt],R=q[1],C=q[2];break;case"l":X.push([R,C,R,C,R,C,R+q[1],C+q[2]]),R+=q[1],C+=q[2];break;case"L":X.push([R,C,q[1],q[2],q[1],q[2],q[1],q[2]]),R=q[1],C=q[2];break;case"h":X.push([R,C,R,C,R,C,R+q[1],C]),R+=q[1];break;case"H":X.push([R,C,q[1],C,q[1],C,q[1],C]),R=q[1];break;case"v":X.push([R,C,R,C,R,C,R,C+q[1]]),C+=q[1];break;case"V":X.push([R,C,R,q[1],R,q[1],R,q[1]]),C=q[1];break;case"C":X.push([R,C,q[1],q[2],q[3],q[4],q[5],q[6]]),R=q[5],C=q[6];break;case"S":dt[0]==="C"||dt[0]==="c"?X.push([R,C,R+dt[5]-dt[3],C+dt[6]-dt[4],q[1],q[2],q[3],q[4]]):(dt[0]==="S"||dt[0]==="s")&&X.push([R,C,R+dt[3]-dt[1],C+dt[4]-dt[2],q[1],q[2],q[3],q[4]]),R=q[3],C=q[4];break;case"c":X.push([R,C,R+q[1],C+q[2],R+q[3],C+q[4],R+q[5],C+q[6]]),R=R+q[5],C=C+q[6];break;case"s":dt[0]==="C"||dt[0]==="c"?X.push([R,C,R+dt[5]-dt[3],C+dt[6]-dt[4],R+q[1],C+q[2],R+q[3],C+q[4]]):(dt[0]==="S"||dt[0]==="s")&&X.push([R,C,R+dt[3]-dt[1],C+dt[4]-dt[2],R+q[1],C+q[2],R+q[3],C+q[4]]),R=R+q[3],C=C+q[4];break;case"a":et=f({rx:q[1],ry:q[2],px:R,py:C,xAxisRotation:q[3],largeArcFlag:q[4],sweepFlag:q[5],cx:R+q[6],cy:C+q[7]}),at=et[et.length-1],et.forEach(function(B,F){F===0?X.push([R,C,B.x1,B.y1,B.x2,B.y2,B.x,B.y]):X.push([et[F-1].x,et[F-1].y,B.x1,B.y1,B.x2,B.y2,B.x,B.y])}),R=at.x,C=at.y;break;case"A":et=f({rx:q[1],ry:q[2],px:R,py:C,xAxisRotation:q[3],largeArcFlag:q[4],sweepFlag:q[5],cx:q[6],cy:q[7]}),at=et[et.length-1],et.forEach(function(B,F){F===0?X.push([R,C,B.x1,B.y1,B.x2,B.y2,B.x,B.y]):X.push([et[F-1].x,et[F-1].y,B.x1,B.y1,B.x2,B.y2,B.x,B.y])}),R=at.x,C=at.y;break;case"Q":X.push(A.q2b(R,C,q[1],q[2],q[3],q[4])),R=q[3],C=q[4];break;case"q":X.push(A.q2b(R,C,R+q[1],C+q[2],q[3]+R,q[4]+C)),R+=q[3],C+=q[4];break;case"T":dt[0]==="Q"||dt[0]==="q"?(G=R+dt[3]-dt[1],Q=C+dt[4]-dt[2],X.push(A.q2b(R,C,G,Q,q[1],q[2]))):(dt[0]==="T"||dt[0]==="t")&&(X.push(A.q2b(R,C,R+R-G,C+C-Q,q[1],q[2])),G=R+R-G,Q=C+C-Q),R=q[1],C=q[2];break;case"t":dt[0]==="Q"||dt[0]==="q"?(G=R+dt[3]-dt[1],Q=C+dt[4]-dt[2],X.push(A.q2b(R,C,G,Q,R+q[1],C+q[2]))):(dt[0]==="T"||dt[0]==="t")&&(X.push(A.q2b(R,C,R+R-G,C+C-Q,R+q[1],C+q[2])),G=R+R-G,Q=C+C-Q),R+=q[1],C+=q[2];break;case"Z":Z=X[0][0],j=X[0][1],X.push([R,C,Z,j,Z,j,Z,j]);break;case"z":Z=X[0][0],j=X[0][1],X.push([R,C,Z,j,Z,j,Z,j]);break}}return H},A._upCurves=function(L,D){for(var R=0,C=0,W=L.length;R<D;R++)L.push(L[C].slice(0)),C++,C>W-1&&(C-=W)};function I(L,D,R,C,W,z,H,X,Z){return{left:b(L,D,R,C,W,z,H,X,Z),right:b(H,X,W,z,R,C,L,D,1-Z,!0)}}function b(L,D,R,C,W,z,H,X,Z,j){var G=(R-L)*Z+L,Q=(C-D)*Z+D,tt=(W-R)*Z+R,et=(z-C)*Z+C,at=(H-W)*Z+W,q=(X-z)*Z+z,pt=(tt-G)*Z+G,dt=(et-Q)*Z+Q,B=(at-tt)*Z+tt,F=(q-et)*Z+et,V=(B-pt)*Z+pt,J=(F-dt)*Z+dt;return j?[V,J,pt,dt,G,Q,L,D]:[L,D,G,Q,pt,dt,V,J]}A._splitCurves=function(L,D){for(var R=0,C=0;R<D;R++){var W=L[C],z=I(W[0],W[1],W[2],W[3],W[4],W[5],W[6],W[7],.5);L.splice(C,1),L.splice(C,0,z.left,z.right),C+=2,C>=L.length-1&&(C=0)}};function E(L,D){for(var R=function(z){var H=L[L.length-1],X=[];H.forEach(function(Z){X.push(Z.slice(0))}),L.push(X)},C=0;C<D;C++)R()}return A.lerp=function(L,D,R){return A._lerp(A.path2shapes(L),A.path2shapes(D),R)},A.MIM_CURVES_COUNT=100,A._preprocessing=function(L,D){var R=L.length,C=D.length,W=JSON.parse(JSON.stringify(L)),z=JSON.parse(JSON.stringify(D));return R>C?E(z,R-C):R<C&&E(W,C-R),W=h(W,z),W.forEach(function(H,X){var Z=H.length,j=z[X].length;Z>j?Z<A.MIM_CURVES_COUNT?(A._splitCurves(H,A.MIM_CURVES_COUNT-Z),A._splitCurves(z[X],A.MIM_CURVES_COUNT-j)):A._splitCurves(z[X],Z-j):Z<j&&(j<A.MIM_CURVES_COUNT?(A._splitCurves(H,A.MIM_CURVES_COUNT-Z),A._splitCurves(z[X],A.MIM_CURVES_COUNT-j)):A._splitCurves(H,j-Z))}),W.forEach(function(H,X){W[X]=c(H,z[X])}),[W,z]},A._lerp=function(L,D,R){var C=[];return L.forEach(function(W,z){var H=[];W.forEach(function(X,Z){H.push(A.lerpCurve(X,D[z][Z],R))}),C.push(H)}),C},A.animate=function(L){var D=A.path2shapes(L.from),R=A.path2shapes(L.to),C=A._preprocessing(D,R),W=new Date,z=L.end||function(){},H=L.progress||function(){},X=L.begin||function(){},Z=L.easing||function(et){return et},j=null,G=null,Q=L.time;X(D);var tt=function et(){var at=new Date-W;if(at>=Q){G=R,H(G,1),z(G),cancelAnimationFrame(j);return}var q=Z(at/Q);G=A._lerp(C[0],C[1],q),H(G,q),j=requestAnimationFrame(et)};tt()},A})},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(71),n=t(221),i=t(72);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttributeDefault"),s=Symbol.for("spritejs_setAttribute"),o=Symbol.for("spritejs_getAttribute");class f extends e.default{constructor(l){super(l),this[a]({d:"",normalize:!1,fillColor:void 0,fillRule:"nonzero",strokeColor:void 0,lineWidth:1,lineJoin:"miter",lineCap:"butt",roundSegments:20,lineDash:void 0,lineDashOffset:0,miterLimit:10,texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0,clipPath:void 0})}get d(){return this[o]("d")}set d(l){this[s]("d",l)}get normalize(){return this[o]("normalize")}set normalize(l){this[s]("normalize",!!l)}get fillColor(){return this[o]("fillColor")}set fillColor(l){this[s]("fillColor",Object(n.parseColor)(l))}get fillRule(){return this[o]("fillRule")}set fillRule(l){if(l!=null&&l!=="nonzero"&&l!=="evenodd")throw new TypeError("Invalid fill rule.");this[s]("fillRule",l)}get strokeColor(){return this[o]("strokeColor")}set strokeColor(l){this[s]("strokeColor",Object(n.parseColor)(l))}get lineWidth(){return this[o]("lineWidth")}set lineWidth(l){this[s]("lineWidth",Object(i.toNumber)(l))}get lineJoin(){return this[o]("lineJoin")}set lineJoin(l){if(l!=null&&l!=="miter"&&l!=="bevel"&&l!=="round")throw new TypeError("Invalid lineJoin type.");this[s]("lineJoin",l)}get lineCap(){return this[o]("lineCap")}set lineCap(l){if(l!=null&&l!=="butt"&&l!=="square"&&l!=="round")throw new TypeError("Invalid lineCap type.");this[s]("lineCap",l)}get lineDash(){return this[o]("lineDash")}set lineDash(l){l=Object(i.toArray)(l,!0),l!=null&&!Array.isArray(l)&&(l=[l]),this[s]("lineDash",l?l.map(i.toNumber):null)}get lineDashOffset(){return this[o]("lineDashOffset")}set lineDashOffset(l){this[s]("lineDashOffset",Object(i.toNumber)(l))}get miterLimit(){return this[o]("miterLimit")}set miterLimit(l){this[s]("miterLimit",Object(i.toNumber)(l))}get roundSegments(){return this[o]("roundSegments")}set roundSegments(l){this[s]("roundSegments",l)}get texture(){return this[o]("texture")}set texture(l){this[s]("texture",l)}get textureRect(){return this[o]("textureRect")}set textureRect(l){this[s]("textureRect",l)}get sourceRect(){return this[o]("sourceRect")}set sourceRect(l){this[s]("sourceRect",l)}get textureRepeat(){return this[o]("textureRepeat")}set textureRepeat(l){this[s]("textureRepeat",!!l)}get clipPath(){return this[o]("clipPath")}set clipPath(l){this[s]("clipPath",l)}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(226),n=t(213),i=t(230);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{width:f,height:v}=this.attributes;return f>0&&v>0&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"rect")},function(d,r,t){t.r(r),t.d(r,"default",function(){return v});var e=t(228),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i=Symbol.for("spritejs_setAttributeDefault"),a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute"),o=Symbol.for("spritejs_declareAlias");function f(l){const{width:p,height:y}=l;return`M0 0L${p} 0L${p} ${y}L0 ${y}Z`}class v extends e.default{constructor(p){super(p),this[i]({width:0,height:0}),this[o]("size")}get d(){return this[s]("d")}set d(p){}get width(){return this[s]("width")}set width(p){if(p=Object(n.toNumber)(p),this[a]("width",p)){const y=f(this);this[a]("d",y)}}get height(){return this[s]("height")}set height(p){if(p=Object(n.toNumber)(p),this[a]("height",p)){const y=f(this);this[a]("d",y)}}get size(){return[this.width,this.height]}set size(p){p=Object(n.toArray)(p),Array.isArray(p)||(p=[p,p]),this.width=p[0],this.height=p[1]}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(232),n=t(213),i=t(235);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{sides:f}=this.attributes;return f[0]>0&&f[1]>0&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"triangle")},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(226),n=t(213),i=t(233);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{points:f}=this.attributes;return f.length>0&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"polyline")},function(d,r,t){t.r(r),t.d(r,"default",function(){return l});var e=t(228),n=t(72),i=t(234);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttributeDefault"),s=Symbol.for("spritejs_setAttribute"),o=Symbol.for("spritejs_getAttribute"),f=Symbol.for("spritejs_declareAlias");function v(p){const{points:y,smooth:O,smoothRange:x,close:m}=p,T=[];for(let h=0;h<y.length;h+=2)T.push([y[h],y[h+1]]);let c="";return O?c=Object(i.makeSmoothCurveLine)(T,x):T.length&&(c=`M${T.map(h=>h.join(" ")).join("L")}`),c&&m&&(c+="Z"),c}class l extends e.default{constructor(y){super(y),this[a]({points:[],smooth:!1,smoothRange:[0],closeType:"none"}),this[f]("close")}get d(){return this[o]("d")}set d(y){}get close(){return this.closeType!=="none"}set close(y){y=y?"normal":"none",this.closeType=y}get closeType(){return this[o]("closeType")}set closeType(y){if(y!=null&&y!=="none"&&y!=="normal")throw new TypeError("Invalid closeType type.");if(this[s]("closeType",y)){const O=v(this);this[s]("d",O)}}get smooth(){return this[o]("smooth")}set smooth(y){if(this[s]("smooth",y)){const O=v(this);this[s]("d",O)}}get smoothRange(){return this[o]("smoothRange")}set smoothRange(y){if(y&&!Array.isArray(y)&&(y=[y]),this[s]("smoothRange",y)&&this.smooth){const O=v(this);this[s]("d",O)}}get points(){return this[o]("points")}set points(y){if(y=Object(n.toArray)(y),Array.isArray(y)&&(y=y.reduce((O,x)=>Array.isArray(x)?[...O,...x.map(m=>Object(n.toNumber)(m))]:[...O,Object(n.toNumber)(x)],[])),this[s]("points",y)){const O=v(this);this[s]("d",O)}}}},function(d,r,t){t.r(r),t.d(r,"makeSmoothCurveLine",function(){return e}),t(1).glMatrix.setMatrixArrayType(Array);function e(n,i=[0]){function a(f,v=.168,l=.168){let p,y,O,x;if((n[f].x===n[f+1].x||n[f].y===n[f+1].y)&&(v=0,l=0),f<1?(p=n[0].x+(n[1].x-n[0].x)*v,y=n[0].y+(n[1].y-n[0].y)*v):(p=n[f].x+(n[f+1].x-n[f-1].x)*v,y=n[f].y+(n[f+1].y-n[f-1].y)*v),f>n.length-3){const m=n.length-1;O=n[m].x-(n[m].x-n[m-1].x)*l,x=n[m].y-(n[m].y-n[m-1].y)*l}else O=n[f+1].x-(n[f+2].x-n[f].x)*l,x=n[f+1].y-(n[f+2].y-n[f].y)*l;return[{x:p,y},{x:O,y:x}]}n=n.map(([f,v])=>({x:f,y:v}));let s="",o=0;return n.forEach((f,v)=>{if(v===0)s+=`M${f.x} ${f.y}`;else{for(;v>i[o];)o++;if(o%2){const[l,p]=a(v-1);s+=`C${[l.x,l.y,p.x,p.y,f.x,f.y].join(" ")}`}else s+=`L${f.x} ${f.y}`}}),s}},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(233),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i=Symbol.for("spritejs_setAttributeDefault"),a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute");function o(v){const[l,p]=v.sides;let y=v.angle%360;return y<0&&(y+=360),y=Math.PI*y/180,[0,0,l,0,p*Math.cos(y),p*Math.sin(y)]}class f extends e.default{constructor(l){super(l),this[i]({sides:[0,0],angle:60,closeType:"normal"})}get points(){return super.points}set points(l){}get sides(){return this[s]("sides")}set sides(l){if(l=Object(n.toArray)(l,!0),l!=null&&!Array.isArray(l)&&(l=[l,l]),this[a]("sides",l)){const p=o(this);super.points=p}}get angle(){return this[s]("angle")}set angle(l){if(l=Object(n.toNumber)(l),this[a]("angle",l)){const p=o(this);super.points=p}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(232),n=t(213),i=t(237);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{sides:f}=this.attributes;return f[0]>0&&f[1]>0&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"parallel")},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(233),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i=Symbol.for("spritejs_setAttributeDefault"),a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute");function o(v){const[l,p]=v.sides;let y=v.angle%360;y<0&&(y+=360),y=Math.PI*y/180;const O=p*Math.cos(y),x=p*Math.sin(y);return[0,0,l,0,O+l,x,O,x]}class f extends e.default{constructor(l){super(l),this[i]({sides:[0,0],angle:90,closeType:"normal"})}get points(){return super.points}set points(l){}get sides(){return this[s]("sides")}set sides(l){if(l=Object(n.toArray)(l,!0),l!=null&&!Array.isArray(l)&&(l=[l,l]),this[a]("sides",l)){const p=o(this);super.points=p}}get angle(){return this[s]("angle")}set angle(l){if(l=Object(n.toNumber)(l),this[a]("angle",l)){const p=o(this);super.points=p}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(232),n=t(213),i=t(239);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{}a(s,"Attr",i.default),n.default.registerNode(s,"regular")},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(233),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i=Symbol.for("spritejs_setAttributeDefault"),a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute");function o(v){const{edges:l,radius:p,offsetAngle:y}=v,O=Math.PI*y/180-.5*Math.PI;if(l<3||p<=0)return[];const x=[];for(let m=0;m<l;m++){const T=m*2*Math.PI/l+O,c=p*Math.cos(T),h=p*Math.sin(T);x.push(c,h)}return x}class f extends e.default{constructor(l){super(l),this[i]({edges:3,radius:0,offsetAngle:0,closeType:"normal"})}get points(){return super.points}set points(l){}get edges(){return this[s]("edges")}set edges(l){if(l=Object(n.toNumber)(l),this[a]("edges",l)){const p=o(this);super.points=p}}get radius(){return this[s]("radius")}set radius(l){if(l=Object(n.toNumber)(l),this[a]("radius",l)){const p=o(this);super.points=p}}get offsetAngle(){return this[s]("offsetAngle")}set offsetAngle(l){if(l=Object(n.toNumber)(l),this[a]("offsetAngle",l)){const p=o(this);super.points=p}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(232),n=t(213),i=t(241);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{}a(s,"Attr",i.default),n.default.registerNode(s,"star")},function(d,r,t){t.r(r),t.d(r,"default",function(){return f});var e=t(233),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);const i=Symbol.for("spritejs_setAttributeDefault"),a=Symbol.for("spritejs_setAttribute"),s=Symbol.for("spritejs_getAttribute");function o(v){const{angles:l,innerRadius:p,outerRadius:y,offsetAngle:O}=v,x=Math.PI*O/180-.5*Math.PI;if(l<3||p<=0||y<=0)return[];const m=[];for(let T=0;T<l*2;T++){const c=T*Math.PI/l+x,h=T%2?p:y,u=h*Math.cos(c),g=h*Math.sin(c);m.push(u,g)}return m}class f extends e.default{constructor(l){super(l),this[i]({angles:5,innerRadius:0,outerRadius:0,offsetAngle:0,closeType:"normal"})}get points(){return super.points}set points(l){}get angles(){return this[s]("angles")}set angles(l){if(l=Object(n.toNumber)(l),this[a]("angles",l)){const p=o(this);super.points=p}}get innerRadius(){return this[s]("innerRadius")}set innerRadius(l){if(l=Object(n.toNumber)(l),this[a]("innerRadius",l)){const p=o(this);super.points=p}}get outerRadius(){return this[s]("outerRadius")}set outerRadius(l){if(l=Object(n.toNumber)(l),this[a]("outerRadius",l)){const p=o(this);super.points=p}}get radius(){return[this.innerRadius,this.outerRadius]}set radius(l){l=Object(n.toArray)(l,!0),Array.isArray(l)||(l=[l,l]),this.innerRadius=l[0],this.outerRadius=l[1]}get offsetAngle(){return this[s]("offsetAngle")}set offsetAngle(l){if(l=Object(n.toNumber)(l),this[a]("offsetAngle",l)){const p=o(this);super.points=p}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(226),n=t(213),i=t(243);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{radiusX:f,radiusY:v,startAngle:l,endAngle:p}=this.attributes;return f>0&&v>0&&l!==p&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"ellipse")},function(d,r,t){t.r(r),t.d(r,"default",function(){return l});var e=t(12),n=t(228),i=t(72);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttributeDefault"),s=Symbol.for("spritejs_setAttribute"),o=Symbol.for("spritejs_getAttribute"),f=Symbol.for("spritejs_declareAlias");function v(p){const{radiusX:y,radiusY:O,startAngle:x,endAngle:m,direction:T,closeType:c}=p,h=T==="anitclockwise",u=new e.Figure2D;return c==="sector"&&u.moveTo(0,0),u.ellipse(0,0,y,O,0,Math.PI*x/180,Math.PI*m/180,h),c!=="none"&&u.closePath(),u.path.reduce((A,I)=>A+I.join(" "),"")}class l extends n.default{constructor(y){super(y),this[a]({radiusX:0,radiusY:0,startAngle:0,endAngle:360,direction:"clockwise",closeType:"none"}),this[f]("radius","angle")}get d(){return this[o]("d")}set d(y){}get radiusX(){return this[o]("radiusX")}set radiusX(y){if(y=Object(i.toNumber)(y),this[s]("radiusX",y)){const O=v(this);this[s]("d",O)}}get radiusY(){return this[o]("radiusY")}set radiusY(y){if(y=Object(i.toNumber)(y),this[s]("radiusY",y)){const O=v(this);this[s]("d",O)}}get radius(){return[this.radiusX,this.radiusY]}set radius(y){y=Object(i.toArray)(y,!0),Array.isArray(y)||(y=[y,y]),this.radiusX=y[0],this.radiusY=y[1]}get angle(){return[this.startAngle,this.endAngle]}set angle(y){y=Object(i.toArray)(y),Array.isArray(y)||(y=[y,y]),this.startAngle=y[0],this.endAngle=y[1]}get direction(){return this[o]("direction")}set direction(y){if(y!=null&&y!=="clockwise"&&y!=="anticlockwise")throw new TypeError("Invalid direction type.");this[s]("direction",y)}get startAngle(){return this[o]("startAngle")}set startAngle(y){if(y=Object(i.toNumber)(y),this[s]("startAngle",y)){const O=v(this);this[s]("d",O)}}get endAngle(){return this[o]("endAngle")}set endAngle(y){if(y=Object(i.toNumber)(y),this[s]("endAngle",y)){const O=v(this);this[s]("d",O)}}get closeType(){return this[o]("closeType")}set closeType(y){if(y!=null&&y!=="none"&&y!=="sector"&&y!=="normal")throw new TypeError("Invalid closeType type.");if(this[s]("closeType",y)){const O=v(this);this[s]("d",O)}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(242),n=t(213),i=t(245);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{}a(s,"Attr",i.default),n.default.registerNode(s,"arc")},function(d,r,t){t.r(r),t.d(r,"default",function(){return i});var e=t(243),n=t(72);t(1).glMatrix.setMatrixArrayType(Array);class i extends e.default{get radius(){return super.radiusX}set radius(s){s=Object(n.toNumber)(s),super.radiusX=s,super.radiusY=s}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(226),n=t(213),i=t(247);t(1).glMatrix.setMatrixArrayType(Array);function a(o,f,v){return f in o?Object.defineProperty(o,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):o[f]=v,o}class s extends e.default{get isVisible(){const{innerRadius:f,outerRadius:v,startAngle:l,endAngle:p}=this.attributes;return(f>0||v>0)&&l!==p&&super.isVisible}}a(s,"Attr",i.default),n.default.registerNode(s,"ring")},function(d,r,t){t.r(r),t.d(r,"default",function(){return l});var e=t(12),n=t(228),i=t(72);t(1).glMatrix.setMatrixArrayType(Array);const a=Symbol.for("spritejs_setAttributeDefault"),s=Symbol.for("spritejs_setAttribute"),o=Symbol.for("spritejs_getAttribute"),f=Symbol.for("spritejs_declareAlias");function v(p){let{innerRadius:y,outerRadius:O,startAngle:x,endAngle:m}=p;const T=new e.Figure2D;if(x=Math.PI*x/180,m=Math.PI*m/180,y>O&&([y,O]=[O,y]),y<=0&&T.moveTo(0,0),T.arc(0,0,O,x,m,!1),y>0){const u=Math.PI*2;m<x&&(m=x+u+(m-x)%u),m-x>=u&&(m=x+u-1e-6),T.arc(0,0,y,m,x,!0)}return T.closePath(),T.path.reduce((u,g)=>u+g.join(" "),"")}class l extends n.default{constructor(y){super(y),this[a]({innerRadius:0,outerRadius:0,startAngle:0,endAngle:360}),this[f]("radius","angle")}get d(){return this[o]("d")}set d(y){}get innerRadius(){return this[o]("innerRadius")}set innerRadius(y){if(y=Object(i.toNumber)(y),this[s]("innerRadius",y)){const O=v(this);this[s]("d",O)}}get outerRadius(){return this[o]("outerRadius")}set outerRadius(y){if(y=Object(i.toNumber)(y),this[s]("outerRadius",y)){const O=v(this);this[s]("d",O)}}get radius(){return[this.innerRadius,this.outerRadius]}set radius(y){y=Object(i.toArray)(y,!0),Array.isArray(y)||(y=[y,y]),this.innerRadius=y[0],this.outerRadius=y[1]}get startAngle(){return this[o]("startAngle")}set startAngle(y){if(y=Object(i.toNumber)(y),this[s]("startAngle",y)){const O=v(this);this[s]("d",O)}}get endAngle(){return this[o]("endAngle")}set endAngle(y){if(y=Object(i.toNumber)(y),this[s]("endAngle",y)){const O=v(this);this[s]("d",O)}}get angle(){return[this.startAngle,this.endAngle]}set angle(y){y=Object(i.toArray)(y),Array.isArray(y)||(y=[y,y]),this.startAngle=y[0],this.endAngle=y[1]}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return O});var e=t(12),n=t(218),i=t(219),a=t(249),s=t(213);t(1).glMatrix.setMatrixArrayType(Array);function o(x,m,T){return m in x?Object.defineProperty(x,m,{value:T,enumerable:!0,configurable:!0,writable:!0}):x[m]=T,x}const f=Symbol("textImage"),v=Symbol("textImageTask"),l=Symbol("textureContext"),p=Symbol("updateTextureRect"),y=Symbol("textCanvas");class O extends i.default{constructor(m={}){typeof m=="string"&&(m={text:m}),super(m)}get contentSize(){let[m,T]=super.contentSize;const{width:c,height:h}=this.attributes;if(c==null||h==null){const u=this[f];u&&(c==null&&(m=u.rect[2]),h==null&&(T=u.rect[3]))}return[m,T]}get text(){return this.attributes.text}set text(m){this.attributes.text=m}get textContent(){return this.attributes.text}set textContent(m){this.attributes.text=m}get textImage(){return this[f]||{}}get textImageReady(){return this[v]||Promise.resolve()}draw(m){super.draw(m);const T=this.mesh;if(T){const c=this[f];if(c){let h=T.texture;if(!h||this[l]&&this[l]!==this.renderer||c.needsUpdate?(c.needsUpdate=!1,Object(n.deleteTexture)(c.image,this.renderer),h=Object(n.createTexture)(c.image,this.renderer),this[p]=!0):h=T.uniforms.u_texSampler,this[p]){const[u,g]=c.rect.slice(2),[M,A]=this.contentSize,I=this.attributes.textAlign,b=this.attributes.verticalAlign;let E=0;I==="center"?E=(M-u)/2:(I==="right"||I==="end")&&(E=M-u);const L=this.attributes.fontSize,D=this.attributes.lineHeight;let R=0;b==="top"?R=(L-D)/2:b==="bottom"&&(R=(D-L)/2);const{paddingLeft:C,paddingTop:W}=this.attributes,{borderWidth:z}=this.attributes;E+=C+z,R+=W+z;const{anchorX:H,anchorY:X}=this.attributes;E-=this.offsetSize[0]*H,R-=this.offsetSize[1]*X,T.setTexture(h,{rect:[E,R,u,g]}),this[p]=!1,this[l]=this.renderer}}}return m}onPropertyChange(m,T,c){m==="text"||m==="fontSize"||m==="fontFamily"||m==="fontStyle"||m==="fontVariant"||m==="fontWeight"||m==="fontStretch"||m==="lineHeight"||m==="strokeColor"||m==="fillColor"||m==="strokeWidth"?this.updateText():((m==="textAlign"||m==="verticalAlign")&&(this[p]=!0),super.onPropertyChange(m,T,c))}updateContours(){super.updateContours(),this[p]=!0}updateText(){this[v]||(this[v]=Promise.resolve().then(()=>{this[v]=null;const{text:m,font:T,fillColor:c,strokeColor:h,strokeWidth:u}=this.attributes,g=this.layer?this.layer.displayRatio:1;return this[y]=this[y]||e.ENV.createCanvas(1,1),this[f]=e.ENV.createText(m,{font:T,fillColor:c,strokeColor:h,strokeWidth:u,parseFont:e.parseFont,ratio:g,textCanvas:this[y]}),this[f].needsUpdate=!0,this.updateContours(),this.forceUpdate(),this[f]}))}}o(O,"Attr",a.default),s.default.registerNode(O,"label")},function(d,r,t){t.r(r),t.d(r,"default",function(){return l});var e=t(12),n=t(72),i=t(221),a=t(220);t(1).glMatrix.setMatrixArrayType(Array);const s=Symbol.for("spritejs_setAttributeDefault"),o=Symbol.for("spritejs_setAttribute"),f=Symbol.for("spritejs_getAttribute"),v=Symbol.for("spritejs_declareAlias");class l extends a.default{constructor(y){super(y),this[s]({text:"",fontSize:16,fontFamily:"Helvetica,Arial,sans-serif",fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontStretch:"normal",lineHeight:"",textAlign:"left",strokeColor:void 0,strokeWidth:1,fillColor:void 0,verticalAlign:"middle"}),this[v]("font")}get text(){return this[f]("text")||" "}set text(y){this[o]("text",y)}get fontSize(){return this[f]("fontSize")}set fontSize(y){this[o]("fontSize",Object(n.toNumber)(y))}get fontFamily(){return this[f]("fontFamily")}set fontFamily(y){this[o]("fontFamily",y)}get fontStyle(){return this[f]("fontStyle")}set fontStyle(y){this[o]("fontStyle",y)}get fontVariant(){return this[f]("fontVariant")}set fontVariant(y){this[o]("fontVariant",y)}get fontWeight(){return this[f]("fontWeight")}set fontWeight(y){this[o]("fontWeight",y)}get fontStretch(){return this[f]("fontStretch")}set fontStretch(y){this[o]("fontStretch",y)}get lineHeight(){return this[f]("lineHeight")||this.fontSize}set lineHeight(y){this[o]("lineHeight",Object(n.toNumber)(y))}get textAlign(){return this[f]("textAlign")}set textAlign(y){this[o]("textAlign",y)}get strokeColor(){return this[f]("strokeColor")}set strokeColor(y){this[o]("strokeColor",Object(i.parseColor)(y))}get strokeWidth(){return this[f]("strokeWidth")}set strokeWidth(y){this[o]("strokeWidth",Object(n.toNumber)(y))}get verticalAlign(){return this[f]("verticalAlign")}set verticalAlign(y){this[o]("verticalAlign",y)}get fillColor(){return this[f]("fillColor")}set fillColor(y){this[o]("fillColor",Object(i.parseColor)(y))}get font(){const{fontStyle:y,fontVariant:O,fontWeight:x,fontStretch:m,fontSize:T,lineHeight:c,fontFamily:h}=this;return`${y} ${O} ${x} ${m} ${T}px/${c}px ${h}`}set font(y){if(y==null)this.fontStyle=null,this.fontVariant=null,this.fontWeight=null,this.fontStretch=null,this.fontSize=null,this.lineHeight=null,this.fontFamily=null;else{const O=Object(e.parseFont)(y);this.fontStyle=O.style,this.fontVariant=O.variant,this.fontWeight=O.weight,this.fontStretch=O.stretch,this.fontSize=Object(n.toNumber)(`${O.size}${O.unit}`),O.lineHeight&&(this.lineHeight=O.pxLineHeight),this.fontFamily=O.family}}}},function(d,r,t){t.r(r),t.d(r,"default",function(){return y});var e=t(12),n=t(219),i=t(251),a=t(213),s=t(252);t(1).glMatrix.setMatrixArrayType(Array);function o(O,x,m){return x in O?Object.defineProperty(O,x,{value:m,enumerable:!0,configurable:!0,writable:!0}):O[x]=m,O}const f=Symbol("zOrder"),v=Symbol("ordered"),l=Symbol("children"),p=Symbol("sealed");class y extends n.default{constructor(x={}){super(x),this[l]=[],this[v]=null,this[f]=0}get childNodes(){return this[l]}get children(){return this[l]}get orderedChildren(){return this[v]||(this[v]=[...this[l]],this[v].sort((x,m)=>x.zIndex-m.zIndex||x.zOrder-m.zOrder)),this[v]}append(...x){return x.map(m=>this.appendChild(m))}appendChild(x){return x.remove(),this[l].push(x),x.connect(this,this[f]++),this[v]&&(this[v].length&&x.zIndex<this[v][this[v].length-1].zIndex?this.reorder():this[v].push(x)),x}cloneNode(x=!1){const m=super.cloneNode();return x&&this[l].forEach(T=>{const c=T.cloneNode(x);m.appendChild(c)}),m}dispatchPointerEvent(x){const m=this.orderedChildren;for(let T=m.length-1;T>=0;T--)if(m[T].dispatchPointerEvent(x))return!0;return super.dispatchPointerEvent(x)}draw(x=[]){if(this.__cacheRenderMatrix=this.renderMatrix,super.draw(x),!this[p]&&this.attributes.display!=="none"){const m=this.orderedChildren;for(let T=0;T<m.length;T++)m[T].draw(x)}return this.__cacheRenderMatrix=null,x}getElementById(x){return Object(s.querySelector)(`#${x}`,this)}getElementsByClassName(x){return Object(s.querySelectorAll)(`.${x}`,this)}getElementsByName(x){return Object(s.querySelectorAll)(`[name="${x}"]`,this)}getElementsByTagName(x){return Object(s.querySelectorAll)(x,this)}insertBefore(x,m){if(m==null)return this.appendChild(x);x.remove();const T=this[l].indexOf(m);if(T<0)throw new Error("Invalid reference node.");const c=m.zOrder;for(let h=T;h<this[l].length;h++){const u=this[l][h].zOrder,g=this[l][h];delete g.zOrder,Object.defineProperty(g,"zOrder",{value:u+1,writable:!1,configurable:!0})}if(this[l].splice(T,0,x),x.connect(this,c),this[v])if(x.zIndex!==m.zIndex)this.reorder();else{const h=this[v].indexOf(m);this[v].splice(h,0,x)}return x}querySelector(x){return Object(s.querySelector)(x,this)}querySelectorAll(x){return Object(s.querySelectorAll)(x,this)}replaceChild(x,m){x.remove();const T=this[l].indexOf(m);if(T<0)throw new Error("Invalid reference node.");if(this[l][T]=x,x.connect(this,m.zOrder),this[v])if(x.zIndex!==m.zIndex)this.reorder();else{const c=this[v].indexOf(m);this[v][c]=x}return m.disconnect(this),x}removeAllChildren(){const x=this[l];for(let m=x.length-1;m>=0;m--)x[m].remove()}removeChild(x){const m=this[l].indexOf(x);if(m>=0){if(this[l].splice(m,1),this[v]){const T=this[v].indexOf(x);this[v].splice(T,1)}return x.disconnect(this),x}return null}reorder(){this[v]=null}seal(){function x(h,u){const g=[];for(let M=0;M<h.length;M++){const A=[...h[M]];for(let I=1;I<A.length;I+=2){const b=A[I],E=A[I+1];A[I]=b*u[0]+E*u[2]+u[4],A[I+1]=b*u[1]+E*u[3]+u[5]}g.push(A)}return g}const m=this.orderedChildren,T=new e.Figure2D,c=this.localMatrix;for(let h=0;h<m.length;h++){let u=m[h];if(u instanceof y&&(u=u.seal()),u.clientBox){let g=u.clientBox.contours.path;g=x(g,u.localMatrix),T.addPath(g)}if(u.path){let g=u.path.contours.path;g=x(g,u.localMatrix),T.addPath(g)}}return this[p]=!0,this.clientBox=T,{clientBox:T,localMatrix:c}}setResolution({width:x,height:m}){super.setResolution({width:x,height:m}),this[l].forEach(T=>{T.setResolution({width:x,height:m})})}updateContours(){this[p]||super.updateContours()}}o(y,"Attr",i.default),a.default.registerNode(y,"group")},function(d,r,t){t.r(r),t.d(r,"default",function(){return n});var e=t(220);t(1).glMatrix.setMatrixArrayType(Array);class n extends e.default{}},function(d,r,t){t.r(r),t.d(r,"querySelectorAll",function(){return p}),t.d(r,"querySelector",function(){return y}),t.d(r,"isMatched",function(){return O}),t.d(r,"compile",function(){return x});var e=t(221),n=t(213);t(1).glMatrix.setMatrixArrayType(Array);const i=t(253);function a(m){return m.nodeType===1||n.default.isSpriteNode(m.nodeName)}function s(m){return Array.from(m.childNodes||[])}function o(m){return n.default.isSpriteNode(m.nodeName)?m.parent||m.canvas||m.container:m.parentElement}function f(m){let T=m.length,c,h,u;for(;--T>-1;){for(c=h=m[T],m[T]=null,u=!0;h;){if(m.indexOf(h)>-1){u=!1,m.splice(T,1);break}h=o(h)}u&&(m[T]=c)}return m}const v={isTag:a,existsOne(m,T){return T.some(c=>a(c)?m(c)||v.existsOne(m,s(c)):!1)},getSiblings(m){const T=o(m);return T&&s(T)},getChildren:s,getParent:o,getAttributeValue(m,T){if(m.nodeType===1&&T==="class"||T==="id")return m[T];if(this.hasAttrib(m,T)){let c=m.attributes[T];return Array.isArray(c)&&(c=`[${c.join()}]`),String(c)}},hasAttrib(m,T){return m.attributes[T]!=null},removeSubsets:f,getName(m){return m.tagName?m.tagName.toLowerCase():null},findOne:function m(T,c){let h=null;for(let u=0,g=c.length;u<g&&!h;u++)if(T(c[u]))h=c[u];else{const M=s(c[u]);M&&M.length>0&&(h=m(T,M))}return h},findAll:function m(T,c){let h=[];for(let u=0,g=c.length;u<g;u++){if(!a(c[u]))continue;T(c[u])&&h.push(c[u]);const M=s(c[u]);M&&(h=h.concat(m(T,M)))}return h},getText:function m(T){return Array.isArray(T)?T.map(m).join(""):a(T)?m(s(T)):T.nodeType===3?T.nodeValue:n.default.isSpriteNode(T.nodeName)?T.text:""}};function l(m){if(typeof m!="string")return m;let T=m.match(/\[(bgcolor|fillColor|strokeColor|color)\s*=\s*['"]?\w+['"]?\]/g);return T&&(T=T.map(c=>{const h=c.slice(1,-1).split("="),u=Object(e.parseColor)(h[1].replace(/['"]/g,""));return[c,`[${h[0]}="${u}"]`]}),T.forEach(([c,h])=>{m=m.replace(c,h)})),T=m.match(/\[\w+\s*=\s*['"]\[.+?\]['"]\]/g),T&&(T=T.map(c=>{const h=c.slice(1,-1).split("="),u=h[1].slice(2,-2).split(/,/g).map(g=>g.trim());return[c,`[${h[0]}="[${u}]"]`]}),T.forEach(([c,h])=>{m=m.replace(c,h)})),m}function p(m,T){return i.selectAll(l(m),T,{adapter:v})}function y(m,T){return i.selectOne(l(m),T,{adapter:v})}function O(m,T){return i.is(m,l(T),{adapter:v})}function x(m){return i.compile(l(m),{adapter:v})}},function(d,r,t){d.exports=x;var e=t(254),n=t(273).falseFunc,i=t(274);function a(m){return function(c,h,u){return h=h||{},h.adapter=h.adapter||e,m(c,h,u)}}var s=a(i),o=a(i.compileUnsafe);function f(m){return function(c,h,u){return u=u||{},u.adapter=u.adapter||e,typeof c!="function"&&(c=o(c,u,h)),c.shouldTestNextSiblings&&(h=l(u&&u.context||h,u.adapter)),Array.isArray(h)?h=u.adapter.removeSubsets(h):h=u.adapter.getChildren(h),m(c,h,u)}}function v(m,T){var c=T.getSiblings(m);if(!Array.isArray(c))return[];for(c=c.slice(0);c.shift()!==m;);return c}function l(m,T){Array.isArray(m)||(m=[m]);for(var c=m.slice(0),h=0,u=m.length;h<u;h++){var g=v(c[h],T);c.push.apply(c,g)}return c}var p=f(function(T,c,h){return T===n||!c||c.length===0?[]:h.adapter.findAll(T,c)}),y=f(function(T,c,h){return T===n||!c||c.length===0?null:h.adapter.findOne(T,c)});function O(m,T,c){return c=c||{},c.adapter=c.adapter||e,(typeof T=="function"?T:s(T,c))(m)}function x(m,T,c){return p(m,T,c)}x.compile=s,x.filters=i.Pseudos.filters,x.pseudos=i.Pseudos.pseudos,x.selectAll=p,x.selectOne=y,x.is=O,x.parse=s,x.iterate=p,x._compileUnsafe=o,x._compileToken=i.compileToken},function(d,r,t){var e=d.exports;[t(255),t(268),t(269),t(270),t(271),t(272)].forEach(function(n){Object.keys(n).forEach(function(i){e[i]=n[i].bind(e)})})},function(d,r,t){var e=t(256),n=t(257),i=e.isTag;d.exports={getInnerHTML:a,getOuterHTML:n,getText:s};function a(o,f){return o.children?o.children.map(function(v){return n(v,f)}).join(""):""}function s(o){return Array.isArray(o)?o.map(s).join(""):i(o)?o.name==="br"?`
565
565
  `:s(o.children):o.type===e.CDATA?s(o.children):o.type===e.Text?o.data:""}},function(d,r){d.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(t){return t.type==="tag"||t.type==="script"||t.type==="style"}}},function(d,r,t){var e=t(258),n=t(259),i=t(267);i.elementNames.__proto__=null,i.attributeNames.__proto__=null;var a={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0};function s(m,T){if(m){var c="",h;for(var u in m)h=m[u],c&&(c+=" "),T.xmlMode==="foreign"&&(u=i.attributeNames[u]||u),c+=u,(h!==null&&h!==""||T.xmlMode)&&(c+='="'+(T.decodeEntities?n.encodeXML(h):h.replace(/\"/g,"&quot;"))+'"');return c}}var o={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=d.exports=function(m,T){!Array.isArray(m)&&!m.cheerio&&(m=[m]),T=T||{};for(var c="",h=0;h<m.length;h++){var u=m[h];u.type==="root"?c+=f(u.children,T):e.isTag(u)?c+=l(u,T):u.type===e.Directive?c+=p(u):u.type===e.Comment?c+=x(u):u.type===e.CDATA?c+=O(u):c+=y(u,T)}return c},v=["mi","mo","mn","ms","mtext","annotation-xml","foreignObject","desc","title"];function l(m,T){T.xmlMode==="foreign"&&(m.name=i.elementNames[m.name]||m.name,m.parent&&v.indexOf(m.parent.name)>=0&&(T=Object.assign({},T,{xmlMode:!1}))),!T.xmlMode&&["svg","math"].indexOf(m.name)>=0&&(T=Object.assign({},T,{xmlMode:"foreign"}));var c="<"+m.name,h=s(m.attribs,T);return h&&(c+=" "+h),T.xmlMode&&(!m.children||m.children.length===0)?c+="/>":(c+=">",m.children&&(c+=f(m.children,T)),(!o[m.name]||T.xmlMode)&&(c+="</"+m.name+">")),c}function p(m){return"<"+m.data+">"}function y(m,T){var c=m.data||"";return T.decodeEntities&&!(m.parent&&m.parent.name in a)&&(c=n.encodeXML(c)),c}function O(m){return"<![CDATA["+m.children[0].data+"]]>"}function x(m){return"<!--"+m.data+"-->"}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});function e(n){return n.type==="tag"||n.type==="script"||n.type==="style"}r.isTag=e,r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.encode=r.decodeStrict=r.decode=void 0;var e=t(260),n=t(266);function i(v,l){return(!l||l<=0?e.decodeXML:e.decodeHTML)(v)}r.decode=i;function a(v,l){return(!l||l<=0?e.decodeXML:e.decodeHTMLStrict)(v)}r.decodeStrict=a;function s(v,l){return(!l||l<=0?n.encodeXML:n.encodeHTML)(v)}r.encode=s;var o=t(266);Object.defineProperty(r,"encodeXML",{enumerable:!0,get:function(){return o.encodeXML}}),Object.defineProperty(r,"encodeHTML",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(r,"escape",{enumerable:!0,get:function(){return o.escape}}),Object.defineProperty(r,"encodeHTML4",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(r,"encodeHTML5",{enumerable:!0,get:function(){return o.encodeHTML}});var f=t(260);Object.defineProperty(r,"decodeXML",{enumerable:!0,get:function(){return f.decodeXML}}),Object.defineProperty(r,"decodeHTML",{enumerable:!0,get:function(){return f.decodeHTML}}),Object.defineProperty(r,"decodeHTMLStrict",{enumerable:!0,get:function(){return f.decodeHTMLStrict}}),Object.defineProperty(r,"decodeHTML4",{enumerable:!0,get:function(){return f.decodeHTML}}),Object.defineProperty(r,"decodeHTML5",{enumerable:!0,get:function(){return f.decodeHTML}}),Object.defineProperty(r,"decodeHTML4Strict",{enumerable:!0,get:function(){return f.decodeHTMLStrict}}),Object.defineProperty(r,"decodeHTML5Strict",{enumerable:!0,get:function(){return f.decodeHTMLStrict}}),Object.defineProperty(r,"decodeXMLStrict",{enumerable:!0,get:function(){return f.decodeXML}})},function(d,r,t){var e=this&&this.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(r,"__esModule",{value:!0}),r.decodeHTML=r.decodeHTMLStrict=r.decodeXML=void 0;var n=e(t(261)),i=e(t(262)),a=e(t(263)),s=e(t(264));r.decodeXML=o(a.default),r.decodeHTMLStrict=o(n.default);function o(l){var p=Object.keys(l).join("|"),y=v(l);p+="|#[xX][\\da-fA-F]+|#\\d+";var O=new RegExp("&(?:"+p+");","g");return function(x){return String(x).replace(O,y)}}var f=function(l,p){return l<p?1:-1};r.decodeHTML=function(){for(var l=Object.keys(i.default).sort(f),p=Object.keys(n.default).sort(f),y=0,O=0;y<p.length;y++)l[O]===p[y]?(p[y]+=";?",O++):p[y]+=";";var x=new RegExp("&(?:"+p.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),m=v(n.default);function T(c){return c.substr(-1)!==";"&&(c+=";"),m(c)}return function(c){return String(c).replace(x,T)}}();function v(l){return function(y){if(y.charAt(1)==="#"){var O=y.charAt(2);return O==="X"||O==="x"?s.default(parseInt(y.substr(3),16)):s.default(parseInt(y.substr(2),10))}return l[y.slice(1,-1)]}}},function(d){d.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Abreve":"Ă","abreve":"ă","ac":"∾","acd":"∿","acE":"∾̳","Acirc":"Â","acirc":"â","acute":"´","Acy":"А","acy":"а","AElig":"Æ","aelig":"æ","af":"⁡","Afr":"𝔄","afr":"𝔞","Agrave":"À","agrave":"à","alefsym":"ℵ","aleph":"ℵ","Alpha":"Α","alpha":"α","Amacr":"Ā","amacr":"ā","amalg":"⨿","amp":"&","AMP":"&","andand":"⩕","And":"⩓","and":"∧","andd":"⩜","andslope":"⩘","andv":"⩚","ang":"∠","ange":"⦤","angle":"∠","angmsdaa":"⦨","angmsdab":"⦩","angmsdac":"⦪","angmsdad":"⦫","angmsdae":"⦬","angmsdaf":"⦭","angmsdag":"⦮","angmsdah":"⦯","angmsd":"∡","angrt":"∟","angrtvb":"⊾","angrtvbd":"⦝","angsph":"∢","angst":"Å","angzarr":"⍼","Aogon":"Ą","aogon":"ą","Aopf":"𝔸","aopf":"𝕒","apacir":"⩯","ap":"≈","apE":"⩰","ape":"≊","apid":"≋","apos":"\'","ApplyFunction":"⁡","approx":"≈","approxeq":"≊","Aring":"Å","aring":"å","Ascr":"𝒜","ascr":"𝒶","Assign":"≔","ast":"*","asymp":"≈","asympeq":"≍","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","awconint":"∳","awint":"⨑","backcong":"≌","backepsilon":"϶","backprime":"‵","backsim":"∽","backsimeq":"⋍","Backslash":"∖","Barv":"⫧","barvee":"⊽","barwed":"⌅","Barwed":"⌆","barwedge":"⌅","bbrk":"⎵","bbrktbrk":"⎶","bcong":"≌","Bcy":"Б","bcy":"б","bdquo":"„","becaus":"∵","because":"∵","Because":"∵","bemptyv":"⦰","bepsi":"϶","bernou":"ℬ","Bernoullis":"ℬ","Beta":"Β","beta":"β","beth":"ℶ","between":"≬","Bfr":"𝔅","bfr":"𝔟","bigcap":"⋂","bigcirc":"◯","bigcup":"⋃","bigodot":"⨀","bigoplus":"⨁","bigotimes":"⨂","bigsqcup":"⨆","bigstar":"★","bigtriangledown":"▽","bigtriangleup":"△","biguplus":"⨄","bigvee":"⋁","bigwedge":"⋀","bkarow":"⤍","blacklozenge":"⧫","blacksquare":"▪","blacktriangle":"▴","blacktriangledown":"▾","blacktriangleleft":"◂","blacktriangleright":"▸","blank":"␣","blk12":"▒","blk14":"░","blk34":"▓","block":"█","bne":"=⃥","bnequiv":"≡⃥","bNot":"⫭","bnot":"⌐","Bopf":"𝔹","bopf":"𝕓","bot":"⊥","bottom":"⊥","bowtie":"⋈","boxbox":"⧉","boxdl":"┐","boxdL":"╕","boxDl":"╖","boxDL":"╗","boxdr":"┌","boxdR":"╒","boxDr":"╓","boxDR":"╔","boxh":"─","boxH":"═","boxhd":"┬","boxHd":"╤","boxhD":"╥","boxHD":"╦","boxhu":"┴","boxHu":"╧","boxhU":"╨","boxHU":"╩","boxminus":"⊟","boxplus":"⊞","boxtimes":"⊠","boxul":"┘","boxuL":"╛","boxUl":"╜","boxUL":"╝","boxur":"└","boxuR":"╘","boxUr":"╙","boxUR":"╚","boxv":"│","boxV":"║","boxvh":"┼","boxvH":"╪","boxVh":"╫","boxVH":"╬","boxvl":"┤","boxvL":"╡","boxVl":"╢","boxVL":"╣","boxvr":"├","boxvR":"╞","boxVr":"╟","boxVR":"╠","bprime":"‵","breve":"˘","Breve":"˘","brvbar":"¦","bscr":"𝒷","Bscr":"ℬ","bsemi":"⁏","bsim":"∽","bsime":"⋍","bsolb":"⧅","bsol":"\\\\","bsolhsub":"⟈","bull":"•","bullet":"•","bump":"≎","bumpE":"⪮","bumpe":"≏","Bumpeq":"≎","bumpeq":"≏","Cacute":"Ć","cacute":"ć","capand":"⩄","capbrcup":"⩉","capcap":"⩋","cap":"∩","Cap":"⋒","capcup":"⩇","capdot":"⩀","CapitalDifferentialD":"ⅅ","caps":"∩︀","caret":"⁁","caron":"ˇ","Cayleys":"ℭ","ccaps":"⩍","Ccaron":"Č","ccaron":"č","Ccedil":"Ç","ccedil":"ç","Ccirc":"Ĉ","ccirc":"ĉ","Cconint":"∰","ccups":"⩌","ccupssm":"⩐","Cdot":"Ċ","cdot":"ċ","cedil":"¸","Cedilla":"¸","cemptyv":"⦲","cent":"¢","centerdot":"·","CenterDot":"·","cfr":"𝔠","Cfr":"ℭ","CHcy":"Ч","chcy":"ч","check":"✓","checkmark":"✓","Chi":"Χ","chi":"χ","circ":"ˆ","circeq":"≗","circlearrowleft":"↺","circlearrowright":"↻","circledast":"⊛","circledcirc":"⊚","circleddash":"⊝","CircleDot":"⊙","circledR":"®","circledS":"Ⓢ","CircleMinus":"⊖","CirclePlus":"⊕","CircleTimes":"⊗","cir":"○","cirE":"⧃","cire":"≗","cirfnint":"⨐","cirmid":"⫯","cirscir":"⧂","ClockwiseContourIntegral":"∲","CloseCurlyDoubleQuote":"”","CloseCurlyQuote":"’","clubs":"♣","clubsuit":"♣","colon":":","Colon":"∷","Colone":"⩴","colone":"≔","coloneq":"≔","comma":",","commat":"@","comp":"∁","compfn":"∘","complement":"∁","complexes":"ℂ","cong":"≅","congdot":"⩭","Congruent":"≡","conint":"∮","Conint":"∯","ContourIntegral":"∮","copf":"𝕔","Copf":"ℂ","coprod":"∐","Coproduct":"∐","copy":"©","COPY":"©","copysr":"℗","CounterClockwiseContourIntegral":"∳","crarr":"↵","cross":"✗","Cross":"⨯","Cscr":"𝒞","cscr":"𝒸","csub":"⫏","csube":"⫑","csup":"⫐","csupe":"⫒","ctdot":"⋯","cudarrl":"⤸","cudarrr":"⤵","cuepr":"⋞","cuesc":"⋟","cularr":"↶","cularrp":"⤽","cupbrcap":"⩈","cupcap":"⩆","CupCap":"≍","cup":"∪","Cup":"⋓","cupcup":"⩊","cupdot":"⊍","cupor":"⩅","cups":"∪︀","curarr":"↷","curarrm":"⤼","curlyeqprec":"⋞","curlyeqsucc":"⋟","curlyvee":"⋎","curlywedge":"⋏","curren":"¤","curvearrowleft":"↶","curvearrowright":"↷","cuvee":"⋎","cuwed":"⋏","cwconint":"∲","cwint":"∱","cylcty":"⌭","dagger":"†","Dagger":"‡","daleth":"ℸ","darr":"↓","Darr":"↡","dArr":"⇓","dash":"‐","Dashv":"⫤","dashv":"⊣","dbkarow":"⤏","dblac":"˝","Dcaron":"Ď","dcaron":"ď","Dcy":"Д","dcy":"д","ddagger":"‡","ddarr":"⇊","DD":"ⅅ","dd":"ⅆ","DDotrahd":"⤑","ddotseq":"⩷","deg":"°","Del":"∇","Delta":"Δ","delta":"δ","demptyv":"⦱","dfisht":"⥿","Dfr":"𝔇","dfr":"𝔡","dHar":"⥥","dharl":"⇃","dharr":"⇂","DiacriticalAcute":"´","DiacriticalDot":"˙","DiacriticalDoubleAcute":"˝","DiacriticalGrave":"`","DiacriticalTilde":"˜","diam":"⋄","diamond":"⋄","Diamond":"⋄","diamondsuit":"♦","diams":"♦","die":"¨","DifferentialD":"ⅆ","digamma":"ϝ","disin":"⋲","div":"÷","divide":"÷","divideontimes":"⋇","divonx":"⋇","DJcy":"Ђ","djcy":"ђ","dlcorn":"⌞","dlcrop":"⌍","dollar":"$","Dopf":"𝔻","dopf":"𝕕","Dot":"¨","dot":"˙","DotDot":"⃜","doteq":"≐","doteqdot":"≑","DotEqual":"≐","dotminus":"∸","dotplus":"∔","dotsquare":"⊡","doublebarwedge":"⌆","DoubleContourIntegral":"∯","DoubleDot":"¨","DoubleDownArrow":"⇓","DoubleLeftArrow":"⇐","DoubleLeftRightArrow":"⇔","DoubleLeftTee":"⫤","DoubleLongLeftArrow":"⟸","DoubleLongLeftRightArrow":"⟺","DoubleLongRightArrow":"⟹","DoubleRightArrow":"⇒","DoubleRightTee":"⊨","DoubleUpArrow":"⇑","DoubleUpDownArrow":"⇕","DoubleVerticalBar":"∥","DownArrowBar":"⤓","downarrow":"↓","DownArrow":"↓","Downarrow":"⇓","DownArrowUpArrow":"⇵","DownBreve":"̑","downdownarrows":"⇊","downharpoonleft":"⇃","downharpoonright":"⇂","DownLeftRightVector":"⥐","DownLeftTeeVector":"⥞","DownLeftVectorBar":"⥖","DownLeftVector":"↽","DownRightTeeVector":"⥟","DownRightVectorBar":"⥗","DownRightVector":"⇁","DownTeeArrow":"↧","DownTee":"⊤","drbkarow":"⤐","drcorn":"⌟","drcrop":"⌌","Dscr":"𝒟","dscr":"𝒹","DScy":"Ѕ","dscy":"ѕ","dsol":"⧶","Dstrok":"Đ","dstrok":"đ","dtdot":"⋱","dtri":"▿","dtrif":"▾","duarr":"⇵","duhar":"⥯","dwangle":"⦦","DZcy":"Џ","dzcy":"џ","dzigrarr":"⟿","Eacute":"É","eacute":"é","easter":"⩮","Ecaron":"Ě","ecaron":"ě","Ecirc":"Ê","ecirc":"ê","ecir":"≖","ecolon":"≕","Ecy":"Э","ecy":"э","eDDot":"⩷","Edot":"Ė","edot":"ė","eDot":"≑","ee":"ⅇ","efDot":"≒","Efr":"𝔈","efr":"𝔢","eg":"⪚","Egrave":"È","egrave":"è","egs":"⪖","egsdot":"⪘","el":"⪙","Element":"∈","elinters":"⏧","ell":"ℓ","els":"⪕","elsdot":"⪗","Emacr":"Ē","emacr":"ē","empty":"∅","emptyset":"∅","EmptySmallSquare":"◻","emptyv":"∅","EmptyVerySmallSquare":"▫","emsp13":" ","emsp14":" ","emsp":" ","ENG":"Ŋ","eng":"ŋ","ensp":" ","Eogon":"Ę","eogon":"ę","Eopf":"𝔼","eopf":"𝕖","epar":"⋕","eparsl":"⧣","eplus":"⩱","epsi":"ε","Epsilon":"Ε","epsilon":"ε","epsiv":"ϵ","eqcirc":"≖","eqcolon":"≕","eqsim":"≂","eqslantgtr":"⪖","eqslantless":"⪕","Equal":"⩵","equals":"=","EqualTilde":"≂","equest":"≟","Equilibrium":"⇌","equiv":"≡","equivDD":"⩸","eqvparsl":"⧥","erarr":"⥱","erDot":"≓","escr":"ℯ","Escr":"ℰ","esdot":"≐","Esim":"⩳","esim":"≂","Eta":"Η","eta":"η","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","euro":"€","excl":"!","exist":"∃","Exists":"∃","expectation":"ℰ","exponentiale":"ⅇ","ExponentialE":"ⅇ","fallingdotseq":"≒","Fcy":"Ф","fcy":"ф","female":"♀","ffilig":"ffi","fflig":"ff","ffllig":"ffl","Ffr":"𝔉","ffr":"𝔣","filig":"fi","FilledSmallSquare":"◼","FilledVerySmallSquare":"▪","fjlig":"fj","flat":"♭","fllig":"fl","fltns":"▱","fnof":"ƒ","Fopf":"𝔽","fopf":"𝕗","forall":"∀","ForAll":"∀","fork":"⋔","forkv":"⫙","Fouriertrf":"ℱ","fpartint":"⨍","frac12":"½","frac13":"⅓","frac14":"¼","frac15":"⅕","frac16":"⅙","frac18":"⅛","frac23":"⅔","frac25":"⅖","frac34":"¾","frac35":"⅗","frac38":"⅜","frac45":"⅘","frac56":"⅚","frac58":"⅝","frac78":"⅞","frasl":"⁄","frown":"⌢","fscr":"𝒻","Fscr":"ℱ","gacute":"ǵ","Gamma":"Γ","gamma":"γ","Gammad":"Ϝ","gammad":"ϝ","gap":"⪆","Gbreve":"Ğ","gbreve":"ğ","Gcedil":"Ģ","Gcirc":"Ĝ","gcirc":"ĝ","Gcy":"Г","gcy":"г","Gdot":"Ġ","gdot":"ġ","ge":"≥","gE":"≧","gEl":"⪌","gel":"⋛","geq":"≥","geqq":"≧","geqslant":"⩾","gescc":"⪩","ges":"⩾","gesdot":"⪀","gesdoto":"⪂","gesdotol":"⪄","gesl":"⋛︀","gesles":"⪔","Gfr":"𝔊","gfr":"𝔤","gg":"≫","Gg":"⋙","ggg":"⋙","gimel":"ℷ","GJcy":"Ѓ","gjcy":"ѓ","gla":"⪥","gl":"≷","glE":"⪒","glj":"⪤","gnap":"⪊","gnapprox":"⪊","gne":"⪈","gnE":"≩","gneq":"⪈","gneqq":"≩","gnsim":"⋧","Gopf":"𝔾","gopf":"𝕘","grave":"`","GreaterEqual":"≥","GreaterEqualLess":"⋛","GreaterFullEqual":"≧","GreaterGreater":"⪢","GreaterLess":"≷","GreaterSlantEqual":"⩾","GreaterTilde":"≳","Gscr":"𝒢","gscr":"ℊ","gsim":"≳","gsime":"⪎","gsiml":"⪐","gtcc":"⪧","gtcir":"⩺","gt":">","GT":">","Gt":"≫","gtdot":"⋗","gtlPar":"⦕","gtquest":"⩼","gtrapprox":"⪆","gtrarr":"⥸","gtrdot":"⋗","gtreqless":"⋛","gtreqqless":"⪌","gtrless":"≷","gtrsim":"≳","gvertneqq":"≩︀","gvnE":"≩︀","Hacek":"ˇ","hairsp":" ","half":"½","hamilt":"ℋ","HARDcy":"Ъ","hardcy":"ъ","harrcir":"⥈","harr":"↔","hArr":"⇔","harrw":"↭","Hat":"^","hbar":"ℏ","Hcirc":"Ĥ","hcirc":"ĥ","hearts":"♥","heartsuit":"♥","hellip":"…","hercon":"⊹","hfr":"𝔥","Hfr":"ℌ","HilbertSpace":"ℋ","hksearow":"⤥","hkswarow":"⤦","hoarr":"⇿","homtht":"∻","hookleftarrow":"↩","hookrightarrow":"↪","hopf":"𝕙","Hopf":"ℍ","horbar":"―","HorizontalLine":"─","hscr":"𝒽","Hscr":"ℋ","hslash":"ℏ","Hstrok":"Ħ","hstrok":"ħ","HumpDownHump":"≎","HumpEqual":"≏","hybull":"⁃","hyphen":"‐","Iacute":"Í","iacute":"í","ic":"⁣","Icirc":"Î","icirc":"î","Icy":"И","icy":"и","Idot":"İ","IEcy":"Е","iecy":"е","iexcl":"¡","iff":"⇔","ifr":"𝔦","Ifr":"ℑ","Igrave":"Ì","igrave":"ì","ii":"ⅈ","iiiint":"⨌","iiint":"∭","iinfin":"⧜","iiota":"℩","IJlig":"IJ","ijlig":"ij","Imacr":"Ī","imacr":"ī","image":"ℑ","ImaginaryI":"ⅈ","imagline":"ℐ","imagpart":"ℑ","imath":"ı","Im":"ℑ","imof":"⊷","imped":"Ƶ","Implies":"⇒","incare":"℅","in":"∈","infin":"∞","infintie":"⧝","inodot":"ı","intcal":"⊺","int":"∫","Int":"∬","integers":"ℤ","Integral":"∫","intercal":"⊺","Intersection":"⋂","intlarhk":"⨗","intprod":"⨼","InvisibleComma":"⁣","InvisibleTimes":"⁢","IOcy":"Ё","iocy":"ё","Iogon":"Į","iogon":"į","Iopf":"𝕀","iopf":"𝕚","Iota":"Ι","iota":"ι","iprod":"⨼","iquest":"¿","iscr":"𝒾","Iscr":"ℐ","isin":"∈","isindot":"⋵","isinE":"⋹","isins":"⋴","isinsv":"⋳","isinv":"∈","it":"⁢","Itilde":"Ĩ","itilde":"ĩ","Iukcy":"І","iukcy":"і","Iuml":"Ï","iuml":"ï","Jcirc":"Ĵ","jcirc":"ĵ","Jcy":"Й","jcy":"й","Jfr":"𝔍","jfr":"𝔧","jmath":"ȷ","Jopf":"𝕁","jopf":"𝕛","Jscr":"𝒥","jscr":"𝒿","Jsercy":"Ј","jsercy":"ј","Jukcy":"Є","jukcy":"є","Kappa":"Κ","kappa":"κ","kappav":"ϰ","Kcedil":"Ķ","kcedil":"ķ","Kcy":"К","kcy":"к","Kfr":"𝔎","kfr":"𝔨","kgreen":"ĸ","KHcy":"Х","khcy":"х","KJcy":"Ќ","kjcy":"ќ","Kopf":"𝕂","kopf":"𝕜","Kscr":"𝒦","kscr":"𝓀","lAarr":"⇚","Lacute":"Ĺ","lacute":"ĺ","laemptyv":"⦴","lagran":"ℒ","Lambda":"Λ","lambda":"λ","lang":"⟨","Lang":"⟪","langd":"⦑","langle":"⟨","lap":"⪅","Laplacetrf":"ℒ","laquo":"«","larrb":"⇤","larrbfs":"⤟","larr":"←","Larr":"↞","lArr":"⇐","larrfs":"⤝","larrhk":"↩","larrlp":"↫","larrpl":"⤹","larrsim":"⥳","larrtl":"↢","latail":"⤙","lAtail":"⤛","lat":"⪫","late":"⪭","lates":"⪭︀","lbarr":"⤌","lBarr":"⤎","lbbrk":"❲","lbrace":"{","lbrack":"[","lbrke":"⦋","lbrksld":"⦏","lbrkslu":"⦍","Lcaron":"Ľ","lcaron":"ľ","Lcedil":"Ļ","lcedil":"ļ","lceil":"⌈","lcub":"{","Lcy":"Л","lcy":"л","ldca":"⤶","ldquo":"“","ldquor":"„","ldrdhar":"⥧","ldrushar":"⥋","ldsh":"↲","le":"≤","lE":"≦","LeftAngleBracket":"⟨","LeftArrowBar":"⇤","leftarrow":"←","LeftArrow":"←","Leftarrow":"⇐","LeftArrowRightArrow":"⇆","leftarrowtail":"↢","LeftCeiling":"⌈","LeftDoubleBracket":"⟦","LeftDownTeeVector":"⥡","LeftDownVectorBar":"⥙","LeftDownVector":"⇃","LeftFloor":"⌊","leftharpoondown":"↽","leftharpoonup":"↼","leftleftarrows":"⇇","leftrightarrow":"↔","LeftRightArrow":"↔","Leftrightarrow":"⇔","leftrightarrows":"⇆","leftrightharpoons":"⇋","leftrightsquigarrow":"↭","LeftRightVector":"⥎","LeftTeeArrow":"↤","LeftTee":"⊣","LeftTeeVector":"⥚","leftthreetimes":"⋋","LeftTriangleBar":"⧏","LeftTriangle":"⊲","LeftTriangleEqual":"⊴","LeftUpDownVector":"⥑","LeftUpTeeVector":"⥠","LeftUpVectorBar":"⥘","LeftUpVector":"↿","LeftVectorBar":"⥒","LeftVector":"↼","lEg":"⪋","leg":"⋚","leq":"≤","leqq":"≦","leqslant":"⩽","lescc":"⪨","les":"⩽","lesdot":"⩿","lesdoto":"⪁","lesdotor":"⪃","lesg":"⋚︀","lesges":"⪓","lessapprox":"⪅","lessdot":"⋖","lesseqgtr":"⋚","lesseqqgtr":"⪋","LessEqualGreater":"⋚","LessFullEqual":"≦","LessGreater":"≶","lessgtr":"≶","LessLess":"⪡","lesssim":"≲","LessSlantEqual":"⩽","LessTilde":"≲","lfisht":"⥼","lfloor":"⌊","Lfr":"𝔏","lfr":"𝔩","lg":"≶","lgE":"⪑","lHar":"⥢","lhard":"↽","lharu":"↼","lharul":"⥪","lhblk":"▄","LJcy":"Љ","ljcy":"љ","llarr":"⇇","ll":"≪","Ll":"⋘","llcorner":"⌞","Lleftarrow":"⇚","llhard":"⥫","lltri":"◺","Lmidot":"Ŀ","lmidot":"ŀ","lmoustache":"⎰","lmoust":"⎰","lnap":"⪉","lnapprox":"⪉","lne":"⪇","lnE":"≨","lneq":"⪇","lneqq":"≨","lnsim":"⋦","loang":"⟬","loarr":"⇽","lobrk":"⟦","longleftarrow":"⟵","LongLeftArrow":"⟵","Longleftarrow":"⟸","longleftrightarrow":"⟷","LongLeftRightArrow":"⟷","Longleftrightarrow":"⟺","longmapsto":"⟼","longrightarrow":"⟶","LongRightArrow":"⟶","Longrightarrow":"⟹","looparrowleft":"↫","looparrowright":"↬","lopar":"⦅","Lopf":"𝕃","lopf":"𝕝","loplus":"⨭","lotimes":"⨴","lowast":"∗","lowbar":"_","LowerLeftArrow":"↙","LowerRightArrow":"↘","loz":"◊","lozenge":"◊","lozf":"⧫","lpar":"(","lparlt":"⦓","lrarr":"⇆","lrcorner":"⌟","lrhar":"⇋","lrhard":"⥭","lrm":"‎","lrtri":"⊿","lsaquo":"‹","lscr":"𝓁","Lscr":"ℒ","lsh":"↰","Lsh":"↰","lsim":"≲","lsime":"⪍","lsimg":"⪏","lsqb":"[","lsquo":"‘","lsquor":"‚","Lstrok":"Ł","lstrok":"ł","ltcc":"⪦","ltcir":"⩹","lt":"<","LT":"<","Lt":"≪","ltdot":"⋖","lthree":"⋋","ltimes":"⋉","ltlarr":"⥶","ltquest":"⩻","ltri":"◃","ltrie":"⊴","ltrif":"◂","ltrPar":"⦖","lurdshar":"⥊","luruhar":"⥦","lvertneqq":"≨︀","lvnE":"≨︀","macr":"¯","male":"♂","malt":"✠","maltese":"✠","Map":"⤅","map":"↦","mapsto":"↦","mapstodown":"↧","mapstoleft":"↤","mapstoup":"↥","marker":"▮","mcomma":"⨩","Mcy":"М","mcy":"м","mdash":"—","mDDot":"∺","measuredangle":"∡","MediumSpace":" ","Mellintrf":"ℳ","Mfr":"𝔐","mfr":"𝔪","mho":"℧","micro":"µ","midast":"*","midcir":"⫰","mid":"∣","middot":"·","minusb":"⊟","minus":"−","minusd":"∸","minusdu":"⨪","MinusPlus":"∓","mlcp":"⫛","mldr":"…","mnplus":"∓","models":"⊧","Mopf":"𝕄","mopf":"𝕞","mp":"∓","mscr":"𝓂","Mscr":"ℳ","mstpos":"∾","Mu":"Μ","mu":"μ","multimap":"⊸","mumap":"⊸","nabla":"∇","Nacute":"Ń","nacute":"ń","nang":"∠⃒","nap":"≉","napE":"⩰̸","napid":"≋̸","napos":"ʼn","napprox":"≉","natural":"♮","naturals":"ℕ","natur":"♮","nbsp":" ","nbump":"≎̸","nbumpe":"≏̸","ncap":"⩃","Ncaron":"Ň","ncaron":"ň","Ncedil":"Ņ","ncedil":"ņ","ncong":"≇","ncongdot":"⩭̸","ncup":"⩂","Ncy":"Н","ncy":"н","ndash":"–","nearhk":"⤤","nearr":"↗","neArr":"⇗","nearrow":"↗","ne":"≠","nedot":"≐̸","NegativeMediumSpace":"​","NegativeThickSpace":"​","NegativeThinSpace":"​","NegativeVeryThinSpace":"​","nequiv":"≢","nesear":"⤨","nesim":"≂̸","NestedGreaterGreater":"≫","NestedLessLess":"≪","NewLine":"\\n","nexist":"∄","nexists":"∄","Nfr":"𝔑","nfr":"𝔫","ngE":"≧̸","nge":"≱","ngeq":"≱","ngeqq":"≧̸","ngeqslant":"⩾̸","nges":"⩾̸","nGg":"⋙̸","ngsim":"≵","nGt":"≫⃒","ngt":"≯","ngtr":"≯","nGtv":"≫̸","nharr":"↮","nhArr":"⇎","nhpar":"⫲","ni":"∋","nis":"⋼","nisd":"⋺","niv":"∋","NJcy":"Њ","njcy":"њ","nlarr":"↚","nlArr":"⇍","nldr":"‥","nlE":"≦̸","nle":"≰","nleftarrow":"↚","nLeftarrow":"⇍","nleftrightarrow":"↮","nLeftrightarrow":"⇎","nleq":"≰","nleqq":"≦̸","nleqslant":"⩽̸","nles":"⩽̸","nless":"≮","nLl":"⋘̸","nlsim":"≴","nLt":"≪⃒","nlt":"≮","nltri":"⋪","nltrie":"⋬","nLtv":"≪̸","nmid":"∤","NoBreak":"⁠","NonBreakingSpace":" ","nopf":"𝕟","Nopf":"ℕ","Not":"⫬","not":"¬","NotCongruent":"≢","NotCupCap":"≭","NotDoubleVerticalBar":"∦","NotElement":"∉","NotEqual":"≠","NotEqualTilde":"≂̸","NotExists":"∄","NotGreater":"≯","NotGreaterEqual":"≱","NotGreaterFullEqual":"≧̸","NotGreaterGreater":"≫̸","NotGreaterLess":"≹","NotGreaterSlantEqual":"⩾̸","NotGreaterTilde":"≵","NotHumpDownHump":"≎̸","NotHumpEqual":"≏̸","notin":"∉","notindot":"⋵̸","notinE":"⋹̸","notinva":"∉","notinvb":"⋷","notinvc":"⋶","NotLeftTriangleBar":"⧏̸","NotLeftTriangle":"⋪","NotLeftTriangleEqual":"⋬","NotLess":"≮","NotLessEqual":"≰","NotLessGreater":"≸","NotLessLess":"≪̸","NotLessSlantEqual":"⩽̸","NotLessTilde":"≴","NotNestedGreaterGreater":"⪢̸","NotNestedLessLess":"⪡̸","notni":"∌","notniva":"∌","notnivb":"⋾","notnivc":"⋽","NotPrecedes":"⊀","NotPrecedesEqual":"⪯̸","NotPrecedesSlantEqual":"⋠","NotReverseElement":"∌","NotRightTriangleBar":"⧐̸","NotRightTriangle":"⋫","NotRightTriangleEqual":"⋭","NotSquareSubset":"⊏̸","NotSquareSubsetEqual":"⋢","NotSquareSuperset":"⊐̸","NotSquareSupersetEqual":"⋣","NotSubset":"⊂⃒","NotSubsetEqual":"⊈","NotSucceeds":"⊁","NotSucceedsEqual":"⪰̸","NotSucceedsSlantEqual":"⋡","NotSucceedsTilde":"≿̸","NotSuperset":"⊃⃒","NotSupersetEqual":"⊉","NotTilde":"≁","NotTildeEqual":"≄","NotTildeFullEqual":"≇","NotTildeTilde":"≉","NotVerticalBar":"∤","nparallel":"∦","npar":"∦","nparsl":"⫽⃥","npart":"∂̸","npolint":"⨔","npr":"⊀","nprcue":"⋠","nprec":"⊀","npreceq":"⪯̸","npre":"⪯̸","nrarrc":"⤳̸","nrarr":"↛","nrArr":"⇏","nrarrw":"↝̸","nrightarrow":"↛","nRightarrow":"⇏","nrtri":"⋫","nrtrie":"⋭","nsc":"⊁","nsccue":"⋡","nsce":"⪰̸","Nscr":"𝒩","nscr":"𝓃","nshortmid":"∤","nshortparallel":"∦","nsim":"≁","nsime":"≄","nsimeq":"≄","nsmid":"∤","nspar":"∦","nsqsube":"⋢","nsqsupe":"⋣","nsub":"⊄","nsubE":"⫅̸","nsube":"⊈","nsubset":"⊂⃒","nsubseteq":"⊈","nsubseteqq":"⫅̸","nsucc":"⊁","nsucceq":"⪰̸","nsup":"⊅","nsupE":"⫆̸","nsupe":"⊉","nsupset":"⊃⃒","nsupseteq":"⊉","nsupseteqq":"⫆̸","ntgl":"≹","Ntilde":"Ñ","ntilde":"ñ","ntlg":"≸","ntriangleleft":"⋪","ntrianglelefteq":"⋬","ntriangleright":"⋫","ntrianglerighteq":"⋭","Nu":"Ν","nu":"ν","num":"#","numero":"№","numsp":" ","nvap":"≍⃒","nvdash":"⊬","nvDash":"⊭","nVdash":"⊮","nVDash":"⊯","nvge":"≥⃒","nvgt":">⃒","nvHarr":"⤄","nvinfin":"⧞","nvlArr":"⤂","nvle":"≤⃒","nvlt":"<⃒","nvltrie":"⊴⃒","nvrArr":"⤃","nvrtrie":"⊵⃒","nvsim":"∼⃒","nwarhk":"⤣","nwarr":"↖","nwArr":"⇖","nwarrow":"↖","nwnear":"⤧","Oacute":"Ó","oacute":"ó","oast":"⊛","Ocirc":"Ô","ocirc":"ô","ocir":"⊚","Ocy":"О","ocy":"о","odash":"⊝","Odblac":"Ő","odblac":"ő","odiv":"⨸","odot":"⊙","odsold":"⦼","OElig":"Œ","oelig":"œ","ofcir":"⦿","Ofr":"𝔒","ofr":"𝔬","ogon":"˛","Ograve":"Ò","ograve":"ò","ogt":"⧁","ohbar":"⦵","ohm":"Ω","oint":"∮","olarr":"↺","olcir":"⦾","olcross":"⦻","oline":"‾","olt":"⧀","Omacr":"Ō","omacr":"ō","Omega":"Ω","omega":"ω","Omicron":"Ο","omicron":"ο","omid":"⦶","ominus":"⊖","Oopf":"𝕆","oopf":"𝕠","opar":"⦷","OpenCurlyDoubleQuote":"“","OpenCurlyQuote":"‘","operp":"⦹","oplus":"⊕","orarr":"↻","Or":"⩔","or":"∨","ord":"⩝","order":"ℴ","orderof":"ℴ","ordf":"ª","ordm":"º","origof":"⊶","oror":"⩖","orslope":"⩗","orv":"⩛","oS":"Ⓢ","Oscr":"𝒪","oscr":"ℴ","Oslash":"Ø","oslash":"ø","osol":"⊘","Otilde":"Õ","otilde":"õ","otimesas":"⨶","Otimes":"⨷","otimes":"⊗","Ouml":"Ö","ouml":"ö","ovbar":"⌽","OverBar":"‾","OverBrace":"⏞","OverBracket":"⎴","OverParenthesis":"⏜","para":"¶","parallel":"∥","par":"∥","parsim":"⫳","parsl":"⫽","part":"∂","PartialD":"∂","Pcy":"П","pcy":"п","percnt":"%","period":".","permil":"‰","perp":"⊥","pertenk":"‱","Pfr":"𝔓","pfr":"𝔭","Phi":"Φ","phi":"φ","phiv":"ϕ","phmmat":"ℳ","phone":"☎","Pi":"Π","pi":"π","pitchfork":"⋔","piv":"ϖ","planck":"ℏ","planckh":"ℎ","plankv":"ℏ","plusacir":"⨣","plusb":"⊞","pluscir":"⨢","plus":"+","plusdo":"∔","plusdu":"⨥","pluse":"⩲","PlusMinus":"±","plusmn":"±","plussim":"⨦","plustwo":"⨧","pm":"±","Poincareplane":"ℌ","pointint":"⨕","popf":"𝕡","Popf":"ℙ","pound":"£","prap":"⪷","Pr":"⪻","pr":"≺","prcue":"≼","precapprox":"⪷","prec":"≺","preccurlyeq":"≼","Precedes":"≺","PrecedesEqual":"⪯","PrecedesSlantEqual":"≼","PrecedesTilde":"≾","preceq":"⪯","precnapprox":"⪹","precneqq":"⪵","precnsim":"⋨","pre":"⪯","prE":"⪳","precsim":"≾","prime":"′","Prime":"″","primes":"ℙ","prnap":"⪹","prnE":"⪵","prnsim":"⋨","prod":"∏","Product":"∏","profalar":"⌮","profline":"⌒","profsurf":"⌓","prop":"∝","Proportional":"∝","Proportion":"∷","propto":"∝","prsim":"≾","prurel":"⊰","Pscr":"𝒫","pscr":"𝓅","Psi":"Ψ","psi":"ψ","puncsp":" ","Qfr":"𝔔","qfr":"𝔮","qint":"⨌","qopf":"𝕢","Qopf":"ℚ","qprime":"⁗","Qscr":"𝒬","qscr":"𝓆","quaternions":"ℍ","quatint":"⨖","quest":"?","questeq":"≟","quot":"\\"","QUOT":"\\"","rAarr":"⇛","race":"∽̱","Racute":"Ŕ","racute":"ŕ","radic":"√","raemptyv":"⦳","rang":"⟩","Rang":"⟫","rangd":"⦒","range":"⦥","rangle":"⟩","raquo":"»","rarrap":"⥵","rarrb":"⇥","rarrbfs":"⤠","rarrc":"⤳","rarr":"→","Rarr":"↠","rArr":"⇒","rarrfs":"⤞","rarrhk":"↪","rarrlp":"↬","rarrpl":"⥅","rarrsim":"⥴","Rarrtl":"⤖","rarrtl":"↣","rarrw":"↝","ratail":"⤚","rAtail":"⤜","ratio":"∶","rationals":"ℚ","rbarr":"⤍","rBarr":"⤏","RBarr":"⤐","rbbrk":"❳","rbrace":"}","rbrack":"]","rbrke":"⦌","rbrksld":"⦎","rbrkslu":"⦐","Rcaron":"Ř","rcaron":"ř","Rcedil":"Ŗ","rcedil":"ŗ","rceil":"⌉","rcub":"}","Rcy":"Р","rcy":"р","rdca":"⤷","rdldhar":"⥩","rdquo":"”","rdquor":"”","rdsh":"↳","real":"ℜ","realine":"ℛ","realpart":"ℜ","reals":"ℝ","Re":"ℜ","rect":"▭","reg":"®","REG":"®","ReverseElement":"∋","ReverseEquilibrium":"⇋","ReverseUpEquilibrium":"⥯","rfisht":"⥽","rfloor":"⌋","rfr":"𝔯","Rfr":"ℜ","rHar":"⥤","rhard":"⇁","rharu":"⇀","rharul":"⥬","Rho":"Ρ","rho":"ρ","rhov":"ϱ","RightAngleBracket":"⟩","RightArrowBar":"⇥","rightarrow":"→","RightArrow":"→","Rightarrow":"⇒","RightArrowLeftArrow":"⇄","rightarrowtail":"↣","RightCeiling":"⌉","RightDoubleBracket":"⟧","RightDownTeeVector":"⥝","RightDownVectorBar":"⥕","RightDownVector":"⇂","RightFloor":"⌋","rightharpoondown":"⇁","rightharpoonup":"⇀","rightleftarrows":"⇄","rightleftharpoons":"⇌","rightrightarrows":"⇉","rightsquigarrow":"↝","RightTeeArrow":"↦","RightTee":"⊢","RightTeeVector":"⥛","rightthreetimes":"⋌","RightTriangleBar":"⧐","RightTriangle":"⊳","RightTriangleEqual":"⊵","RightUpDownVector":"⥏","RightUpTeeVector":"⥜","RightUpVectorBar":"⥔","RightUpVector":"↾","RightVectorBar":"⥓","RightVector":"⇀","ring":"˚","risingdotseq":"≓","rlarr":"⇄","rlhar":"⇌","rlm":"‏","rmoustache":"⎱","rmoust":"⎱","rnmid":"⫮","roang":"⟭","roarr":"⇾","robrk":"⟧","ropar":"⦆","ropf":"𝕣","Ropf":"ℝ","roplus":"⨮","rotimes":"⨵","RoundImplies":"⥰","rpar":")","rpargt":"⦔","rppolint":"⨒","rrarr":"⇉","Rrightarrow":"⇛","rsaquo":"›","rscr":"𝓇","Rscr":"ℛ","rsh":"↱","Rsh":"↱","rsqb":"]","rsquo":"’","rsquor":"’","rthree":"⋌","rtimes":"⋊","rtri":"▹","rtrie":"⊵","rtrif":"▸","rtriltri":"⧎","RuleDelayed":"⧴","ruluhar":"⥨","rx":"℞","Sacute":"Ś","sacute":"ś","sbquo":"‚","scap":"⪸","Scaron":"Š","scaron":"š","Sc":"⪼","sc":"≻","sccue":"≽","sce":"⪰","scE":"⪴","Scedil":"Ş","scedil":"ş","Scirc":"Ŝ","scirc":"ŝ","scnap":"⪺","scnE":"⪶","scnsim":"⋩","scpolint":"⨓","scsim":"≿","Scy":"С","scy":"с","sdotb":"⊡","sdot":"⋅","sdote":"⩦","searhk":"⤥","searr":"↘","seArr":"⇘","searrow":"↘","sect":"§","semi":";","seswar":"⤩","setminus":"∖","setmn":"∖","sext":"✶","Sfr":"𝔖","sfr":"𝔰","sfrown":"⌢","sharp":"♯","SHCHcy":"Щ","shchcy":"щ","SHcy":"Ш","shcy":"ш","ShortDownArrow":"↓","ShortLeftArrow":"←","shortmid":"∣","shortparallel":"∥","ShortRightArrow":"→","ShortUpArrow":"↑","shy":"­","Sigma":"Σ","sigma":"σ","sigmaf":"ς","sigmav":"ς","sim":"∼","simdot":"⩪","sime":"≃","simeq":"≃","simg":"⪞","simgE":"⪠","siml":"⪝","simlE":"⪟","simne":"≆","simplus":"⨤","simrarr":"⥲","slarr":"←","SmallCircle":"∘","smallsetminus":"∖","smashp":"⨳","smeparsl":"⧤","smid":"∣","smile":"⌣","smt":"⪪","smte":"⪬","smtes":"⪬︀","SOFTcy":"Ь","softcy":"ь","solbar":"⌿","solb":"⧄","sol":"/","Sopf":"𝕊","sopf":"𝕤","spades":"♠","spadesuit":"♠","spar":"∥","sqcap":"⊓","sqcaps":"⊓︀","sqcup":"⊔","sqcups":"⊔︀","Sqrt":"√","sqsub":"⊏","sqsube":"⊑","sqsubset":"⊏","sqsubseteq":"⊑","sqsup":"⊐","sqsupe":"⊒","sqsupset":"⊐","sqsupseteq":"⊒","square":"□","Square":"□","SquareIntersection":"⊓","SquareSubset":"⊏","SquareSubsetEqual":"⊑","SquareSuperset":"⊐","SquareSupersetEqual":"⊒","SquareUnion":"⊔","squarf":"▪","squ":"□","squf":"▪","srarr":"→","Sscr":"𝒮","sscr":"𝓈","ssetmn":"∖","ssmile":"⌣","sstarf":"⋆","Star":"⋆","star":"☆","starf":"★","straightepsilon":"ϵ","straightphi":"ϕ","strns":"¯","sub":"⊂","Sub":"⋐","subdot":"⪽","subE":"⫅","sube":"⊆","subedot":"⫃","submult":"⫁","subnE":"⫋","subne":"⊊","subplus":"⪿","subrarr":"⥹","subset":"⊂","Subset":"⋐","subseteq":"⊆","subseteqq":"⫅","SubsetEqual":"⊆","subsetneq":"⊊","subsetneqq":"⫋","subsim":"⫇","subsub":"⫕","subsup":"⫓","succapprox":"⪸","succ":"≻","succcurlyeq":"≽","Succeeds":"≻","SucceedsEqual":"⪰","SucceedsSlantEqual":"≽","SucceedsTilde":"≿","succeq":"⪰","succnapprox":"⪺","succneqq":"⪶","succnsim":"⋩","succsim":"≿","SuchThat":"∋","sum":"∑","Sum":"∑","sung":"♪","sup1":"¹","sup2":"²","sup3":"³","sup":"⊃","Sup":"⋑","supdot":"⪾","supdsub":"⫘","supE":"⫆","supe":"⊇","supedot":"⫄","Superset":"⊃","SupersetEqual":"⊇","suphsol":"⟉","suphsub":"⫗","suplarr":"⥻","supmult":"⫂","supnE":"⫌","supne":"⊋","supplus":"⫀","supset":"⊃","Supset":"⋑","supseteq":"⊇","supseteqq":"⫆","supsetneq":"⊋","supsetneqq":"⫌","supsim":"⫈","supsub":"⫔","supsup":"⫖","swarhk":"⤦","swarr":"↙","swArr":"⇙","swarrow":"↙","swnwar":"⤪","szlig":"ß","Tab":"\\t","target":"⌖","Tau":"Τ","tau":"τ","tbrk":"⎴","Tcaron":"Ť","tcaron":"ť","Tcedil":"Ţ","tcedil":"ţ","Tcy":"Т","tcy":"т","tdot":"⃛","telrec":"⌕","Tfr":"𝔗","tfr":"𝔱","there4":"∴","therefore":"∴","Therefore":"∴","Theta":"Θ","theta":"θ","thetasym":"ϑ","thetav":"ϑ","thickapprox":"≈","thicksim":"∼","ThickSpace":"  ","ThinSpace":" ","thinsp":" ","thkap":"≈","thksim":"∼","THORN":"Þ","thorn":"þ","tilde":"˜","Tilde":"∼","TildeEqual":"≃","TildeFullEqual":"≅","TildeTilde":"≈","timesbar":"⨱","timesb":"⊠","times":"×","timesd":"⨰","tint":"∭","toea":"⤨","topbot":"⌶","topcir":"⫱","top":"⊤","Topf":"𝕋","topf":"𝕥","topfork":"⫚","tosa":"⤩","tprime":"‴","trade":"™","TRADE":"™","triangle":"▵","triangledown":"▿","triangleleft":"◃","trianglelefteq":"⊴","triangleq":"≜","triangleright":"▹","trianglerighteq":"⊵","tridot":"◬","trie":"≜","triminus":"⨺","TripleDot":"⃛","triplus":"⨹","trisb":"⧍","tritime":"⨻","trpezium":"⏢","Tscr":"𝒯","tscr":"𝓉","TScy":"Ц","tscy":"ц","TSHcy":"Ћ","tshcy":"ћ","Tstrok":"Ŧ","tstrok":"ŧ","twixt":"≬","twoheadleftarrow":"↞","twoheadrightarrow":"↠","Uacute":"Ú","uacute":"ú","uarr":"↑","Uarr":"↟","uArr":"⇑","Uarrocir":"⥉","Ubrcy":"Ў","ubrcy":"ў","Ubreve":"Ŭ","ubreve":"ŭ","Ucirc":"Û","ucirc":"û","Ucy":"У","ucy":"у","udarr":"⇅","Udblac":"Ű","udblac":"ű","udhar":"⥮","ufisht":"⥾","Ufr":"𝔘","ufr":"𝔲","Ugrave":"Ù","ugrave":"ù","uHar":"⥣","uharl":"↿","uharr":"↾","uhblk":"▀","ulcorn":"⌜","ulcorner":"⌜","ulcrop":"⌏","ultri":"◸","Umacr":"Ū","umacr":"ū","uml":"¨","UnderBar":"_","UnderBrace":"⏟","UnderBracket":"⎵","UnderParenthesis":"⏝","Union":"⋃","UnionPlus":"⊎","Uogon":"Ų","uogon":"ų","Uopf":"𝕌","uopf":"𝕦","UpArrowBar":"⤒","uparrow":"↑","UpArrow":"↑","Uparrow":"⇑","UpArrowDownArrow":"⇅","updownarrow":"↕","UpDownArrow":"↕","Updownarrow":"⇕","UpEquilibrium":"⥮","upharpoonleft":"↿","upharpoonright":"↾","uplus":"⊎","UpperLeftArrow":"↖","UpperRightArrow":"↗","upsi":"υ","Upsi":"ϒ","upsih":"ϒ","Upsilon":"Υ","upsilon":"υ","UpTeeArrow":"↥","UpTee":"⊥","upuparrows":"⇈","urcorn":"⌝","urcorner":"⌝","urcrop":"⌎","Uring":"Ů","uring":"ů","urtri":"◹","Uscr":"𝒰","uscr":"𝓊","utdot":"⋰","Utilde":"Ũ","utilde":"ũ","utri":"▵","utrif":"▴","uuarr":"⇈","Uuml":"Ü","uuml":"ü","uwangle":"⦧","vangrt":"⦜","varepsilon":"ϵ","varkappa":"ϰ","varnothing":"∅","varphi":"ϕ","varpi":"ϖ","varpropto":"∝","varr":"↕","vArr":"⇕","varrho":"ϱ","varsigma":"ς","varsubsetneq":"⊊︀","varsubsetneqq":"⫋︀","varsupsetneq":"⊋︀","varsupsetneqq":"⫌︀","vartheta":"ϑ","vartriangleleft":"⊲","vartriangleright":"⊳","vBar":"⫨","Vbar":"⫫","vBarv":"⫩","Vcy":"В","vcy":"в","vdash":"⊢","vDash":"⊨","Vdash":"⊩","VDash":"⊫","Vdashl":"⫦","veebar":"⊻","vee":"∨","Vee":"⋁","veeeq":"≚","vellip":"⋮","verbar":"|","Verbar":"‖","vert":"|","Vert":"‖","VerticalBar":"∣","VerticalLine":"|","VerticalSeparator":"❘","VerticalTilde":"≀","VeryThinSpace":" ","Vfr":"𝔙","vfr":"𝔳","vltri":"⊲","vnsub":"⊂⃒","vnsup":"⊃⃒","Vopf":"𝕍","vopf":"𝕧","vprop":"∝","vrtri":"⊳","Vscr":"𝒱","vscr":"𝓋","vsubnE":"⫋︀","vsubne":"⊊︀","vsupnE":"⫌︀","vsupne":"⊋︀","Vvdash":"⊪","vzigzag":"⦚","Wcirc":"Ŵ","wcirc":"ŵ","wedbar":"⩟","wedge":"∧","Wedge":"⋀","wedgeq":"≙","weierp":"℘","Wfr":"𝔚","wfr":"𝔴","Wopf":"𝕎","wopf":"𝕨","wp":"℘","wr":"≀","wreath":"≀","Wscr":"𝒲","wscr":"𝓌","xcap":"⋂","xcirc":"◯","xcup":"⋃","xdtri":"▽","Xfr":"𝔛","xfr":"𝔵","xharr":"⟷","xhArr":"⟺","Xi":"Ξ","xi":"ξ","xlarr":"⟵","xlArr":"⟸","xmap":"⟼","xnis":"⋻","xodot":"⨀","Xopf":"𝕏","xopf":"𝕩","xoplus":"⨁","xotime":"⨂","xrarr":"⟶","xrArr":"⟹","Xscr":"𝒳","xscr":"𝓍","xsqcup":"⨆","xuplus":"⨄","xutri":"△","xvee":"⋁","xwedge":"⋀","Yacute":"Ý","yacute":"ý","YAcy":"Я","yacy":"я","Ycirc":"Ŷ","ycirc":"ŷ","Ycy":"Ы","ycy":"ы","yen":"¥","Yfr":"𝔜","yfr":"𝔶","YIcy":"Ї","yicy":"ї","Yopf":"𝕐","yopf":"𝕪","Yscr":"𝒴","yscr":"𝓎","YUcy":"Ю","yucy":"ю","yuml":"ÿ","Yuml":"Ÿ","Zacute":"Ź","zacute":"ź","Zcaron":"Ž","zcaron":"ž","Zcy":"З","zcy":"з","Zdot":"Ż","zdot":"ż","zeetrf":"ℨ","ZeroWidthSpace":"​","Zeta":"Ζ","zeta":"ζ","zfr":"𝔷","Zfr":"ℨ","ZHcy":"Ж","zhcy":"ж","zigrarr":"⇝","zopf":"𝕫","Zopf":"ℤ","Zscr":"𝒵","zscr":"𝓏","zwj":"‍","zwnj":"‌"}')},function(d){d.exports=JSON.parse('{"Aacute":"Á","aacute":"á","Acirc":"Â","acirc":"â","acute":"´","AElig":"Æ","aelig":"æ","Agrave":"À","agrave":"à","amp":"&","AMP":"&","Aring":"Å","aring":"å","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","brvbar":"¦","Ccedil":"Ç","ccedil":"ç","cedil":"¸","cent":"¢","copy":"©","COPY":"©","curren":"¤","deg":"°","divide":"÷","Eacute":"É","eacute":"é","Ecirc":"Ê","ecirc":"ê","Egrave":"È","egrave":"è","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","frac12":"½","frac14":"¼","frac34":"¾","gt":">","GT":">","Iacute":"Í","iacute":"í","Icirc":"Î","icirc":"î","iexcl":"¡","Igrave":"Ì","igrave":"ì","iquest":"¿","Iuml":"Ï","iuml":"ï","laquo":"«","lt":"<","LT":"<","macr":"¯","micro":"µ","middot":"·","nbsp":" ","not":"¬","Ntilde":"Ñ","ntilde":"ñ","Oacute":"Ó","oacute":"ó","Ocirc":"Ô","ocirc":"ô","Ograve":"Ò","ograve":"ò","ordf":"ª","ordm":"º","Oslash":"Ø","oslash":"ø","Otilde":"Õ","otilde":"õ","Ouml":"Ö","ouml":"ö","para":"¶","plusmn":"±","pound":"£","quot":"\\"","QUOT":"\\"","raquo":"»","reg":"®","REG":"®","sect":"§","shy":"­","sup1":"¹","sup2":"²","sup3":"³","szlig":"ß","THORN":"Þ","thorn":"þ","times":"×","Uacute":"Ú","uacute":"ú","Ucirc":"Û","ucirc":"û","Ugrave":"Ù","ugrave":"ù","uml":"¨","Uuml":"Ü","uuml":"ü","Yacute":"Ý","yacute":"ý","yen":"¥","yuml":"ÿ"}')},function(d){d.exports=JSON.parse(`{"amp":"&","apos":"'","gt":">","lt":"<","quot":"\\""}`)},function(d,r,t){var e=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r,"__esModule",{value:!0});var n=e(t(265));function i(a){if(a>=55296&&a<=57343||a>1114111)return"�";a in n.default&&(a=n.default[a]);var s="";return a>65535&&(a-=65536,s+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),s+=String.fromCharCode(a),s}r.default=i},function(d){d.exports=JSON.parse('{"0":65533,"128":8364,"130":8218,"131":402,"132":8222,"133":8230,"134":8224,"135":8225,"136":710,"137":8240,"138":352,"139":8249,"140":338,"142":381,"145":8216,"146":8217,"147":8220,"148":8221,"149":8226,"150":8211,"151":8212,"152":732,"153":8482,"154":353,"155":8250,"156":339,"158":382,"159":376}')},function(d,r,t){var e=this&&this.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(r,"__esModule",{value:!0}),r.escape=r.encodeHTML=r.encodeXML=void 0;var n=e(t(263)),i=v(n.default),a=l(i);r.encodeXML=O(i,a);var s=e(t(261)),o=v(s.default),f=l(o);r.encodeHTML=O(o,f);function v(T){return Object.keys(T).sort().reduce(function(c,h){return c[T[h]]="&"+h+";",c},{})}function l(T){for(var c=[],h=[],u=0,g=Object.keys(T);u<g.length;u++){var M=g[u];M.length===1?c.push("\\"+M):h.push(M)}c.sort();for(var A=0;A<c.length-1;A++){for(var I=A;I<c.length-1&&c[I].charCodeAt(1)+1===c[I+1].charCodeAt(1);)I+=1;var b=1+I-A;b<3||c.splice(A,b,c[A]+"-"+c[I])}return h.unshift("["+c.join("")+"]"),new RegExp(h.join("|"),"g")}var p=/(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;function y(T){return"&#x"+T.codePointAt(0).toString(16).toUpperCase()+";"}function O(T,c){return function(h){return h.replace(c,function(u){return T[u]}).replace(p,y)}}var x=l(i);function m(T){return T.replace(x,y).replace(p,y)}r.escape=m},function(d){d.exports=JSON.parse('{"elementNames":{"altglyph":"altGlyph","altglyphdef":"altGlyphDef","altglyphitem":"altGlyphItem","animatecolor":"animateColor","animatemotion":"animateMotion","animatetransform":"animateTransform","clippath":"clipPath","feblend":"feBlend","fecolormatrix":"feColorMatrix","fecomponenttransfer":"feComponentTransfer","fecomposite":"feComposite","feconvolvematrix":"feConvolveMatrix","fediffuselighting":"feDiffuseLighting","fedisplacementmap":"feDisplacementMap","fedistantlight":"feDistantLight","fedropshadow":"feDropShadow","feflood":"feFlood","fefunca":"feFuncA","fefuncb":"feFuncB","fefuncg":"feFuncG","fefuncr":"feFuncR","fegaussianblur":"feGaussianBlur","feimage":"feImage","femerge":"feMerge","femergenode":"feMergeNode","femorphology":"feMorphology","feoffset":"feOffset","fepointlight":"fePointLight","fespecularlighting":"feSpecularLighting","fespotlight":"feSpotLight","fetile":"feTile","feturbulence":"feTurbulence","foreignobject":"foreignObject","glyphref":"glyphRef","lineargradient":"linearGradient","radialgradient":"radialGradient","textpath":"textPath"},"attributeNames":{"definitionurl":"definitionURL","attributename":"attributeName","attributetype":"attributeType","basefrequency":"baseFrequency","baseprofile":"baseProfile","calcmode":"calcMode","clippathunits":"clipPathUnits","diffuseconstant":"diffuseConstant","edgemode":"edgeMode","filterunits":"filterUnits","glyphref":"glyphRef","gradienttransform":"gradientTransform","gradientunits":"gradientUnits","kernelmatrix":"kernelMatrix","kernelunitlength":"kernelUnitLength","keypoints":"keyPoints","keysplines":"keySplines","keytimes":"keyTimes","lengthadjust":"lengthAdjust","limitingconeangle":"limitingConeAngle","markerheight":"markerHeight","markerunits":"markerUnits","markerwidth":"markerWidth","maskcontentunits":"maskContentUnits","maskunits":"maskUnits","numoctaves":"numOctaves","pathlength":"pathLength","patterncontentunits":"patternContentUnits","patterntransform":"patternTransform","patternunits":"patternUnits","pointsatx":"pointsAtX","pointsaty":"pointsAtY","pointsatz":"pointsAtZ","preservealpha":"preserveAlpha","preserveaspectratio":"preserveAspectRatio","primitiveunits":"primitiveUnits","refx":"refX","refy":"refY","repeatcount":"repeatCount","repeatdur":"repeatDur","requiredextensions":"requiredExtensions","requiredfeatures":"requiredFeatures","specularconstant":"specularConstant","specularexponent":"specularExponent","spreadmethod":"spreadMethod","startoffset":"startOffset","stddeviation":"stdDeviation","stitchtiles":"stitchTiles","surfacescale":"surfaceScale","systemlanguage":"systemLanguage","tablevalues":"tableValues","targetx":"targetX","targety":"targetY","textlength":"textLength","viewbox":"viewBox","viewtarget":"viewTarget","xchannelselector":"xChannelSelector","ychannelselector":"yChannelSelector","zoomandpan":"zoomAndPan"}}')},function(d,r){var t=r.getChildren=function(n){return n.children},e=r.getParent=function(n){return n.parent};r.getSiblings=function(n){var i=e(n);return i?t(i):[n]},r.getAttributeValue=function(n,i){return n.attribs&&n.attribs[i]},r.hasAttrib=function(n,i){return!!n.attribs&&hasOwnProperty.call(n.attribs,i)},r.getName=function(n){return n.name}},function(d,r){r.removeElement=function(t){if(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.parent){var e=t.parent.children;e.splice(e.lastIndexOf(t),1)}},r.replaceElement=function(t,e){var n=e.prev=t.prev;n&&(n.next=e);var i=e.next=t.next;i&&(i.prev=e);var a=e.parent=t.parent;if(a){var s=a.children;s[s.lastIndexOf(t)]=e}},r.appendChild=function(t,e){if(e.parent=t,t.children.push(e)!==1){var n=t.children[t.children.length-2];n.next=e,e.prev=n,e.next=null}},r.append=function(t,e){var n=t.parent,i=t.next;if(e.next=i,e.prev=t,t.next=e,e.parent=n,i){if(i.prev=e,n){var a=n.children;a.splice(a.lastIndexOf(i),0,e)}}else n&&n.children.push(e)},r.prepend=function(t,e){var n=t.parent;if(n){var i=n.children;i.splice(i.lastIndexOf(t),0,e)}t.prev&&(t.prev.next=e),e.parent=n,e.prev=t.prev,e.next=t,t.prev=e}},function(d,r,t){var e=t(256).isTag;d.exports={filter:n,find:i,findOneChild:a,findOne:s,existsOne:o,findAll:f};function n(v,l,p,y){return Array.isArray(l)||(l=[l]),(typeof y!="number"||!isFinite(y))&&(y=1/0),i(v,l,p!==!1,y)}function i(v,l,p,y){for(var O=[],x,m=0,T=l.length;m<T&&!(v(l[m])&&(O.push(l[m]),--y<=0)||(x=l[m].children,p&&x&&x.length>0&&(x=i(v,x,p,y),O=O.concat(x),y-=x.length,y<=0)));m++);return O}function a(v,l){for(var p=0,y=l.length;p<y;p++)if(v(l[p]))return l[p];return null}function s(v,l){for(var p=null,y=0,O=l.length;y<O&&!p;y++)if(e(l[y]))v(l[y])?p=l[y]:l[y].children.length>0&&(p=s(v,l[y].children));else continue;return p}function o(v,l){for(var p=0,y=l.length;p<y;p++)if(e(l[p])&&(v(l[p])||l[p].children.length>0&&o(v,l[p].children)))return!0;return!1}function f(v,l){for(var p=[],y=l.slice();y.length;){var O=y.shift();e(O)&&(O.children&&O.children.length>0&&y.unshift.apply(y,O.children),v(O)&&p.push(O))}return p}},function(d,r,t){var e=t(256),n=r.isTag=e.isTag;r.testElement=function(o,f){for(var v in o)if(o.hasOwnProperty(v)){if(v==="tag_name"){if(!n(f)||!o.tag_name(f.name))return!1}else if(v==="tag_type"){if(!o.tag_type(f.type))return!1}else if(v==="tag_contains"){if(n(f)||!o.tag_contains(f.data))return!1}else if(!f.attribs||!o[v](f.attribs[v]))return!1}return!0};var i={tag_name:function(o){return typeof o=="function"?function(f){return n(f)&&o(f.name)}:o==="*"?n:function(f){return n(f)&&f.name===o}},tag_type:function(o){return typeof o=="function"?function(f){return o(f.type)}:function(f){return f.type===o}},tag_contains:function(o){return typeof o=="function"?function(f){return!n(f)&&o(f.data)}:function(f){return!n(f)&&f.data===o}}};function a(o,f){return typeof f=="function"?function(v){return v.attribs&&f(v.attribs[o])}:function(v){return v.attribs&&v.attribs[o]===f}}function s(o,f){return function(v){return o(v)||f(v)}}r.getElements=function(o,f,v,l){var p=Object.keys(o).map(function(y){var O=o[y];return y in i?i[y](O):a(y,O)});return p.length===0?[]:this.filter(p.reduce(s),f,v,l)},r.getElementById=function(o,f,v){return Array.isArray(f)||(f=[f]),this.findOne(a("id",o),f,v!==!1)},r.getElementsByTagName=function(o,f,v,l){return this.filter(i.tag_name(o),f,v,l)},r.getElementsByTagType=function(o,f,v,l){return this.filter(i.tag_type(o),f,v,l)}},function(d,r){r.removeSubsets=function(n){for(var i=n.length,a,s,o;--i>-1;){for(a=s=n[i],n[i]=null,o=!0;s;){if(n.indexOf(s)>-1){o=!1,n.splice(i,1);break}s=s.parent}o&&(n[i]=a)}return n};var t={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16},e=r.compareDocumentPosition=function(n,i){var a=[],s=[],o,f,v,l,p,y;if(n===i)return 0;for(o=n;o;)a.unshift(o),o=o.parent;for(o=i;o;)s.unshift(o),o=o.parent;for(y=0;a[y]===s[y];)y++;return y===0?t.DISCONNECTED:(f=a[y-1],v=f.children,l=a[y],p=s[y],v.indexOf(l)>v.indexOf(p)?f===i?t.FOLLOWING|t.CONTAINED_BY:t.FOLLOWING:f===n?t.PRECEDING|t.CONTAINS:t.PRECEDING)};r.uniqueSort=function(n){var i=n.length,a,s;for(n=n.slice();--i>-1;)a=n[i],s=n.indexOf(a),s>-1&&s<i&&n.splice(i,1);return n.sort(function(o,f){var v=e(o,f);return v&t.PRECEDING?-1:v&t.FOLLOWING?1:0}),n}},function(d,r){d.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},function(d,r,t){d.exports=p;var e=t(275).parse,n=t(273),i=t(278),a=t(279),s=t(280),o=t(282),f=n.trueFunc,v=n.falseFunc,l=o.filters;function p(E,L,D){var R=O(E,L,D);return y(R,L)}function y(E,L){var D=L.adapter;return function(C){return D.isTag(C)&&E(C)}}function O(E,L,D){var R=e(E,L);return g(R,L,D)}function x(E){return E.type==="pseudo"&&(E.name==="scope"||Array.isArray(E.data)&&E.data.some(function(L){return L.some(x)}))}var m={type:"descendant"},T={type:"_flexibleDescendant"},c={type:"pseudo",name:"scope"},h={};function u(E,L,D){var R=L.adapter,C=!!D&&!!D.length&&D.every(function(W){return W===h||!!R.getParent(W)});E.forEach(function(W){if(!(W.length>0&&M(W[0])&&W[0].type!=="descendant"))if(C&&!(Array.isArray(W)?W.some(x):x(W)))W.unshift(m);else return;W.unshift(c)})}function g(E,L,D){E=E.filter(function(z){return z.length>0}),E.forEach(i);var R=Array.isArray(D);D=L&&L.context||D,D&&!R&&(D=[D]),u(E,L,D);var C=!1,W=E.map(function(z){if(z[0]&&z[1]&&z[0].name==="scope"){var H=z[1].type;R&&H==="descendant"?z[1]=T:(H==="adjacent"||H==="sibling")&&(C=!0)}return A(z,L,D)}).reduce(I,v);return W.shouldTestNextSiblings=C,W}function M(E){return a[E.type]<0}function A(E,L,D){return E.reduce(function(R,C){if(R===v)return R;if(!(C.type in s))throw new Error("Rule type "+C.type+" is not supported by css-select");return s[C.type](R,C,L,D)},L&&L.rootFunc||f)}function I(E,L){return L===v||E===f?E:E===v||L===f?L:function(R){return E(R)||L(R)}}function b(E){return E.some(M)}l.not=function(E,L,D,R){var C={xmlMode:!!(D&&D.xmlMode),strict:!!(D&&D.strict),adapter:D.adapter};if(C.strict&&(L.length>1||L.some(b)))throw new Error("complex selectors in :not aren't allowed in strict mode");var W=g(L,C,R);return W===v?E:W===f?v:function(H){return!W(H)&&E(H)}},l.has=function(E,L,D){var R=D.adapter,C={xmlMode:!!(D&&D.xmlMode),strict:!!(D&&D.strict),adapter:R},W=L.some(b)?[h]:null,z=g(L,C,W);return z===v?v:z===f?function(X){return R.getChildren(X).some(R.isTag)&&E(X)}:(z=y(z,D),W?function(X){return E(X)&&(W[0]=X,R.existsOne(z,R.getChildren(X)))}:function(X){return E(X)&&R.existsOne(z,R.getChildren(X))})},l.matches=function(E,L,D,R){var C={xmlMode:!!(D&&D.xmlMode),strict:!!(D&&D.strict),rootFunc:E,adapter:D.adapter};return g(L,C,R)},p.compileToken=g,p.compileUnsafe=O,p.Pseudos=o},function(d,r,t){var e=this&&this.__createBinding||(Object.create?function(s,o,f,v){v===void 0&&(v=f),Object.defineProperty(s,v,{enumerable:!0,get:function(){return o[f]}})}:function(s,o,f,v){v===void 0&&(v=f),s[v]=o[f]}),n=this&&this.__exportStar||function(s,o){for(var f in s)f!=="default"&&!o.hasOwnProperty(f)&&e(o,s,f)};Object.defineProperty(r,"__esModule",{value:!0}),n(t(276),r);var i=t(276);Object.defineProperty(r,"parse",{enumerable:!0,get:function(){return i.default}});var a=t(277);Object.defineProperty(r,"stringify",{enumerable:!0,get:function(){return a.default}})},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.default=x;var e=/^[^\\]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,n=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,i=/^\s*((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*(i)?\]/,a={undefined:"exists","":"equals","~":"element","^":"start",$:"end","*":"any","!":"not","|":"hyphen"},s={">":"child","<":"parent","~":"sibling","+":"adjacent"},o={"#":["id","equals"],".":["class","element"]},f=new Set(["has","not","matches"]),v=new Set(["contains","icontains"]),l=new Set(['"',"'"]);function p(c,h,u){var g=parseInt(h,16)-65536;return g!==g||u?h:g<0?String.fromCharCode(g+65536):String.fromCharCode(g>>10|55296,g&1023|56320)}function y(c){return c.replace(n,p)}function O(c){return c===" "||c===`
566
- `||c===" "||c==="\f"||c==="\r"}function x(c,h){var u=[];if(c=m(u,""+c,h),c!=="")throw new Error("Unmatched selector: "+c);return u}function m(c,h,u){var g=[],M=!1;function A(){var Q=h.match(e);if(!Q)throw new Error("Expected name, found "+h);var tt=Q[0];return h=h.substr(tt.length),y(tt)}function I(Q){for(;O(h.charAt(Q));)Q++;h=h.substr(Q)}function b(Q){for(var tt=0;h.charAt(--Q)==="\\";)tt++;return(tt&1)===1}for(I(0);h!=="";){var E=h.charAt(0);if(O(E))M=!0,I(1);else if(E in s)g.push({type:s[E]}),M=!1,I(1);else if(E===","){if(g.length===0)throw new Error("Empty sub-selector");c.push(g),g=[],M=!1,I(1)}else if(M&&(g.length>0&&g.push({type:"descendant"}),M=!1),E==="*")h=h.substr(1),g.push({type:"universal"});else if(E in o){var L=o[E],D=L[0],R=L[1];h=h.substr(1),g.push({type:"attribute",name:D,action:R,value:A(),ignoreCase:!1})}else if(E==="["){h=h.substr(1);var C=h.match(i);if(!C)throw new Error("Malformed attribute selector: "+h);h=h.substr(C[0].length);var W=y(C[1]);(!u||("lowerCaseAttributeNames"in u?u.lowerCaseAttributeNames:!u.xmlMode))&&(W=W.toLowerCase()),g.push({type:"attribute",name:W,action:a[C[2]],value:y(C[4]||C[5]||""),ignoreCase:!!C[6]})}else if(E===":"){if(h.charAt(1)===":"){h=h.substr(2),g.push({type:"pseudo-element",name:A().toLowerCase()});continue}h=h.substr(1);var z=A().toLowerCase(),C=null;if(h.charAt(0)==="(")if(f.has(z)){var H=h.charAt(1),X=l.has(H);if(h=h.substr(X?2:1),C=[],h=m(C,h,u),X){if(h.charAt(0)!==H)throw new Error("Unmatched quotes in :"+z);h=h.substr(1)}if(h.charAt(0)!==")")throw new Error("Missing closing parenthesis in :"+z+" ("+h+")");h=h.substr(1)}else{for(var Z=1,j=1;j>0&&Z<h.length;Z++)h.charAt(Z)==="("&&!b(Z)?j++:h.charAt(Z)===")"&&!b(Z)&&j--;if(j)throw new Error("Parenthesis not matched");if(C=h.substr(1,Z-2),h=h.substr(Z),v.has(z)){var H=C.charAt(0);H===C.slice(-1)&&l.has(H)&&(C=C.slice(1,-1)),C=y(C)}}g.push({type:"pseudo",name:z,data:C})}else if(e.test(h)){var G=A();(!u||("lowerCaseTags"in u?u.lowerCaseTags:!u.xmlMode))&&(G=G.toLowerCase()),g.push({type:"tag",name:G})}else return g.length&&g[g.length-1].type==="descendant"&&g.pop(),T(c,g),h}return T(c,g),h}function T(c,h){if(c.length>0&&h.length===0)throw new Error("Empty sub-selector");c.push(h)}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});var e={equals:"",element:"~",start:"^",end:"$",any:"*",not:"!",hyphen:"|"};function n(o){return o.map(i).join(", ")}r.default=n;function i(o){return o.map(a).join("")}function a(o){switch(o.type){case"child":return" > ";case"parent":return" < ";case"sibling":return" ~ ";case"adjacent":return" + ";case"descendant":return" ";case"universal":return"*";case"tag":return o.name;case"pseudo-element":return"::"+o.name;case"pseudo":return o.data===null?":"+o.name:typeof o.data=="string"?":"+o.name+"("+o.data+")":":"+o.name+"("+n(o.data)+")";case"attribute":return o.action==="exists"?"["+o.name+"]":o.name==="id"&&o.action==="equals"&&!o.ignoreCase?"#"+o.value:o.name==="class"&&o.action==="element"&&!o.ignoreCase?"."+o.value:"["+o.name+e[o.action]+"='"+o.value+"'"+(o.ignoreCase?"i":"")+"]";default:throw new Error("Unknown type")}}function s(o){return o}},function(d,r,t){d.exports=i;var e=t(279),n={__proto__:null,exists:10,equals:8,not:7,start:6,end:6,any:5,hyphen:4,element:4};function i(s){for(var o=s.map(a),f=1;f<s.length;f++){var v=o[f];if(!(v<0))for(var l=f-1;l>=0&&v<o[l];l--){var p=s[l+1];s[l+1]=s[l],s[l]=p,o[l+1]=o[l],o[l]=v}}}function a(s){var o=e[s.type];if(o===e.attribute)o=n[s.action],o===n.equals&&s.name==="id"&&(o=9),s.ignoreCase&&(o>>=1);else if(o===e.pseudo)if(!s.data)o=3;else if(s.name==="has"||s.name==="contains")o=0;else if(s.name==="matches"||s.name==="not"){o=0;for(var f=0;f<s.data.length;f++)if(s.data[f].length===1){var v=a(s.data[f][0]);if(v===0){o=0;break}v>o&&(o=v)}s.data.length>1&&o>0&&(o-=1)}else o=1;return o}},function(d){d.exports=JSON.parse('{"universal":50,"tag":30,"attribute":1,"pseudo":0,"descendant":-1,"child":-1,"parent":-1,"sibling":-1,"adjacent":-1}')},function(d,r,t){var e=t(281),n=t(282);d.exports={__proto__:null,attribute:e.compile,pseudo:n.compile,tag:function(i,a,s){var o=a.name,f=s.adapter;return function(l){return f.getName(l)===o&&i(l)}},descendant:function(i,a,s){var o=typeof WeakSet<"u"?new WeakSet:null,f=s.adapter;return function(l){for(var p=!1;!p&&(l=f.getParent(l));)(!o||!o.has(l))&&(p=i(l),!p&&o&&o.add(l));return p}},_flexibleDescendant:function(i,a,s){var o=s.adapter;return function(v){for(var l=i(v);!l&&(v=o.getParent(v));)l=i(v);return l}},parent:function(i,a,s){if(s&&s.strict)throw new Error("Parent selector isn't part of CSS3");var o=s.adapter;return function(l){return o.getChildren(l).some(f)};function f(v){return o.isTag(v)&&i(v)}},child:function(i,a,s){var o=s.adapter;return function(v){var l=o.getParent(v);return!!l&&i(l)}},sibling:function(i,a,s){var o=s.adapter;return function(v){for(var l=o.getSiblings(v),p=0;p<l.length;p++)if(o.isTag(l[p])){if(l[p]===v)break;if(i(l[p]))return!0}return!1}},adjacent:function(i,a,s){var o=s.adapter;return function(v){for(var l=o.getSiblings(v),p,y=0;y<l.length;y++)if(o.isTag(l[y])){if(l[y]===v)break;p=l[y]}return!!p&&i(p)}},universal:function(i){return i}}},function(d,r,t){var e=t(273).falseFunc,n=/[-[\]{}()*+?.,\\^$|#\s]/g,i={__proto__:null,equals:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;return s.ignoreCase?(v=v.toLowerCase(),function(y){var O=l.getAttributeValue(y,f);return O!=null&&O.toLowerCase()===v&&a(y)}):function(y){return l.getAttributeValue(y,f)===v&&a(y)}},hyphen:function(a,s,o){var f=s.name,v=s.value,l=v.length,p=o.adapter;return s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&(x.length===l||x.charAt(l)==="-")&&x.substr(0,l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l)===v&&(x.length===l||x.charAt(l)==="-")&&a(O)}},element:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;if(/\s/.test(v))return e;v=v.replace(n,"\\$&");var p="(?:^|\\s)"+v+"(?:$|\\s)",y=s.ignoreCase?"i":"",O=new RegExp(p,y);return function(m){var T=l.getAttributeValue(m,f);return T!=null&&O.test(T)&&a(m)}},exists:function(a,s,o){var f=s.name,v=o.adapter;return function(p){return v.hasAttrib(p,f)&&a(p)}},start:function(a,s,o){var f=s.name,v=s.value,l=v.length,p=o.adapter;return l===0?e:s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l)===v&&a(O)}},end:function(a,s,o){var f=s.name,v=s.value,l=-v.length,p=o.adapter;return l===0?e:s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(l)===v&&a(O)}},any:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;if(v==="")return e;if(s.ignoreCase){var p=new RegExp(v.replace(n,"\\$&"),"i");return function(O){var x=l.getAttributeValue(O,f);return x!=null&&p.test(x)&&a(O)}}return function(O){var x=l.getAttributeValue(O,f);return x!=null&&x.indexOf(v)>=0&&a(O)}},not:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;return v===""?function(y){return!!l.getAttributeValue(y,f)&&a(y)}:s.ignoreCase?(v=v.toLowerCase(),function(y){var O=l.getAttributeValue(y,f);return O!=null&&O.toLowerCase()!==v&&a(y)}):function(y){return l.getAttributeValue(y,f)!==v&&a(y)}}};d.exports={compile:function(a,s,o){if(o&&o.strict&&(s.ignoreCase||s.action==="not"))throw new Error("Unsupported attribute selector");return i[s.action](a,s,o)},rules:i}},function(d,r,t){var e=t(283),n=t(273),i=t(281),a=n.trueFunc,s=n.falseFunc,o=i.rules.equals;function f(T,c){var h={name:T,value:c};return function(g,M,A){return o(g,h,A)}}function v(T,c){return function(h){return!!c.getParent(h)&&T(h)}}var l={contains:function(T,c,h){var u=h.adapter;return function(M){return T(M)&&u.getText(M).indexOf(c)>=0}},icontains:function(T,c,h){var u=c.toLowerCase(),g=h.adapter;return function(A){return T(A)&&g.getText(A).toLowerCase().indexOf(u)>=0}},"nth-child":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=0;b<I.length;b++)if(g.isTag(I[b])){if(I[b]===A)break;E++}return u(E)&&T(A)}},"nth-last-child":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=I.length-1;E>=0;E--)if(g.isTag(I[E])){if(I[E]===A)break;b++}return u(b)&&T(A)}},"nth-of-type":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=0;E<I.length;E++)if(g.isTag(I[E])){if(I[E]===A)break;g.getName(I[E])===g.getName(A)&&b++}return u(b)&&T(A)}},"nth-last-of-type":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=I.length-1;E>=0;E--)if(g.isTag(I[E])){if(I[E]===A)break;g.getName(I[E])===g.getName(A)&&b++}return u(b)&&T(A)}},root:function(T,c,h){var u=h.adapter;return function(g){return!u.getParent(g)&&T(g)}},scope:function(T,c,h,u){var g=h.adapter;if(!u||u.length===0)return l.root(T,c,h);function M(A,I){return typeof g.equals=="function"?g.equals(A,I):A===I}return u.length===1?function(A){return M(u[0],A)&&T(A)}:function(A){return u.indexOf(A)>=0&&T(A)}},checkbox:f("type","checkbox"),file:f("type","file"),password:f("type","password"),radio:f("type","radio"),reset:f("type","reset"),image:f("type","image"),submit:f("type","submit"),hover:function(T,c,h){var u=h.adapter;return typeof u.isHovered=="function"?function(M){return T(M)&&u.isHovered(M)}:s},visited:function(T,c,h){var u=h.adapter;return typeof u.isVisited=="function"?function(M){return T(M)&&u.isVisited(M)}:s},active:function(T,c,h){var u=h.adapter;return typeof u.isActive=="function"?function(M){return T(M)&&u.isActive(M)}:s}};function p(T,c){for(var h=0;T&&h<T.length;h++)if(c.isTag(T[h]))return T[h]}var y={empty:function(T,c){return!c.getChildren(T).some(function(h){return c.isTag(h)||h.type==="text"})},"first-child":function(T,c){return p(c.getSiblings(T),c)===T},"last-child":function(T,c){for(var h=c.getSiblings(T),u=h.length-1;u>=0;u--){if(h[u]===T)return!0;if(c.isTag(h[u]))break}return!1},"first-of-type":function(T,c){for(var h=c.getSiblings(T),u=0;u<h.length;u++)if(c.isTag(h[u])){if(h[u]===T)return!0;if(c.getName(h[u])===c.getName(T))break}return!1},"last-of-type":function(T,c){for(var h=c.getSiblings(T),u=h.length-1;u>=0;u--)if(c.isTag(h[u])){if(h[u]===T)return!0;if(c.getName(h[u])===c.getName(T))break}return!1},"only-of-type":function(T,c){for(var h=c.getSiblings(T),u=0,g=h.length;u<g;u++)if(c.isTag(h[u])){if(h[u]===T)continue;if(c.getName(h[u])===c.getName(T))return!1}return!0},"only-child":function(T,c){for(var h=c.getSiblings(T),u=0;u<h.length;u++)if(c.isTag(h[u])&&h[u]!==T)return!1;return!0},link:function(T,c){return c.hasAttrib(T,"href")},selected:function(T,c){if(c.hasAttrib(T,"selected"))return!0;if(c.getName(T)!=="option")return!1;var h=c.getParent(T);if(!h||c.getName(h)!=="select"||c.hasAttrib(h,"multiple"))return!1;for(var u=c.getChildren(h),g=!1,M=0;M<u.length;M++)if(c.isTag(u[M]))if(u[M]===T)g=!0;else if(g){if(c.hasAttrib(u[M],"selected"))return!1}else return!1;return g},disabled:function(T,c){return c.hasAttrib(T,"disabled")},enabled:function(T,c){return!c.hasAttrib(T,"disabled")},checked:function(T,c){return c.hasAttrib(T,"checked")||y.selected(T,c)},required:function(T,c){return c.hasAttrib(T,"required")},optional:function(T,c){return!c.hasAttrib(T,"required")},parent:function(T,c){return!y.empty(T,c)},header:O(["h1","h2","h3","h4","h5","h6"]),button:function(T,c){var h=c.getName(T);return h==="button"||h==="input"&&c.getAttributeValue(T,"type")==="button"},input:O(["input","textarea","select","button"]),text:function(T,c){var h;return c.getName(T)==="input"&&(!(h=c.getAttributeValue(T,"type"))||h.toLowerCase()==="text")}};function O(T){if(typeof Set<"u"){var c=new Set(T);return function(h,u){return c.has(u.getName(h))}}return function(h,u){return T.indexOf(u.getName(h))>=0}}function x(T,c,h){if(h===null){if(T.length>2&&c!=="scope")throw new Error("pseudo-selector :"+c+" requires an argument")}else if(T.length===2)throw new Error("pseudo-selector :"+c+" doesn't have any arguments")}var m=/^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/;d.exports={compile:function(T,c,h,u){var g=c.name,M=c.data,A=h.adapter;if(h&&h.strict&&!m.test(g))throw new Error(":"+g+" isn't part of CSS3");if(typeof l[g]=="function")return l[g](T,M,h,u);if(typeof y[g]=="function"){var I=y[g];return x(I,g,M),I===s?I:T===a?function(E){return I(E,A,M)}:function(E){return I(E,A,M)&&T(E)}}else throw new Error("unmatched pseudo-class :"+g)},filters:l,pseudos:y}},function(d,r,t){var e=t(284),n=t(285);d.exports=function(a){return n(e(a))},d.exports.parse=e,d.exports.compile=n},function(d,r){d.exports=e;var t=/^([+\-]?\d*n)?\s*(?:([+\-]?)\s*(\d+))?$/;function e(n){if(n=n.trim().toLowerCase(),n==="even")return[2,0];if(n==="odd")return[2,1];var i=n.match(t);if(!i)throw new SyntaxError("n-th rule couldn't be parsed ('"+n+"')");var a;return i[1]?(a=parseInt(i[1],10),isNaN(a)&&(i[1].charAt(0)==="-"?a=-1:a=1)):a=0,[a,i[3]?parseInt((i[2]||"")+i[3],10):0]}},function(d,r,t){d.exports=a;var e=t(273),n=e.trueFunc,i=e.falseFunc;function a(s){var o=s[0],f=s[1]-1;if(f<0&&o<=0)return i;if(o===-1)return function(l){return l<=f};if(o===0)return function(l){return l===f};if(o===1)return f<0?n:function(l){return l>=f};var v=f%o;return v<0&&(v+=o),o>1?function(l){return l>=f&&l%o===v}:(o*=-1,function(l){return l<=f&&l%o===v})}},function(d,r,t){t.r(r),t.d(r,"default",function(){return M});var e=t(12),n=t(74),i=t(1),a=t(68),s=t(250),o=t(213),f=t(218);t(1).glMatrix.setMatrixArrayType(Array);function v(A,I){if(A==null)return{};var b=l(A,I),E,L;if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(A);for(L=0;L<D.length;L++)E=D[L],!(I.indexOf(E)>=0)&&Object.prototype.propertyIsEnumerable.call(A,E)&&(b[E]=A[E])}return b}function l(A,I){if(A==null)return{};var b={},E=Object.keys(A),L,D;for(D=0;D<E.length;D++)L=E[D],!(I.indexOf(L)>=0)&&(b[L]=A[L]);return b}const p={antialias:!0,autoRender:!0,alpha:!0},y=Symbol("autoRender"),O=Symbol("renderer"),x=Symbol("timeline"),m=Symbol("prepareRender"),T=Symbol("tickRender"),c=Symbol("pass"),h=Symbol("fbo"),u=Symbol("tickers"),g=Symbol("layerTransformInvert");class M extends s.default{constructor(I={}){if(super(),!I.canvas){const{width:D,height:R}=this.getResolution(),C=e.ENV.createCanvas(D,R,{offscreen:!!I.offscreen,id:I.id,extra:I.extra});C.style&&(C.style.position="absolute"),C.dataset&&(C.dataset.layerId=I.id),C.contextType&&(I.contextType=C.contextType),I.canvas=C}const b=I.canvas,E=Object.assign({},p,I);this[y]=E.autoRender,delete I.autoRender;const L=E.Renderer||e.Renderer;this[O]=new L(b,E),this.options=I,this.id=I.id,this[c]=[],this.setResolution(b),this.canvas=b,this[x]=new n.Timeline,this.__mouseCapturedTarget=null,this[g]=null}get autoRender(){return this[y]}get displayRatio(){return this.parent&&this.parent.options?this.parent.options.displayRatio:1}get height(){const{height:I}=this.getResolution();return I/this.displayRatio}get gl(){return this.renderer.glRenderer?this.renderer.glRenderer.gl:null}get layer(){return this}get offscreen(){return!!this.options.offscreen||this.canvas._offscreen}get pass(){return this[c]}get prepareRender(){return this[m]?this[m]:Promise.resolve()}get renderer(){return this[O]}get renderOffset(){if(this.parent&&this.parent.options){const{left:I,top:b}=this.parent.options;return[I,b]}return[this.options.left|0,this.options.top|0]}get timeline(){return this[x]}get width(){const{width:I}=this.getResolution();return I/this.displayRatio}get localMatrix(){const{x:I,y:b}=this.attributes;return[1,0,0,1,I,b]}get layerTransformInvert(){if(this[g])return this[g];const I=this.transformMatrix;return I[0]===1&&I[1]===0&&I[2]===0&&I[3]===1&&I[4]===0&&I[5]===0?null:(this[g]=i.mat2d.invert(Array.of(0,0,0,0,0,0),I),this[g])}forceContextLoss(){const I=this.renderer.glRenderer;if(I){const b=I.getExtension("WEBGL_lose_context");if(b)return b.loseContext(),!0}return!1}addPass({vertex:I,fragment:b,options:E,uniforms:L}={}){if(this.renderer.glRenderer){const{width:D,height:R}=this.getResolution(),C=this.renderer.createPassProgram({vertex:I,fragment:b,options:E}),W=new e.Figure2D;W.rect(0,0,D/this.displayRatio,R/this.displayRatio);const z=new e.Mesh2D(W);return z.setUniforms(L),z.setProgram(C),this[c].push(z),this.forceUpdate(),z}return null}deleteTexture(I){return Object(f.deleteTexture)(I,this.renderer)}dispatchPointerEvent(I){const b=I.type;if(b==="mousedown"||b==="mouseup"||b==="mousemove"){const C=this.__mouseCapturedTarget;if(C){if(C.layer===this)return C.dispatchEvent(I),!0;this.__mouseCapturedTarget=null}}let E,L;const D=this.layerTransformInvert;if(D){E=I.x,L=I.y;const C=D,W=C[0]*E+C[2]*L+C[4],z=C[1]*E+C[3]*L+C[5];delete I.x,delete I.y,delete I.layerX,delete I.layerY,Object.defineProperties(I,{layerX:{value:W,configurable:!0},layerY:{value:z,configurable:!0},x:{value:W,configurable:!0},y:{value:z,configurable:!0}})}const R=super.dispatchPointerEvent(I);return D&&Object.defineProperties(I,{layerX:{value:E,configurable:!0},layerY:{value:L,configurable:!0},x:{value:E,configurable:!0},y:{value:L,configurable:!0}}),R}forceUpdate(){if(!this[m])if(this.parent&&this.parent.hasOffscreenCanvas){this.parent.forceUpdate();let I=null;const b=new Promise(E=>{I=E});b._resolve=I,this[m]=b}else{let I=null,b=null;const E=new Promise(L=>{I=L,this[y]&&(b=Object(a.requestAnimationFrame)(()=>{delete E._requestID,this.render()}))});E._resolve=I,E._requestID=b,this[m]=E}}getFBO(){const I=this.renderer.glRenderer,{width:b,height:E}=this.getResolution();return I&&(!this[h]||this[h].width!==b||this[h].height!==E)?(this[h]={width:b,height:E,target:I.createFBO(),buffer:I.createFBO(),swap(){[this.target,this.buffer]=[this.buffer,this.target]}},this[h]):this[h]?this[h]:null}updateGlobalTransform(){if(this.layerTransformInvert){const I=this.renderer,b=I.__globalTransformMatrix||I.globalTransformMatrix;I.__globalTransformMatrix=b;const E=i.mat2d.fromValues(1,0,0,1,0,0);I.setGlobalTransform(...i.mat2d.multiply(E,b,this.transformMatrix))}}onPropertyChange(I,b,E){if(super.onPropertyChange(I,b,E),I==="zIndex"&&(this.canvas.style.zIndex=b),I==="transform"||I==="translate"||I==="rotate"||I==="scale"||I==="skew"){const L=this[g];if(this[g]=null,this.updateGlobalTransform(),L&&!this.layerTransformInvert){const D=this.renderer,R=D.__globalTransformMatrix||D.globalTransformMatrix;D.setGlobalTransform(...R)}}}_prepareRenderFinished(){this[m]&&(this[m]._requestID&&Object(a.cancelAnimationFrame)(this[m]._requestID),this[m]._resolve(),delete this[m])}render({clear:I=!0}={}){const b=this[c].length?this.getFBO():null;b&&this.renderer.glRenderer.bindFBO(b.target),I&&this[O].clear();const E=this.draw();if(E&&E.length&&(this.renderer.drawMeshes(E),this.canvas.draw&&this.canvas.draw()),b){const L=this.renderer.glRenderer,D=this[c].length,{width:R,height:C}=this.getResolution(),W=[0,0,R/this.displayRatio,C/this.displayRatio];this[c].forEach((z,H)=>{z.blend=!0,z.setTexture(b.target.texture,{rect:W}),H===D-1?L.bindFBO(null):(b.swap(),L.bindFBO(b.target)),this[O].clear(),this.renderer.drawMeshes([z])})}this._prepareRenderFinished()}setResolution({width:I,height:b}){const E=this.renderer,L=E.__globalTransformMatrix||E.globalTransformMatrix,D=L[4],R=L[5],C=L[0],{width:W,height:z}=this.getResolution();(W!==I||z!==b)&&(super.setResolution({width:I,height:b}),this.canvas&&(this.canvas.width=I,this.canvas.height=b,E.updateResolution&&E.updateResolution()),this.attributes.size=[I,b],this[c].length&&this[c].forEach(j=>{const G=new e.Figure2D;G.rect(0,0,I/this.displayRatio,b/this.displayRatio),j.contours=G.contours}));const[H,X]=this.renderOffset,Z=this.displayRatio;(D!==H||R!==X||C!==Z)&&(E.setGlobalTransform(Z,0,0,Z,H,X),E.__globalTransformMatrix=null,this[g]=null,this.updateGlobalTransform(),this.forceUpdate())}tick(I=null,b={}){let{duration:E=1/0}=b,L=v(b,["duration"]);const D=this.timeline.fork(L),R=this;this[u]=this[u]||[],this[u].push({handler:I,duration:E});const C=()=>{let W=null,z=null;const H=()=>{const X=this[u].map(({handler:Z,duration:j})=>{const G=Math.min(1,D.currentTime/j);return{value:Z?Z(D.currentTime,G):null,p:G}});R[T]||(R[T]=Promise.resolve().then(()=>{R[y]&&R.render(),delete R[T];for(let Z=X.length-1;Z>=0;Z--){const{value:j,p:G}=X[Z];(j===!1||G>=1)&&this[u].splice(Z,1)}this[u].length>0&&C()}))};if(this[m]&&this[m]._type!=="ticker"&&(Object(a.cancelAnimationFrame)(this[m]._requestID),delete this[m]),!this[m]){const X=new Promise(Z=>{W=Z,z=Object(a.requestAnimationFrame)(H)});X._resolve=W,X._requestID=z,X._type="ticker",this[m]=X}};C()}toGlobalPos(I,b){if(this.layerTransformInvert){const W=this.transformMatrix;I=W[0]*I+W[2]*b+W[4],b=W[1]*I+W[3]*b+W[5]}const{width:E,height:L}=this.getResolution(),D=this.renderOffset,R=[this.canvas.clientWidth,this.canvas.clientHeight];I=I*R[0]/E+D[0],b=b*R[1]/L+D[1];const C=this.displayRatio;return I*=C,b*=C,[I,b]}toLocalPos(I,b){const{width:E,height:L}=this.getResolution(),D=this.renderOffset,R=[this.canvas.clientWidth,this.canvas.clientHeight];I=I*E/R[0]-D[0],b=b*L/R[1]-D[1];const C=this.displayRatio;I/=C,b/=C;const W=this.layerTransformInvert;return W&&(I=W[0]*I+W[2]*b+W[4],b=W[1]*I+W[3]*b+W[5]),[I,b]}}o.default.registerNode(M,"layer")},function(d,r,t){t.r(r),t.d(r,"default",function(){return m});var e=t(224),n=t(288),i=t(213),a=t(252),s=t(72);t(1).glMatrix.setMatrixArrayType(Array);function o(T,c){if(T==null)return{};var h=f(T,c),u,g;if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(T);for(g=0;g<M.length;g++)u=M[g],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(T,u)&&(h[u]=T[u])}return h}function f(T,c){if(T==null)return{};var h={},u=Object.keys(T),g,M;for(M=0;M<u.length;M++)g=u[M],!(c.indexOf(g)>=0)&&(h[g]=T[g]);return h}function v(T,c,h){return c in T?Object.defineProperty(T,c,{value:h,enumerable:!0,configurable:!0,writable:!0}):T[c]=h,T}const l="http://www.w3.org/2000/svg",p=Symbol.for("spritejs_setAttribute"),y=Symbol("root"),O=Symbol("task");function x(T,c=!0){const h=T[y];if(h&&h.children[0]){const u=T.svg,g=T.layer?T.layer.displayRatio:1;if(!u.hasAttribute("data-original-width")){let I=u.getAttribute("width");I=I?Object(s.sizeToPixel)(I):300;let b=u.getAttribute("height");b=b?Object(s.sizeToPixel)(b):150,u.hasAttribute("viewBox")||u.setAttribute("viewBox",`0 0 ${Math.round(I)} ${Math.round(b)}`),u.setAttribute("data-original-width",I),u.setAttribute("data-original-height",b)}let M=T.attributes.width||Number(u.getAttribute("data-original-width")),A=T.attributes.height||Number(u.getAttribute("data-original-height"));if(M*=g,A*=g,c&&T.attributes.flexible){const I=T.attributes.scale[0];if(M*=I,A*=I,u.setAttribute("width",M),u.setAttribute("height",A),M&&A&&T.textureImage){const b=T.textureImage.width,E=T.textureImage.height,L=T.clientSize;T.attributes.textureRect=[0,0,Math.round(L[0]*b/M),Math.round(L[1]*E/A)]}}else T[O]||(u.setAttribute("width",M),u.setAttribute("height",A),T[O]=Promise.resolve().then(()=>{delete T[O];const I=h.innerHTML,b=new Blob([I],{type:"image/svg+xml"}),E=URL.createObjectURL(b),L=new Image;L.onload=function(){L.width&&L.height?(T.attributes[p]("texture",L),T.attributes.flexible&&(T.attributes.textureRect=null)):T.attributes[p]("texture",null)},L.src=E}))}}class m extends e.default{constructor(c={}){typeof c=="string"&&(c={svgText:c});let{svgText:h}=c,u=o(c,["svgText"]);if(super(u),this[y]=document.createElement("div"),h){this[y].innerHTML=h;const g=this[y].children[0];g?g.setAttribute("xmlns",l):(fetch(h).then(M=>M.text()).then(M=>{this[y].innerHTML=M,(!this.observer||this.attributes.flexible)&&x(this)}),h=null)}if(!h){const g=document.createElementNS(l,"svg");g.setAttribute("xmlns",l),this[y].appendChild(g)}if(typeof MutationObserver=="function"){const g=new MutationObserver(M=>{x(this,!1)});g.observe(this[y],{attributes:!0,subtree:!0,characterData:!0,childList:!0}),this.observer=g}}get children(){return[this.svg]}get childNodes(){return[this.svg]}get svg(){return this[y]?this[y].children[0]:null}setResolution({width:c,height:h}){super.setResolution({width:c,height:h}),x(this)}dispatchPointerEvent(c){const h=super.dispatchPointerEvent(c);if(h&&this.attributes.passEvents&&typeof MouseEvent=="function"){const{x:u,y:g}=c;let[M,A]=this.getOffsetPosition(u,g);const I=c.originalEvent,b=this.attributes.anchor,E=this.clientSize;M=(M+b[0]*E[0])/2,A=(A+b[1]*E[1])/2;const L=c.type;if(L===I.type){let D=null;if(I instanceof MouseEvent)D=new MouseEvent(L,{screenX:M,screenY:A,clientX:M,clientY:A,bubbles:I.bubbles,button:I.button,buttons:I.buttons,cancelBubble:I.cancelBubble,cancelable:I.cancelable,currentTarget:I.currentTarget,fromElement:I.fromElement,relatedTarget:I.relatedTarget,returnValue:I.returnValue,srcElement:I.srcElement,target:I.target,toElement:I.toElement,which:I.witch});else if(I instanceof TouchEvent){let R=null;const C=I.changedTouches||[I];for(let W=0;W<C.length;W++){const z=C[W];if(c.identifier===z.identifier){R=z;break}}if(R){const W=new Touch({identifier:R.identifier,target:R.target,clientX:M,clientY:A,screenX:M,screenY:A,pageX:M,pageY:A,radiusX:R.radiusX,radiusY:R.radiusY,rotationAngle:R.rotationAngle,force:R.force});D=new TouchEvent(L,{cancelable:I.cancelable,bubbles:I.bubbles,composed:I.composed,touches:[W],targetTouches:[W],changedTouches:[W]})}}else D=I;D&&this.svg.dispatchEvent(D)}}return h}getElementById(c){return Object(a.querySelector)(`#${c}`,this)}getElementsByClassName(c){return Object(a.querySelectorAll)(`.${c}`,this)}getElementsByName(c){return Object(a.querySelectorAll)(`[name="${c}"]`,this)}getElementsByTagName(c){return Object(a.querySelectorAll)(c,this)}querySelector(c){return Object(a.querySelector)(c,this)}querySelectorAll(c){return Object(a.querySelectorAll)(c,this)}onPropertyChange(c,h,u){super.onPropertyChange(c,h,u),c==="flexible"&&x(this),this.attributes.flexible&&(c==="width"||c==="height"||c==="scale"||c==="transform")&&x(this)}}v(m,"Attr",n.default),i.default.registerNode(m,"spritesvg")},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(225);t(1).glMatrix.setMatrixArrayType(Array);const n=Symbol.for("spritejs_getAttribute"),i=Symbol.for("spritejs_setAttribute"),a=Symbol.for("spritejs_setAttributeDefault");class s extends e.default{constructor(f){super(f),this[a]({passEvents:!1,flexible:!1})}get texture(){return this[n]("texture")}set texture(f){}get passEvents(){return this[n]("passEvents")}set passEvents(f){return this[i]("passEvents",f)}get flexible(){return this[n]("flexible")}set flexible(f){return this[i]("flexible",f)}}},function(d,r,t){t.r(r);var e=t(12);t(1).glMatrix.setMatrixArrayType(Array);function n(f,v){var l=Object.keys(f);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(f);v&&(p=p.filter(function(y){return Object.getOwnPropertyDescriptor(f,y).enumerable})),l.push.apply(l,p)}return l}function i(f){for(var v=1;v<arguments.length;v++){var l=arguments[v]!=null?arguments[v]:{};v%2?n(Object(l),!0).forEach(function(p){a(f,p,l[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(l)):n(Object(l)).forEach(function(p){Object.defineProperty(f,p,Object.getOwnPropertyDescriptor(l,p))})}return f}function a(f,v,l){return v in f?Object.defineProperty(f,v,{value:l,enumerable:!0,configurable:!0,writable:!0}):f[v]=l,f}const s=Symbol("inited");let o=null;typeof Worker=="function"&&(o=class extends Worker{constructor(f){if(f.worker===!0&&(f.worker=`./${f.id}.worker.js`),super(f.worker),this.options=f,!f.canvas){const{width:v,height:l}=this.getResolution(),p=e.ENV.createCanvas(v,l,{offscreen:!1});p.style&&(p.style.position="absolute"),p.dataset&&(p.dataset.layerId=f.id),f.canvas=p}this.canvas=f.canvas}get id(){return this.options.id}setResolution({width:f,height:v}){if(this[s])this.postMessage({type:"resolution_change",width:f,height:v});else{this.canvas.width=f,this.canvas.height=v;const l=this.options,p=l.canvas.transferControlToOffscreen(),y=i({},l);delete y.container,y.canvas=p,this.postMessage({type:"create",options:y},[p]),this[s]=!0}}getResolution(){if(this.canvas){const{width:f,height:v}=this.canvas;return{width:f,height:v}}return{width:300,height:150}}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}connect(f,v){Object.defineProperty(this,"parent",{value:f,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:v,writable:!1,configurable:!0})}disconnect(){delete this.parent,delete this.zOrder}dispatchPointerEvent(f){this.postMessage({type:"event",event:{cancelBubble:f.cancelBubble,bubbles:f.bubbles,detail:f.detail,identifier:f.identifier,layerX:f.layerX,layerY:f.layerY,originalX:f.originalX,originalY:f.originalY,type:f.type,x:f.x,y:f.y}})}}),r.default=o},function(d,r,t){t.r(r),(function(e){t.d(r,"default",function(){return M});var n=t(12),i=t(68),a=t(70),s=t(286),o=t(289),f=t(250),v=t(291),l=t(214),p=t(218),y=t(213);t(1).glMatrix.setMatrixArrayType(Array);const O=Symbol("enteredTargets");function x(A){return A.id=A.id||`_layer${Math.random().toString(36).slice(2,12)}`,A.dataset||(A.dataset={}),A.dataset.layerId=A.id,A.connect=(I,b)=>{A.parent=I,Object.defineProperty(A,"zOrder",{value:b,writable:!1,configurable:!0})},A.disconnect=I=>{delete A.zOrder},A.canvas=A,A.getResolution=()=>({width:0,height:0}),A.setResolution=()=>!1,A.options={handleEvent:!1},A}function m(A,I){const b=A.children;let E=null;for(let L=0;L<b.length;L++){const D=b[L];if((I===D||E!=null)&&(E=D),E&&E!==I&&!E.offscreen)return E.canvas}return null}function T(A,I){const[b,E]=A.renderOffset,{width:L,height:D}=A.getResolution(),R=A.displayRatio;A.renderer.drawImage(I.canvas,-b/R,-E/R,L/R,D/R)}const c={};function h(A){const I=["mousedown","mouseup","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel","click","dblclick","longpress","tap","contextmenu"],b=A.container;b.addEventListener("mouseleave",E=>{const L=A[O];if(L.size){const D=new l.default("mouseleave");D.setOriginalEvent(E),[...L].forEach(R=>{R.dispatchEvent(D)}),A[O].clear()}},{passive:!0}),I.forEach(E=>{b.addEventListener(E,L=>{const{left:D,top:R,displayRatio:C}=A.options,W=A.orderedChildren;Object(v.default)(L,{offsetLeft:D,offsetTop:R,displayRatio:C}).forEach(H=>{const X=H.identifier;if(H.type==="touchmove"||H.type==="touchend"){const j=c[X];j&&j.dispatchEvent(H),H.type==="touchend"&&delete c[X]}else{for(let j=W.length-1;j>=0;j--){const G=W[j];if(G.options.handleEvent!==!1){if(G.dispatchPointerEvent(H)&&H.target!==G)break;H.cancelBubble=!1}}if(H.target===W[0])for(let j=W.length-1;j>=0;j--){const G=W[j];if(G.options.handleEvent!==!1){H.target=G;break}}}const Z=H.target;if(H.type==="touchstart"&&(c[X]=H.target),H.type==="mousemove"){const j=A[O];let G;if(Z){const et=Z.ancestors||[];G=new Set([Z,...et])}else G=new Set;const Q=Object.entries(L);if(!j.has(Z)&&Z){const et=new l.default("mouseenter");et.setOriginalEvent(L),Q.forEach(([q,pt])=>{et[q]=pt}),j.add(Z),Z.dispatchEvent(et);const at=Z.ancestors;at&&at.forEach(q=>{q instanceof a.default&&!j.has(q)&&(j.add(q),q.dispatchEvent(et))})}const tt=new l.default("mouseleave");tt.setOriginalEvent(L),Q.forEach(([et,at])=>{tt[et]=at}),[...j].forEach(et=>{G.has(et)||(j.delete(et),et.dispatchEvent(tt))})}})},{passive:E!=="contextmenu"})})}function u(A,I){if(I&&I.style){let{width:b,height:E,mode:L,container:D}=A;const{clientWidth:R,clientHeight:C}=D;b=b||R,E=E||C,L==="static"?(I.style.width=`${b}px`,I.style.height=`${E}px`):(I.style.top="0",I.style.left="0",I.style.width=`${R}px`,I.style.height=`${C}px`,I.style.transform="",I.style.webkitTransform="")}}const g=Symbol("offscreenLayerCount");class M extends f.default{constructor(I={}){if(super(),!I.container)if(typeof n.ENV.Container=="function")I.container=new n.ENV.Container(I.width||300,I.height||150);else throw new Error("No container specified.");if(this.container=I.container,this.container.style&&(this.container.style.overflow||(this.container.style.overflow="hidden"),this.container.style.position||(this.container.style.position="relative")),this.options=I,I.displayRatio=I.displayRatio||1,I.mode=I.mode||"scale",I.left=0,I.top=0,I.autoResize=I.autoResize!==!1,I.autoResize){let b;if(typeof globalThis<"u"?b=globalThis:b=typeof window<"u"?window:e,b.addEventListener){const E=this;b.addEventListener("resize",function L(){typeof document<"u"&&document.contains(E.container)?E.resize():b.removeEventListener("resize",L)})}}this[O]=new Set,this.setResolution(I),h(this),this[g]=0}get hasOffscreenCanvas(){return this[g]>0}set displayRatio(I){this.options.displayRatio!==I&&(this.options.displayRatio=I,this.resize())}get displayRatio(){return this.options.displayRatio}set height(I){this.options.height!==I&&(this.options.height=I,this.resize())}get height(){return this.options.height}set mode(I){this.options.mode!==I&&(this.options.mode=I,this.resize())}get mode(){return this.options.mode}set width(I){this.options.width!==I&&(this.options.width=I,this.resize())}get width(){return this.options.width}appendChild(I){!(I instanceof s.default)&&!(I instanceof o.default)&&x(I);const b=super.appendChild(I),E=I.canvas;return I.offscreen?this[g]++:this.container.appendChild(E),u(this.options,E),I.setResolution(this.getResolution()),b}forceUpdate(){this.hasOffscreenCanvas&&!this._requestID&&(this._requestID=Object(i.requestAnimationFrame)(()=>{delete this._requestID,this.render()}))}insertBefore(I,b){!(I instanceof s.default)&&!(I instanceof o.default)&&x(I);const E=super.insertBefore(I,b),L=I.canvas;if(!I.offscreen){const D=m(this,I);this.container.insertBefore(L,D)}return u(this.options,L),I.setResolution(this.getResolution()),E}layer(I="default",b={}){b=Object.assign({},this.options,b),b.id=I;const E=this.orderedChildren;for(let R=0;R<E.length;R++)if(E[R].id===I)return E[R];const L=b.worker;let D;return L?D=new o.default(b):D=new s.default(b),this.appendChild(D),D}async preload(...I){const b=[],E=[],L=[];for(let D=0;D<I.length;D++){const R=I[D];let C;if(typeof R=="string")C=Object(p.loadTexture)(R);else if(Array.isArray(R))C=Object(p.loadFrames)(...R);else{const{id:W,src:z}=R;C=Object(p.loadTexture)(z,W)}C instanceof Promise||(C=Promise.resolve(C)),E.push(C.then(W=>{b.push(W),L[D]=W;const z=new l.default({type:"preload",detail:{current:W,loaded:b,resources:I}});this.dispatchEvent(z)}))}return await Promise.all(E),L}removeChild(I){const b=super.removeChild(I);if(b){I._prepareRenderFinished&&I._prepareRenderFinished();const E=I.canvas;E&&E.remove&&E.remove(),I.offscreen&&this[g]--}return b}render(){const I=this.orderedChildren;let b=null;const E=[];for(let L=0;L<I.length;L++){const D=I[L],R=E.length>0;if(D instanceof s.default&&!D.offscreen)if(!D.autoRender)R&&(console.warn("Some offscreen canvas will not be rendered."),E.length=0);else if(b=D,R){D.renderer.clear();for(let C=0;C<E.length;C++){const W=E[C];W.render(),T(D,W)}E.length=0,D.render({clear:!1})}else D.prepareRender&&D.render();else D.offscreen?b?(D.prepareRender&&D.render(),T(b,D)):E.push(D):D instanceof o.default&&R&&(console.warn("Some offscreen canvas will not be rendered."),E.length=0)}}replaceChild(I,b){const E=super.replaceChild(I,b);b.canvas.remove&&b.canvas.remove(),b.offscreen&&this[g]--;const L=I.canvas;if(!I.offscreen){const D=m(this,I);this.container.insertBefore(L,D)}return u(this.options,L),I.setResolution(this.getResolution()),E}resize(){const I=this.options;this.children.forEach(b=>{u(I,b.canvas)}),this.setResolution(I),this.dispatchEvent({type:"resize"})}setResolution({width:I,height:b}={}){const E=this.container,{clientWidth:L,clientHeight:D}=E;(I==null||b==null)&&(I=I??L,b=b??D);const{mode:R,displayRatio:C}=this.options;if(I*=C,b*=C,this.options.left=0,this.options.top=0,R==="stickyHeight"||R==="stickyLeft"||R==="stickyRight"){const W=I;I=L*b/D,R==="stickyHeight"&&(this.options.left=.5*(I-W)),R==="stickyRight"&&(this.options.left=I-W)}else if(R==="stickyWidth"||R==="stickyTop"||R==="stickyBottom"){const W=b;b=D*I/L,R==="stickyWidth"&&(this.options.top=.5*(b-W)),R==="stickyBottom"&&(this.options.top=b-W)}super.setResolution({width:I,height:b})}snapshot({offscreen:I=!1,layers:b}={}){const E=I?"snapshotOffScreenCanvas":"snapshotCanvas",{width:L,height:D}=this.getResolution();this[E]=this[E]||n.ENV.createCanvas(L,D,{offscreen:I});const R=this[E].getContext("2d");b=b||this.orderedChildren,this[E].width=L,this[E].height=D;for(let C=0;C<b.length;C++){const W=b[C];if(!W.options.ignoreSnapshot){W.render&&W.render();const z=W.canvas;z&&z!==W&&R.drawImage(z,0,0,L,D)}}return this[E]}}typeof document<"u"&&(M.prototype.layer3d=function(A,I={}){const b=I.url||"https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.min.js";return new Promise((E,L)=>{const D=document.createElement("script");D.async=!1,D.src=b,D.onload=()=>{try{E(this.layer3d(A,I))}catch(R){L(R)}},document.documentElement.appendChild(D)})}),y.default.registerNode(M,"scene")}).call(this,t(22))},function(d,r,t){t.r(r),t.d(r,"default",function(){return n});var e=t(214);t(1).glMatrix.setMatrixArrayType(Array);function n(i,{offsetTop:a=0,offsetLeft:s=0,displayRatio:o=1}={}){let f,v;const l=[],{left:p,top:y,width:O,height:x}=i.target.getBoundingClientRect(),m=i.target.width,T=i.target.height,c=i.changedTouches||[i];for(let u=0;u<c.length;u++){const g=c[u],M=g.identifier,{clientX:A,clientY:I}=g;A!=null&&I!=null&&l.push({x:Math.round((A|0)-p),y:Math.round((I|0)-y),identifier:M})}l.length<=0&&l.push({x:f,y:v});const h=[];return l.forEach(u=>{u.x!=null&&u.y!=null&&(f=(u.x*m/O-s)/o,v=(u.y*T/x-a)/o);const g=new e.default(i);Object.defineProperties(g,{layerX:{value:f,configurable:!0},layerY:{value:v,configurable:!0},originalX:{value:u.x},originalY:{value:u.y},x:{value:f,configurable:!0},y:{value:v,configurable:!0},identifier:{value:u.identifier}}),h.push(g)}),h}}]);Dt.version,Dt.Arc,Dt.Block,Dt.Cloud,Dt.Color;const Gh=Dt.Ellipse;Dt.Gradient;const se=Dt.Group,Hh=Dt.Label;Dt.Layer,Dt.LayerWorker,Dt.Node,Dt.Parallel;const ge=Dt.Path,pe=Dt.Polyline,hr=Dt.Rect;Dt.Regular,Dt.Ring;const Kh=Dt.Scene,Vh=Dt.Sprite;Dt.SpriteSvg,Dt.Star,Dt.Triangle,Dt.helpers,Dt.createElement,Dt.isSpriteNode,Dt.registerNode,Dt.requestAnimationFrame,Dt.cancelAnimationFrame,Dt.ENV;function Oe(d,r=!0){const t=d.length;if(t<2)return"";let e=d[0],n=d[1];if(t===2)return`M${Te(e)}L${Te(n)}`;let i="";for(let a=2,s=t-1;a<s;a++)e=d[a],n=d[a+1],i+=Me(e,n);return r?`M${Me(d[0],d[1])}Q${Te(d[1])}${Me(d[1],d[2])}T${i}${Me(d[t-1],d[0])}${Me(d[0],d[1])}Z`:`M${Te(d[0])}Q${Te(d[1])}${Me(d[1],d[2])}${d.length>3?"T":""}${i}L${Te(d[t-1])}`}var dr={exports:{}};dr.exports,function(d){var r=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function a(o,f){if(!i[o]){i[o]={};for(var v=0;v<o.length;v++)i[o][o.charAt(v)]=v}return i[o][f]}var s={compressToBase64:function(o){if(o==null)return"";var f=s._compress(o,6,function(v){return e.charAt(v)});switch(f.length%4){default:case 0:return f;case 1:return f+"===";case 2:return f+"==";case 3:return f+"="}},decompressFromBase64:function(o){return o==null?"":o==""?null:s._decompress(o.length,32,function(f){return a(e,o.charAt(f))})},compressToUTF16:function(o){return o==null?"":s._compress(o,15,function(f){return t(f+32)})+" "},decompressFromUTF16:function(o){return o==null?"":o==""?null:s._decompress(o.length,16384,function(f){return o.charCodeAt(f)-32})},compressToUint8Array:function(o){for(var f=s.compress(o),v=new Uint8Array(f.length*2),l=0,p=f.length;l<p;l++){var y=f.charCodeAt(l);v[l*2]=y>>>8,v[l*2+1]=y%256}return v},decompressFromUint8Array:function(o){if(o==null)return s.decompress(o);for(var f=new Array(o.length/2),v=0,l=f.length;v<l;v++)f[v]=o[v*2]*256+o[v*2+1];var p=[];return f.forEach(function(y){p.push(t(y))}),s.decompress(p.join(""))},compressToEncodedURIComponent:function(o){return o==null?"":s._compress(o,6,function(f){return n.charAt(f)})},decompressFromEncodedURIComponent:function(o){return o==null?"":o==""?null:(o=o.replace(/ /g,"+"),s._decompress(o.length,32,function(f){return a(n,o.charAt(f))}))},compress:function(o){return s._compress(o,16,function(f){return t(f)})},_compress:function(o,f,v){if(o==null)return"";var l,p,y={},O={},x="",m="",T="",c=2,h=3,u=2,g=[],M=0,A=0,I;for(I=0;I<o.length;I+=1)if(x=o.charAt(I),Object.prototype.hasOwnProperty.call(y,x)||(y[x]=h++,O[x]=!0),m=T+x,Object.prototype.hasOwnProperty.call(y,m))T=m;else{if(Object.prototype.hasOwnProperty.call(O,T)){if(T.charCodeAt(0)<256){for(l=0;l<u;l++)M=M<<1,A==f-1?(A=0,g.push(v(M)),M=0):A++;for(p=T.charCodeAt(0),l=0;l<8;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}else{for(p=1,l=0;l<u;l++)M=M<<1|p,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=0;for(p=T.charCodeAt(0),l=0;l<16;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}c--,c==0&&(c=Math.pow(2,u),u++),delete O[T]}else for(p=y[T],l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;c--,c==0&&(c=Math.pow(2,u),u++),y[m]=h++,T=String(x)}if(T!==""){if(Object.prototype.hasOwnProperty.call(O,T)){if(T.charCodeAt(0)<256){for(l=0;l<u;l++)M=M<<1,A==f-1?(A=0,g.push(v(M)),M=0):A++;for(p=T.charCodeAt(0),l=0;l<8;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}else{for(p=1,l=0;l<u;l++)M=M<<1|p,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=0;for(p=T.charCodeAt(0),l=0;l<16;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}c--,c==0&&(c=Math.pow(2,u),u++),delete O[T]}else for(p=y[T],l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;c--,c==0&&(c=Math.pow(2,u),u++)}for(p=2,l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;for(;;)if(M=M<<1,A==f-1){g.push(v(M));break}else A++;return g.join("")},decompress:function(o){return o==null?"":o==""?null:s._decompress(o.length,32768,function(f){return o.charCodeAt(f)})},_decompress:function(o,f,v){var l=[],p=4,y=4,O=3,x="",m=[],T,c,h,u,g,M,A,I={val:v(0),position:f,index:1};for(T=0;T<3;T+=1)l[T]=T;for(h=0,g=Math.pow(2,2),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;switch(h){case 0:for(h=0,g=Math.pow(2,8),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;A=t(h);break;case 1:for(h=0,g=Math.pow(2,16),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;A=t(h);break;case 2:return""}for(l[3]=A,c=A,m.push(A);;){if(I.index>o)return"";for(h=0,g=Math.pow(2,O),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;switch(A=h){case 0:for(h=0,g=Math.pow(2,8),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;l[y++]=t(h),A=y-1,p--;break;case 1:for(h=0,g=Math.pow(2,16),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;l[y++]=t(h),A=y-1,p--;break;case 2:return m.join("")}if(p==0&&(p=Math.pow(2,O),O++),l[A])x=l[A];else if(A===y)x=c+c.charAt(0);else return null;m.push(x),l[y++]=c+x.charAt(0),p--,c=x,p==0&&(p=Math.pow(2,O),O++)}}};return s}();d!=null?d.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}(dr);var Mn=dr.exports;function Ie(d){return JSON.parse(Mn.decompress(d))}function qt(d){return Mn.compress(JSON.stringify(d))}class On extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Pencil);nt(this,"syncTimestamp");nt(this,"syncIndex",0);nt(this,"tmpPoints",[]);nt(this,"MAX_REPEAR",10);nt(this,"uniThickness");nt(this,"workOptions");nt(this,"centerPos",[0,0]);this.workOptions=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var s;const t=(s=this.workId)==null?void 0:s.toString(),e=this.transformDataAll(!0),n={name:t};let i;const a=this.drawLayer||this.fullLayer;return e.length&&(i=this.draw({attrs:n,tasks:e,replaceId:t,layer:a})),{rect:i,type:ct.DrawWork,dataType:Tt.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){var c;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a,drawCount:s,replaceId:o}=t;if(((c=e.op)==null?void 0:c.length)===0)return{type:ct.None};const{workId:f}=e,{tasks:v,effects:l,consumeIndex:p}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,p,Math.max(0,this.tmpPoints.length-2));const y={name:f==null?void 0:f.toString(),id:s==null?void 0:s.toString()};let O,x=!1;const m=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),v.length&&(v[0].taskId-this.syncTimestamp>this.syncUnitTime&&(x=!0,this.syncTimestamp=v[0].taskId,this.syncIndex=this.tmpPoints.length),i||a)){const h=n?this.fullLayer:this.drawLayer||this.fullLayer;O=this.draw({attrs:y,tasks:v,effects:l,layer:h,replaceId:o})}if(i)return p>10&&this.tmpPoints.splice(0,p-10),{rect:O,type:ct.DrawWork,dataType:Tt.Local};const T=[];return this.tmpPoints.slice(m).forEach(h=>{T.push(h.x,h.y,this.computRadius(h.z,this.workOptions.thickness))}),{rect:O,type:ct.DrawWork,dataType:Tt.Local,workId:x?f:void 0,op:x?T:void 0,index:x?m*3:void 0}}consumeAll(t){var v,l;if(t.data){const{op:p,workState:y}=t.data;p!=null&&p.length&&y===Rt.Done&&this.workOptions.strokeType===Vt.Stroke&&this.updateTempPointsWithPressureWhenDone(p)}const e=(v=this.workId)==null?void 0:v.toString();if(!e)return{type:ct.None};const n=this.transformDataAll(!0),i={name:e};let a;const s=this.fullLayer;n.length&&(a=this.draw({attrs:i,tasks:n,replaceId:e,layer:s}));const o=[];this.tmpPoints.map(p=>{o.push(p.x,p.y,this.computRadius(p.z,this.workOptions.thickness))}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const f=qt(o);return(l=this.vNodes)==null||l.setInfo(e,{rect:a,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,s)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:e,ops:f,updateNodeOpt:{pos:this.centerPos,useAnimation:!0},opt:this.workOptions}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var v,l;const{op:e,isFullWork:n,replaceId:i}=t;this.tmpPoints.length=0;for(let p=0;p<e.length;p+=3){const y=new xt(e[p],e[p+1],e[p+2]);if(this.tmpPoints.length>0){const O=this.tmpPoints[this.tmpPoints.length-1],x=_.Sub(y,O).uni();y.setv(x)}this.tmpPoints.push(y)}const a=this.transformDataAll(!1),s=(v=this.workId)==null?void 0:v.toString(),o={name:s};let f;if(s&&a.length){const p=n?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:o,tasks:a,replaceId:i,layer:p}),(l=this.vNodes)==null||l.setInfo(s,{rect:f,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&yt.getCenterPos(f,p)})}return f}transformDataAll(t=!0){return this.getTaskPoints(this.tmpPoints,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:n,replaceId:i,effects:a,layer:s}=t,{strokeColor:o,strokeType:f,thickness:v,zIndex:l,scale:p,rotate:y,translate:O}=this.workOptions;a!=null&&a.size&&(a.forEach(u=>{var g;(g=s.getElementById(u+""))==null||g.remove()}),a.clear());let x;const m=[],T=s.worldPosition,c=s.worldScaling;for(let u=0;u<n.length;u++){const{pos:g,points:M}=n[u],{ps:A,rect:I}=this.computDrawPoints(M);let b;const E=M.length===1;f===Vt.Stroke||E?b=Oe(A,!0):b=Oe(A,!1);const L={pos:g,d:b,fillColor:f===Vt.Stroke||E?o:void 0,lineDash:f===Vt.Dotted&&!E?[1,v*2]:f===Vt.LongDotted&&!E?[v,v*2]:void 0,strokeColor:o,lineCap:f===Vt.Stroke||E?void 0:"round",lineWidth:f===Vt.Stroke||E?0:v};x=Ot(x,{x:Math.floor((I.x+g[0])*c[0]+T[0]-yt.SafeBorderPadding),y:Math.floor((I.y+g[1])*c[1]+T[1]-yt.SafeBorderPadding),w:Math.floor(I.w*c[0]+2*yt.SafeBorderPadding),h:Math.floor(I.h*c[1]+2*yt.SafeBorderPadding)}),m.push(L)}p&&(e.scale=p),y&&(e.rotate=y),O&&(e.translate=O);const h=new se;if(x){this.centerPos=yt.getCenterPos(x,s),h.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:f===Vt.Stroke?o:void 0,pos:this.centerPos,size:[(x.w-2*yt.SafeBorderPadding)/c[0],(x.h-2*yt.SafeBorderPadding)/c[1]],zIndex:l});const u=m.map(g=>(g.pos=[g.pos[0]-this.centerPos[0],g.pos[1]-this.centerPos[1]],new ge(g)));h.append(...u),f===Vt.Stroke&&h.seal(),this.replace(s,i||e.workId,h)}if(p||y||O){const u=h==null?void 0:h.getBoundingClientRect();if(u)return{x:Math.floor(u.x-yt.SafeBorderPadding),y:Math.floor(u.y-yt.SafeBorderPadding),w:Math.floor(u.width+yt.SafeBorderPadding*2),h:Math.floor(u.height+yt.SafeBorderPadding*2)}}return x}computDrawPoints(t){return this.workOptions.strokeType===Vt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const n=t.map(i=>(e=Math.max(e,i.radius),i.point));return{ps:n,rect:wt(n,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],n=[];for(let f=0;f<t.length;f++){const{point:v,radius:l}=t[f];let p=v.v;f===0&&t.length>1&&(p=t[f+1].point.v);const y=_.Per(p).mul(l);e.push(xt.Sub(v,y)),n.push(xt.Add(v,y))}const i=t[t.length-1],a=xt.GetSemicircleStroke(i.point,e[e.length-1],-1,8),s=xt.GetSemicircleStroke(t[0].point,n[0],-1,8),o=e.concat(a,n.reverse(),s);return{ps:o,rect:wt(o)}}computDotStroke(t){const{point:e,radius:n}=t,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i}}transformData(t,e){const{op:n,workState:i}=t;let a=this.tmpPoints.length-1,s=[];if(n!=null&&n.length&&i){const{strokeType:o,thickness:f}=this.workOptions,v=new Set;a=o===Vt.Stroke?this.updateTempPointsWithPressure(n,f,v):this.updateTempPoints(n,f,v);const l=e?this.tmpPoints:this.tmpPoints.slice(a);return s=this.getTaskPoints(l,f),{tasks:s,effects:v,consumeIndex:a}}return{tasks:s,consumeIndex:a}}computRadius(t,e){return t*.03*e+e*.5}getMinZ(t,e){return((e||Math.max(1,Math.floor(t*.3)))-t*.5)*100/t/3}getTaskPoints(t,e){var l;const n=[];if(t.length===0)return[];let i=0,a=t[0].x,s=t[0].y,o=[a,s],f=[],v=t[0].t;for(;i<t.length;){const p=t[i],y=p.x-a,O=p.y-s,x=p.z,m=e?this.computRadius(x,e):x;if(f.push({point:new xt(y,O,x,t[i].v),radius:m}),i>0&&i<t.length-1){const T=t[i].getAngleByPoints(t[i-1],t[i+1]);if(T<90||T>270){const c=(l=f.pop())==null?void 0:l.point.clone();c&&n.push({taskId:v,pos:o,points:[...f,{point:c,radius:m}]}),a=t[i].x,s=t[i].y,o=[a,s];const h=p.x-a,u=p.y-s;f=[{point:new xt(h,u,x),radius:m}],v=Date.now()}}i++}return n.push({taskId:v,pos:o,points:f}),n}updateTempPointsWithPressure(t,e,n){const i=Date.now(),a=this.tmpPoints.length;let s=a;for(let f=0;f<t.length;f+=2){s=Math.min(s,a);const v=this.tmpPoints.length,l=new xt(t[f],t[f+1]);if(v===0){this.tmpPoints.push(l);continue}const p=v-1,y=this.tmpPoints[p],O=_.Sub(l,y).uni();if(l.isNear(y,e)){if(y.z<this.MAX_REPEAR){if(y.setz(Math.min(y.z+1,this.MAX_REPEAR)),s=Math.min(s,p),v>1){let T=v-1;for(;T>0;){const c=this.tmpPoints[T].distance(this.tmpPoints[T-1]),h=Math.max(this.tmpPoints[T].z-this.uniThickness*c,0);if(this.tmpPoints[T-1].z>=h)break;this.tmpPoints[T-1].setz(h),s=Math.min(s,T-1),T--}}}else s=1/0;continue}l.setv(O);const x=l.distance(y),m=Math.max(y.z-this.uniThickness*x,0);v>1&&_.Equals(O,y.v,.02)&&(m>0||y.z<=0)&&(n&&y.t&&n.add(y.t),this.tmpPoints.pop(),s=Math.min(p,s)),l.setz(m),this.tmpPoints.push(l)}if(s===1/0)return this.tmpPoints.length;let o=a;if(s===a){o=Math.max(o-1,0);const f=this.tmpPoints[o].t;f&&(n==null||n.add(f))}else{let f=a-1;for(o=s;f>=0;){const v=this.tmpPoints[f].t;if(v&&(n==null||n.add(v),f<=s)){o=f,f=-1;break}f--}}return this.tmpPoints[o].setT(i),o}updateTempPoints(t,e,n){var f;const i=Date.now(),a=this.tmpPoints.length;let s=a;for(let v=0;v<t.length;v+=2){const l=this.tmpPoints.length,p=new xt(t[v],t[v+1]);if(l===0){this.tmpPoints.push(p);continue}const y=l-1,O=this.tmpPoints[y],x=_.Sub(p,O).uni();if(p.isNear(O,e/2)){s=Math.min(y,s);continue}_.Equals(x,O.v,.02)&&(n&&O.t&&n.add(O.t),this.tmpPoints.pop(),s=Math.min(y,s)),p.setv(x),this.tmpPoints.push(p)}let o=a;if(s===a){o=Math.max(o-1,0);const v=this.tmpPoints[o].t;v&&(n==null||n.add(v))}else{let v=Math.min(a-1,s);for(o=s;v>=0;){const l=(f=this.tmpPoints[v])==null?void 0:f.t;if(l&&(n==null||n.add(l),v<=s)){o=v,v=-1;break}v--}}return this.tmpPoints[o].setT(i),o}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,n=t.length,i=this.getMinZ(e);for(let a=0;a<n;a+=2){const s=this.tmpPoints.length,o=new xt(t[a],t[a+1]);if(s===0){this.tmpPoints.push(o);continue}const f=s-1,v=this.tmpPoints[f],l=_.Sub(o,v).uni(),p=o.distance(v);if(s>1&&v.z===i)break;if(o.isNear(v,e/2)){if(n<3&&v.z<this.MAX_REPEAR&&(v.setz(Math.min(v.z+1,this.MAX_REPEAR)),s>1)){let O=s-1;for(;O>0;){const x=this.tmpPoints[O].distance(this.tmpPoints[O-1]),m=Math.max(this.tmpPoints[O].z-this.uniThickness*x,-e/4);if(this.tmpPoints[O-1].z>=m)break;this.tmpPoints[O-1].setz(m),O--}}continue}o.setv(l);const y=Math.max(v.z-this.uniThickness*p,i);s>1&&_.Equals(l,v.v,.02)&&v.z<=0&&this.tmpPoints.pop(),o.setz(y),this.tmpPoints.push(o)}}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.tagName==="GROUP"?Wh(e)?e.setAttribute("bgcolor",a):e.children.forEach(f=>{f.setAttribute("strokeColor",a),f.getAttribute("fillColor")&&f.setAttribute("fillColor",a)}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a)),s&&i.setInfo(e.name,s),yt.updateNodeOpt(t)}}class En extends yt{constructor(t){super(t);nt(this,"toolsType",ht.LaserPen);nt(this,"canRotate",!1);nt(this,"scaleType",jt.none);nt(this,"syncTimestamp");nt(this,"syncIndex",0);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:n}=t,{workId:i,op:a}=e;if((a==null?void 0:a.length)===0)return{type:ct.None};if(this.updateTempPoints(a||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:ct.None};const{strokeColor:s,thickness:o,strokeType:f}=this.workOptions,v=wt(this.tmpPoints,o);let l=!1;const p=this.syncIndex,y=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const O={name:i==null?void 0:i.toString(),opacity:1,lineDash:f===Vt.Dotted?[1,o*2]:f===Vt.LongDotted?[o,o*2]:void 0,strokeColor:s,lineCap:"round",lineWidth:o,anchor:[.5,.5]},x=this.getTaskPoints(y);if(x.length){const T=Date.now();T-this.syncTimestamp>this.syncUnitTime&&(l=!0,this.syncTimestamp=T,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:O,tasks:x,isDot:!1,layer:this.drawLayer||this.fullLayer})}const m=[];return this.tmpPoints.slice(p).forEach(T=>{m.push(T.x,T.y)}),{rect:{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]},type:ct.DrawWork,dataType:Tt.Local,workId:l?i:void 0,op:l?m:void 0,index:l?p*2:void 0}}consumeAll(){var a;const t=(a=this.workId)==null?void 0:a.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let s=this.tmpPoints.slice(this.consumeIndex);const o=s.length===1,{strokeColor:f,thickness:v,strokeType:l}=this.workOptions;if(o){const O=this.computDotStroke({point:s[0],radius:v/2});s=O.ps,e=O.rect}else e=wt(this.tmpPoints,v);const p={name:t==null?void 0:t.toString(),fillColor:o?f:void 0,opacity:1,lineDash:l===Vt.Dotted&&!o?[1,v*2]:l===Vt.LongDotted&&!o?[v,v*2]:void 0,strokeColor:f,lineCap:o?void 0:"round",lineWidth:o?0:v,anchor:[.5,.5]},y=this.getTaskPoints(s);y.length&&this.draw({attrs:p,tasks:y,isDot:o,layer:this.drawLayer||this.fullLayer})}const n=[];this.tmpPoints.forEach(s=>{n.push(s.x,s.y)});const i=qt(n);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:ct.FullWork,dataType:Tt.Local,workId:t,ops:i,index:this.syncIndex*2}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var x;const{op:e,replaceId:n,isFullWork:i}=t,{strokeColor:a,thickness:s,strokeType:o}=this.workOptions;if(!e.length){const m=wt(this.tmpPoints,s);return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.h*this.fullLayer.worldScaling[1]}}const f=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);let v,l=this.tmpPoints.slice(f);const p=l.length===1;if(p){const m=this.computDotStroke({point:l[0],radius:s/2});l=m.ps,v=m.rect}else v=wt(this.tmpPoints,s);const y={name:(x=this.workId)==null?void 0:x.toString(),fillColor:p?a:void 0,opacity:1,lineDash:o===Vt.Dotted&&!p?[1,s*2]:o===Vt.LongDotted&&!p?[s,s*2]:void 0,strokeColor:a,lineCap:p?void 0:"round",lineWidth:p?0:s,anchor:[.5,.5]},O=this.getTaskPoints(l);if(O.length){const m=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:y,tasks:O,isDot:p,replaceId:n,layer:m})}return{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]}}computDotStroke(t){const{point:e,radius:n}=t,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i}}updateTempPoints(t){const e=this.tmpPoints.length;for(let n=0;n<t.length;n+=2){if(e){const i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new xt(t[n],t[n+1]))}}async draw(t){const{attrs:e,tasks:n,isDot:i,layer:a}=t,{duration:s}=this.workOptions;for(const o of n){const f=new ge,{pos:v,points:l}=o;let p;i?p=Oe(l,!0):p=Oe(l,!1),f.attr({...e,pos:v,d:p});const{vertex:y,fragment:O}=this.workOptions;if(y&&O){const x=a.renderer.createProgram({vertex:y,fragment:O}),{width:m,height:T}=a.getResolution();f.setUniforms({u_time:0,u_resolution:[m,T]}),f.setProgram(x)}a.appendChild(f),f.transition(s).attr({scale:i?[.1,.1]:[1,1],lineWidth:i?0:1}).then(()=>{f.remove()})}}getTaskPoints(t){var f;const e=[];if(t.length===0)return[];let n=0,i=t[0].x,a=t[0].y,s=[i,a],o=[];for(;n<t.length;){const v=t[n],l=v.x-i,p=v.y-a;if(o.push(new xt(l,p)),n>0&&n<t.length-1){const y=t[n].getAngleByPoints(t[n-1],t[n+1]);if(y<90||y>270){const O=(f=o.pop())==null?void 0:f.clone();O&&e.push({pos:s,points:[...o,O]}),i=t[n].x,a=t[n].y,s=[i,a];const x=v.x-i,m=v.y-a;o=[new xt(x,m)]}}n++}return e.push({pos:s,points:o}),e}removeLocal(){}removeService(t){let e;const n=[];return this.fullLayer.getElementsByName(t).forEach(i=>{if(i.name===t){const a=i.getBoundingClientRect();e=Ot(e,{x:a.x,y:a.y,w:a.width,h:a.height}),n.push(i)}}),n.length&&n.forEach(i=>i.remove()),e}}var Yh=Xe;Xe.polyline=Xe,Xe.polygon=Xh;function Xe(d,r,t){var e=d.length,n=Ee(d[0],r),i=[],a,s,o,f,v;for(t||(t=[]),a=1;a<e;a++){for(s=d[a-1],o=d[a],f=v=Ee(o,r);;)if(n|f){if(n&f)break;n?(s=gr(s,o,n,r),n=Ee(s,r)):(o=gr(s,o,f,r),f=Ee(o,r))}else{i.push(s),f!==v?(i.push(o),a<e-1&&(t.push(i),i=[])):a===e-1&&i.push(o);break}n=v}return i.length&&t.push(i),t}function Xh(d,r){var t,e,n,i,a,s,o;for(e=1;e<=8;e*=2){for(t=[],n=d[d.length-1],i=!(Ee(n,r)&e),a=0;a<d.length;a++)s=d[a],o=!(Ee(s,r)&e),o!==i&&t.push(gr(n,s,e,r)),o&&t.push(s),n=s,i=o;if(d=t,!d.length)break}return t}function gr(d,r,t,e){return t&8?[d[0]+(r[0]-d[0])*(e[3]-d[1])/(r[1]-d[1]),e[3]]:t&4?[d[0]+(r[0]-d[0])*(e[1]-d[1])/(r[1]-d[1]),e[1]]:t&2?[e[2],d[1]+(r[1]-d[1])*(e[2]-d[0])/(r[0]-d[0])]:t&1?[e[0],d[1]+(r[1]-d[1])*(e[0]-d[0])/(r[0]-d[0])]:null}function Ee(d,r){var t=0;return d[0]<r[0]?t|=1:d[0]>r[2]&&(t|=2),d[1]<r[1]?t|=4:d[1]>r[3]&&(t|=8),t}var Jh=Xt(Yh);const Pe=class Pe extends yt{constructor(t,e){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.none);nt(this,"toolsType",ht.Eraser);nt(this,"serviceWork");nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"worldPosition");nt(this,"worldScaling");nt(this,"eraserRect");nt(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],n=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:i,height:a}=Pe.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-i*.5,y:n-a*.5,w:i,h:a},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new _(this.tmpPoints[0],this.tmpPoints[1]),n=new _(this.tmpPoints[2],this.tmpPoints[3]),i=_.Sub(n,e).uni(),a=_.Dist(e,n),{width:s,height:o}=Pe.eraserSizes[this.workOptions.thickness],f=Math.min(s,o),v=Math.round(a/f);if(v>1){const l=[];for(let p=0;p<v;p++){const y=_.Mul(i,p*f);l.push(this.tmpPoints[0]+y.x,this.tmpPoints[1]+y.y)}return l.concat(t)}}return t}isNear(t,e){const n=new _(t[0],t[1]),i=new _(e[0],e[1]),{width:a,height:s}=Pe.eraserSizes[this.workOptions.thickness];return _.Dist(n,i)<Math.hypot(a,s)*.5}cutPolyline(t,e){let n=[e],i=0;for(;i<t.length;){const o=t[i];if(o.length<2)break;n=a(n,o),i++}return n;function a(o,f){const v=o;for(let l=0;l<o.length;l++){const p=o[l],y=p.findIndex((O,x)=>x<p.length-1?s([O,p[x+1]],[f[0],f[1]]):!1);if(y!==-1&&y>-1){const O=[],x=p.slice(0,y+1);if(_.Equals(p[y],f[0])||x.push(f[0].clone().setz(p[y].z)),x.length>1&&O.push(x),y+f.length-1<p.length-1){const m=y+f.length-1,T=p.slice(m),c=f[f.length-1];_.Equals(p[m],c)||T.unshift(c.clone().setz(p[m].z)),T.length>1&&O.push(T)}return v.splice(l,1,...O),v}}return v}function s(o,f){const v=_.Sub(o[1],o[0]),l=_.Sub(f[1],f[0]),p=_.Sub(f[0],o[0]);return Math.abs(_.Cpr(v,l))<.1&&Math.abs(_.Cpr(v,p))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let n=0;n<t.length;n++){const i=t[n].filter((o,f,v)=>!(f>0&&this.isSamePoint(o,v[f-1]))),a=[];let s=0;for(;s<i.length;){const o=i[s],f=new _(o[0],o[1]);a.push(f),s++}e.push(a)}return e}isLineEraser(t,e){return!(t===ht.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:n,newWorkDatas:i}=t,{isLine:a}=this.workOptions;let s;for(const[o,f]of e.entries())if(f.rect&&this.eraserRect&&this.eraserPolyline&&Ce(this.eraserRect,f.rect)){const{op:v,toolsType:l}=f,p=this.isLineEraser(l,a),y=[],O=[];for(let m=0;m<v.length;m+=3){const T=new _(v[m]*this.worldScaling[0]+this.worldPosition[0],v[m+1]*this.worldScaling[1]+this.worldPosition[1],v[m+2]);O.push(T),y.push(new xt(T.x,T.y))}const x=y.length&&wt(y)||f.rect;if(Ce(x,this.eraserRect)){if(O.length>1){const m=Jh.polyline(O.map(T=>T.XY),this.eraserPolyline);if(m.length&&(n.add(f.name),!p)){const T=this.translateIntersect(m),c=this.cutPolyline(T,O);for(let h=0;h<c.length;h++){const u=`${o}_s_${h}`,g=[];c[h].forEach(M=>{g.push((M.x-this.worldPosition[0])/this.worldScaling[0],(M.y-this.worldPosition[1])/this.worldScaling[1],M.z)}),f.opt&&f.toolsType&&this.vNodes&&(this.vNodes.setInfo(u,{rect:x,op:g,opt:f.opt,canRotate:f.canRotate,scaleType:f.scaleType,toolsType:f.toolsType}),i.set(u,{workId:u,op:g,opt:f.opt,toolsType:f.toolsType}))}}}else n.add(f.name);s=Ot(s,x)}}return n.forEach(o=>{var f;return(f=this.vNodes)==null?void 0:f.delete(o)}),s&&(s.x-=yt.SafeBorderPadding,s.y-=yt.SafeBorderPadding,s.w+=yt.SafeBorderPadding*2,s.h+=yt.SafeBorderPadding*2),s}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:ct.None};const n=this.tmpPoints.length;if(n>1&&this.isNear([e[0],e[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:ct.None};n===4&&(this.tmpPoints.shift(),this.tmpPoints.shift()),this.tmpPoints.push(e[0],e[1]);const i=this.computRectCenterPoints();let a;const s=new Set,o=new Map;if(!this.vNodes)return{type:ct.None};this.vNodes.setTarget();const f=this.getUnLockNodeMap(this.vNodes.getLastTarget());for(let v=0;v<i.length-1;v+=2){this.createEraserRect(i.slice(v,v+2));const l=this.remove({curNodeMap:f,removeIds:s,newWorkDatas:o});a=Ot(a,l)}if(this.vNodes.deleteLastTarget(),a&&s.size){for(const v of o.keys())s.has(v)&&o.delete(v);return{type:ct.RemoveNode,dataType:Tt.Local,rect:a,removeIds:[...s],newWorkDatas:o}}return{type:ct.None}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const n=Jt(t),i=this.serviceWork.selectorWorkShapes,a=this.serviceWork.workShapes;for(const s of i.values())if((e=s.selectIds)!=null&&e.length)for(const o of s.selectIds)n.delete(o);for(const s of a.keys())n.delete(s);return n}return t}};nt(Pe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let ae=Pe;const pr="++",Qh="selector",Zh="all";var kh="__lodash_hash_undefined__";function qh(d){return this.__data__.set(d,kh),this}var _h=qh;function td(d){return this.__data__.has(d)}var ed=td,rd=br,nd=_h,id=ed;function Je(d){var r=-1,t=d==null?0:d.length;for(this.__data__=new rd;++r<t;)this.add(d[r])}Je.prototype.add=Je.prototype.push=nd,Je.prototype.has=id;var sd=Je;function od(d,r){for(var t=-1,e=d==null?0:d.length;++t<e;)if(r(d[t],t,d))return!0;return!1}var ad=od;function ld(d,r){return d.has(r)}var cd=ld,fd=sd,ud=ad,hd=cd,dd=1,gd=2;function pd(d,r,t,e,n,i){var a=t&dd,s=d.length,o=r.length;if(s!=o&&!(a&&o>s))return!1;var f=i.get(d),v=i.get(r);if(f&&v)return f==r&&v==d;var l=-1,p=!0,y=t&gd?new fd:void 0;for(i.set(d,r),i.set(r,d);++l<s;){var O=d[l],x=r[l];if(e)var m=a?e(x,O,l,r,d,i):e(O,x,l,d,r,i);if(m!==void 0){if(m)continue;p=!1;break}if(y){if(!ud(r,function(T,c){if(!hd(y,c)&&(O===T||n(O,T,t,e,i)))return y.push(c)})){p=!1;break}}else if(!(O===x||n(O,x,t,e,i))){p=!1;break}}return i.delete(d),i.delete(r),p}var Pn=pd;function vd(d){var r=-1,t=Array(d.size);return d.forEach(function(e,n){t[++r]=[n,e]}),t}var md=vd;function yd(d){var r=-1,t=Array(d.size);return d.forEach(function(e){t[++r]=e}),t}var Sd=yd,An=Be,Cn=sn,xd=Ze,Td=Pn,Md=md,Od=Sd,Ed=1,Pd=2,Ad="[object Boolean]",Cd="[object Date]",Rd="[object Error]",Id="[object Map]",Ld="[object Number]",bd="[object RegExp]",Dd="[object Set]",wd="[object String]",Nd="[object Symbol]",Wd="[object ArrayBuffer]",Bd="[object DataView]",Rn=An?An.prototype:void 0,vr=Rn?Rn.valueOf:void 0;function Fd(d,r,t,e,n,i,a){switch(t){case Bd:if(d.byteLength!=r.byteLength||d.byteOffset!=r.byteOffset)return!1;d=d.buffer,r=r.buffer;case Wd:return!(d.byteLength!=r.byteLength||!i(new Cn(d),new Cn(r)));case Ad:case Cd:case Ld:return xd(+d,+r);case Rd:return d.name==r.name&&d.message==r.message;case bd:case wd:return d==r+"";case Id:var s=Md;case Dd:var o=e&Ed;if(s||(s=Od),d.size!=r.size&&!o)return!1;var f=a.get(d);if(f)return f==r;e|=Pd,a.set(d,r);var v=Td(s(d),s(r),e,n,i,a);return a.delete(d),v;case Nd:if(vr)return vr.call(d)==vr.call(r)}return!1}var jd=Fd,In=kr,Ud=1,$d=Object.prototype,zd=$d.hasOwnProperty;function Gd(d,r,t,e,n,i){var a=t&Ud,s=In(d),o=s.length,f=In(r),v=f.length;if(o!=v&&!a)return!1;for(var l=o;l--;){var p=s[l];if(!(a?p in r:zd.call(r,p)))return!1}var y=i.get(d),O=i.get(r);if(y&&O)return y==r&&O==d;var x=!0;i.set(d,r),i.set(r,d);for(var m=a;++l<o;){p=s[l];var T=d[p],c=r[p];if(e)var h=a?e(c,T,p,r,d,i):e(T,c,p,d,r,i);if(!(h===void 0?T===c||n(T,c,t,e,i):h)){x=!1;break}m||(m=p=="constructor")}if(x&&!m){var u=d.constructor,g=r.constructor;u!=g&&"constructor"in d&&"constructor"in r&&!(typeof u=="function"&&u instanceof u&&typeof g=="function"&&g instanceof g)&&(x=!1)}return i.delete(d),i.delete(r),x}var Hd=Gd,mr=Dr,Kd=Pn,Vd=jd,Yd=Hd,Ln=Ke,bn=$e,Dn=_e,Xd=zr,Jd=1,wn="[object Arguments]",Nn="[object Array]",Qe="[object Object]",Qd=Object.prototype,Wn=Qd.hasOwnProperty;function Zd(d,r,t,e,n,i){var a=bn(d),s=bn(r),o=a?Nn:Ln(d),f=s?Nn:Ln(r);o=o==wn?Qe:o,f=f==wn?Qe:f;var v=o==Qe,l=f==Qe,p=o==f;if(p&&Dn(d)){if(!Dn(r))return!1;a=!0,v=!1}if(p&&!v)return i||(i=new mr),a||Xd(d)?Kd(d,r,t,e,n,i):Vd(d,r,o,t,e,n,i);if(!(t&Jd)){var y=v&&Wn.call(d,"__wrapped__"),O=l&&Wn.call(r,"__wrapped__");if(y||O){var x=y?d.value():d,m=O?r.value():r;return i||(i=new mr),n(x,m,t,e,i)}}return p?(i||(i=new mr),Yd(d,r,t,e,n,i)):!1}var kd=Zd,qd=kd,Bn=ie;function Fn(d,r,t,e,n){return d===r?!0:d==null||r==null||!Bn(d)&&!Bn(r)?d!==d&&r!==r:qd(d,r,t,e,Fn,n)}var _d=Fn,t0=_d;function e0(d,r){return t0(d,r)}var r0=e0,le=Xt(r0);const ne=class ne extends yt{constructor(t){super(t);nt(this,"toolsType",ht.Selector);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"vNodes");nt(this,"selectIds");nt(this,"selectorColor");nt(this,"strokeColor");nt(this,"fillColor");nt(this,"oldSelectRect");nt(this,"canRotate",!1);nt(this,"canTextEdit",!1);nt(this,"canLock",!1);nt(this,"scaleType",jt.all);nt(this,"toolsTypes");nt(this,"shapeOpt");nt(this,"textOpt");nt(this,"isLocked");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=wt(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:n,nodeRange:i}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...i.keys()],intersectRect:n,subNodeMap:i}}updateTempPoints(t){const e=this.tmpPoints.length,n=t.length;if(n>1){const i=new xt(t[n-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[n-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,i):this.tmpPoints.push(i)}}drawSelector(t){const{drawRect:e,subNodeMap:n,selectorId:i,layer:a,isService:s}=t,o=new se({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:i,name:i,zIndex:1e3}),f=[];if(s){const v=new hr({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:ne.selectorBorderId});f.push(v)}n.forEach((v,l)=>{const p=[v.rect.x+v.rect.w/2-e.x,v.rect.y+v.rect.h/2-e.y],y=new hr({normalize:!0,pos:p,lineWidth:1,strokeColor:n.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:v.rect.w,height:v.rect.h,id:`selector-${l}`,name:`selector-${l}`});f.push(y)}),f&&o.append(...f),(a==null?void 0:a.parent).appendChild(o)}draw(t,e,n,i=!1){var o,f;const{intersectRect:a,subNodeMap:s}=n;(f=(o=e.parent)==null?void 0:o.getElementById(t))==null||f.remove(),a&&this.drawSelector({drawRect:a,subNodeMap:s,selectorId:t,layer:e,isService:i})}getSelecteorInfo(t){this.scaleType=jt.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0;const e=new Set;let n;for(const i of t.values()){const{opt:a,canRotate:s,scaleType:o,toolsType:f}=i;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),f===ht.SpeechBalloon&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),f===ht.Polygon&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),f===ht.Star&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),f===ht.Text&&(this.textOpt=a),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=s,this.scaleType=o),o===jt.none&&(this.scaleType=o),f===ht.Image&&(n=i)}e.size&&(this.toolsTypes=[...e]),n&&(t.size===1?(this.canLock=!0,n.opt.locked&&(this.isLocked=!0,this.scaleType=jt.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1)):t.size>1&&!n.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var t,e;if(this.scaleType===jt.both&&((t=this.selectIds)==null?void 0:t.length)===1){const n=this.selectIds[0],i=(e=this.vNodes.get(n))==null?void 0:e.op;if(i){const a=[];for(let s=0;s<i.length;s+=3)a.push([i[s],i[s+1]]);return a}}}consume(t){const{op:e,workState:n}=t.data;let i=this.oldSelectRect;if(n===Rt.Start&&(i=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:ct.None};this.updateTempPoints(e);const a=this.computSelector();if(this.selectIds&&le(this.selectIds,a.selectIds))return{type:ct.None};this.selectIds=a.selectIds;const s=a.intersectRect;this.getSelecteorInfo(a.subNodeMap),this.draw(ne.selectorId,this.fullLayer,a),this.oldSelectRect=s;const o=this.getChildrenPoints();return{type:ct.Select,dataType:Tt.Local,rect:Ot(s,i),selectIds:a.selectIds,opt:this.workOptions,selectRect:s,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:o,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt}}consumeAll(){var e,n;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,ne.selectorId,!1),(n=this.selectIds)!=null&&n.length&&(t=this.selectedByIds(this.selectIds)),t){const i=this.getChildrenPoints();return{type:ct.Select,dataType:Tt.Local,rect:this.oldSelectRect,selectIds:this.selectIds,opt:this.workOptions,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:i,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt}}return{type:ct.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(t,e=ne.selectorId,n=!1){if(t.length===2){const i=t[0],a=t[1];let s;const{nodeRange:o}=this.vNodes.getRectIntersectRange({x:i,y:a,w:0,h:0},!1),f=[...o.values()].sort((v,l)=>(l.opt.zIndex||0)-(v.opt.zIndex||0));for(const v of f){const l=this.fullLayer.getElementsByName(v.name);if(Yn(l).find(y=>y.isPointCollision(i,a))){s=v;break}}if(s){const v=s.name;if(!le(this.oldSelectRect,s.rect)){const l=new Map([[v,s]]);this.getSelecteorInfo(l),this.draw(e,this.fullLayer,{intersectRect:s.rect,subNodeMap:l,selectIds:this.selectIds||[]},n)}this.selectIds=[v],this.oldSelectRect=s.rect}}}unSelectedAllIds(){let t;for(const[e,n]of this.vNodes.curNodeMap.entries())n.isSelected&&(t=Ot(t,n.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const n of t){const i=this.vNodes.get(n);i&&i.isSelected&&(e=Ot(e,i.rect),this.vNodes.unSelected(n))}return e}selectedByIds(t){let e;for(const n of t){const i=this.vNodes.get(n);i&&(e=Ot(e,i.rect),this.vNodes.selected(n))}return e}getSelectorRect(t,e){var s;let n;const i=(s=t.parent)==null?void 0:s.getElementById(e),a=i==null?void 0:i.getBoundingClientRect();return a&&(n=Ot(n,{x:Math.floor(a.x),y:Math.floor(a.y),w:Math.floor(a.width+1),h:Math.floor(a.height+1)})),n}isCanFillColor(t){return t===ht.Ellipse||t===ht.Triangle||t===ht.Rectangle||t===ht.Polygon||t===ht.Star||t===ht.SpeechBalloon}async updateSelector(t){const{updateSelectorOpt:e,selectIds:n,vNodes:i,willSerializeData:a,worker:s,offset:o,scene:f,isMainThread:v}=t,l=this.fullLayer;if(!l)return;let p;const y=new Map,{box:O,workState:x,angle:m,translate:T}=e;let c=[0,0],h=[1,1],u=[0,0],g,M;if(O||T||Qt(m)){if(x===Rt.Start)return i.setTarget(),{type:ct.Select,dataType:Tt.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(g=i.getLastTarget(),g&&O){let b;n==null||n.forEach(E=>{const L=g==null?void 0:g.get(E);b=Ot(b,L==null?void 0:L.rect)}),b&&(h=[O.w/b.w,O.h/b.h],c=[O.x+O.w/2-(b.x+b.w/2),O.y+O.h/2-(b.y+b.h/2)],u=[b.x+b.w/2,b.y+b.h/2]),M=b}}if(n)for(const b of n){const E=i.get(b);if(E){const{toolsType:L}=E;let D=(l==null?void 0:l.getElementsByName(b))[0];if(D){const R={...e};let C;if(L){if(g&&(C=g.get(b),C&&O)){R.boxScale=h;const z=[C.rect.x+C.rect.w/2,C.rect.y+C.rect.h/2],H=[z[0]-u[0],z[1]-u[1]];R.boxTranslate=[H[0]*(h[0]-1)+c[0]+(o&&o[0]||0),H[1]*(h[1]-1)+c[1]+(o&&o[1]||0)]}const W=Vn(L);if(W==null||W.updateNodeOpt({node:D,opt:R,vNodes:i,willSerializeData:a,targetNode:C}),E&&s&&(a&&(R.angle||R.translate)||R.box&&R.workState!==Rt.Start||R.pointMap&&R.pointMap.has(b)||L===ht.Text&&(R.fontSize||R.translate||R.textInfos&&R.textInfos.get(b))||L===ht.Image&&(R.angle||R.translate||R.boxScale)||L===R.toolsType&&R.willRefresh)){const z=s.createWorkShapeNode({toolsType:L,toolsOpt:E.opt});z==null||z.setWorkId(b);let H;L===ht.Image&&f?H=await z.consumeServiceAsync({isFullWork:!0,replaceId:b,scene:f,isMainThread:v}):L===ht.Text?H=await z.consumeServiceAsync({isFullWork:!0,replaceId:b}):H=z==null?void 0:z.consumeService({op:E.op,isFullWork:!0,replaceId:b}),H&&(E.rect=H),D=(l==null?void 0:l.getElementsByName(b))[0]}E&&(y.set(b,E),p=Ot(p,E.rect))}}}}g&&x===Rt.Done&&i.deleteLastTarget();const A=p;if(M&&e.dir&&A&&!o){const b=[0,0];switch(e.dir){case"top":{const E=[M.x,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h);break}case"topLeft":{const E=[M.x+M.w,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h),e.reverseX?b[0]=E[0]-A.x:b[0]=E[0]-(A.x+A.w);break}case"topRight":{const E=[M.x,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h),e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}case"bottom":{const E=[M.x,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y;break}case"bottomLeft":{const E=[M.x+M.w,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y,e.reverseX?b[0]=E[0]-A.x:b[0]=E[0]-(A.x+A.w);break}case"bottomRight":{const E=[M.x,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y,e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}case"right":{const E=[M.x,M.y];e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}}if(b[0]||b[1])return A.x=A.x+b[0],A.y=A.y+b[1],await this.updateSelector({...t,offset:b})}this.getSelecteorInfo(y),this.draw(ne.selectorId,l,{selectIds:n||[],subNodeMap:y,intersectRect:A});const I=Ot(this.oldSelectRect,A);return this.oldSelectRect=A,{type:ct.Select,dataType:Tt.Local,selectRect:A,renderRect:p,rect:Ot(I,A)}}blurSelector(){const t=this.unSelectedAllIds();return{type:ct.Select,dataType:Tt.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(pr,"-")}selectServiceNode(t,e,n){const{selectIds:i}=e,a=this.getRightServiceId(t),s=this.getSelectorRect(this.fullLayer,a);let o;const f=new Map;return i==null||i.forEach(v=>{const l=this.vNodes.get(v);l&&(o=Ot(o,l.rect),f.set(v,l))}),this.getSelecteorInfo(f),this.draw(a,this.fullLayer,{intersectRect:o,selectIds:i||[],subNodeMap:f},n),Ot(o,s)}reRenderSelector(){var n;let t;const e=new Map;return(n=this.selectIds)==null||n.forEach(i=>{const a=this.vNodes.get(i);a&&(t=Ot(t,a.rect),e.set(i,a))},this),this.getSelecteorInfo(e),this.draw(ne.selectorId,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var a;let e;const n=(a=this.selectIds)==null?void 0:a.filter(s=>!t.includes(s));if(n!=null&&n.length&&(e=this.unSelectedByIds(n)),t.length){const s=this.selectedByIds(t);e=Ot(e,s)}this.selectIds=t;const i=this.reRenderSelector();return{bgRect:e,selectRect:i}}cursorHover(t){var a,s;const e=this.oldSelectRect;this.selectIds=[];const n=(a=this.workId)==null?void 0:a.toString(),i=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,n,!0),this.oldSelectRect&&!le(e,this.oldSelectRect))return{type:ct.CursorHover,dataType:Tt.Local,rect:Ot(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((s=this.selectIds)!=null&&s.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:ct.CursorHover,dataType:Tt.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,n;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((n=this.fullLayer)==null?void 0:n.parent).children.forEach(i=>{i.name===t&&i.remove()})}};nt(ne,"selectorId",Qh),nt(ne,"selectorBorderId","selector-border");let Nt=ne;class jn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.both);nt(this,"toolsType",ht.Arrow);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"arrowTipWidth");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,thickness:a,zIndex:s,scale:o,rotate:f,translate:v}=this.workOptions,l=n.worldPosition,p=n.worldScaling,{points:y,rect:O}=this.computDrawPoints(a),m={pos:[O.x+O.w/2,O.y+O.h/2],name:e,id:e,close:!0,points:y,fillColor:i,strokeColor:i,lineWidth:0,normalize:!0,zIndex:s};o&&(m.scale=o),f&&(m.rotate=f),v&&(m.translate=v);const T=new pe(m);if(this.replace(n,e,T),o||f||v){const c=T.getBoundingClientRect();return{x:Math.floor(c.x-yt.SafeBorderPadding),y:Math.floor(c.y-yt.SafeBorderPadding),w:Math.floor(c.width+yt.SafeBorderPadding*2),h:Math.floor(c.height+yt.SafeBorderPadding*2)}}return{x:Math.floor(O.x*p[0]+l[0]-yt.SafeBorderPadding),y:Math.floor(O.y*p[1]+l[1]-yt.SafeBorderPadding),w:Math.floor(O.w*p[0]+2*yt.SafeBorderPadding),h:Math.floor(O.h*p[1]+2*yt.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=_.Per(e).mul(t/2),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=_.Mul(e,this.arrowTipWidth),o=_.Sub(this.tmpPoints[1],s),f=xt.Sub(o,n),v=xt.Add(o,n),l=_.Per(e).mul(t*1.5),p=xt.Sub(o,l),y=xt.Add(o,l),O=[i,f,p,this.tmpPoints[1],y,v,a];return{points:O.map(x=>xt.Sub(x,this.tmpPoints[0]).XY).flat(1),rect:wt(O),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),n=_.Per(t).mul(Math.floor(e*3/8)),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=[i,this.tmpPoints[1],a];return{points:s.map(o=>xt.Sub(o,this.tmpPoints[0]).XY).flat(1),rect:wt(s),isTriangle:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a),s&&i.setInfo(e.name,s)),yt.updateNodeOpt(t)}}class Un extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Ellipse);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,scale:v,rotate:l,translate:p}=this.workOptions,y=n.worldScaling,{radius:O,rect:x,pos:m}=this.computDrawPoints(o),T={pos:m,name:e,id:e,radius:O,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0},c={name:e,id:e,zIndex:f,pos:m,anchor:[.5,.5],size:[x.w,x.h]};v&&(c.scale=v),l&&(c.rotate=l),p&&(c.translate=p);const h=new se(c);if(i){const M=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/y[0],1/y[1]]});h.append(M)}const u=new Gh({...T,pos:[0,0]});h.append(u),this.replace(n,e,h);const g=h.getBoundingClientRect();return{x:Math.floor(g.x-yt.SafeBorderPadding),y:Math.floor(g.y-yt.SafeBorderPadding),w:Math.floor(g.width+yt.SafeBorderPadding*2),h:Math.floor(g.height+yt.SafeBorderPadding*2)}}computDrawPoints(t){const e=wt(this.tmpPoints),n=wt(this.tmpPoints,t),i=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:n,pos:i,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var v,l;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s}=n,o=i.get(e.name);let f=e;return e.tagName==="GROUP"&&(f=e.children[0]),a&&(f.setAttribute("strokeColor",a),(v=o==null?void 0:o.opt)!=null&&v.strokeColor&&(o.opt.strokeColor=a)),s&&(s==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",s),(l=o==null?void 0:o.opt)!=null&&l.fillColor&&(o.opt.fillColor=s)),o&&i.setInfo(e.name,o),yt.updateNodeOpt(t)}}var n0=ue,i0=ie,s0="[object Boolean]";function o0(d){return d===!0||d===!1||i0(d)&&n0(d)==s0}var a0=o0,ce=Xt(a0);class $n extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Rectangle);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=wt(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,n=[];for(const s of t)n.push(new _(...s));const i=wt(n,e),a=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:a,points:n.map(s=>s.XY).flat(1)}}consume(t){var x;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(x=e==null?void 0:e.workId)==null?void 0:x.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};const p=this.transformData();let y;if(i||a){const m=n?this.fullLayer:this.drawLayer||this.fullLayer;y=this.draw({ps:p,workId:s,layer:m,isDrawing:!0})}if(!i){const m=Date.now();return m-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=m,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:p.flat(1),isSync:!0,index:0}):{type:ct.None}}const O=Ot(y,this.oldRect);return this.oldRect=y,{rect:O,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var v,l;const{data:e}=t,n=(v=e==null?void 0:e.workId)==null?void 0:v.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.transformData(),a=this.fullLayer,s=this.draw({ps:i,workId:n,layer:a,isDrawing:!1});this.oldRect=s;const o=i.flat(1),f=qt(o);return(l=this.vNodes)==null||l.setInfo(n,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),{rect:s,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:f,opt:this.workOptions,isSync:!0}}draw(t){const{workId:e,layer:n,isDrawing:i,ps:a,replaceId:s}=t,{strokeColor:o,fillColor:f,thickness:v,zIndex:l,scale:p,rotate:y,translate:O,textOpt:x}=this.workOptions,m=n.worldPosition,T=n.worldScaling,{points:c,rect:h,pos:u}=this.computDrawPoints(a),g={close:!0,normalize:!0,points:c,lineWidth:v,fillColor:f!=="transparent"&&f||void 0,strokeColor:o,lineJoin:"round"},M={x:Math.floor(h.x*T[0]+m[0]-yt.SafeBorderPadding),y:Math.floor(h.y*T[1]+m[1]-yt.SafeBorderPadding),w:Math.floor(h.w*T[0]+2*yt.SafeBorderPadding),h:Math.floor(h.h*T[0]+2*yt.SafeBorderPadding)},A=new se({name:e,id:e,zIndex:l,pos:u,anchor:[.5,.5],size:[h.w,h.h],scale:p,rotate:y,translate:O}),I=new pe({...g,pos:[0,0]});if(A.appendChild(I),i){const b=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/T[0],1/T[1]]});A.appendChild(b)}if(this.replace(n,s||e,A),p||y||O){const b=A.getBoundingClientRect();return{x:Math.floor(b.x-yt.SafeBorderPadding),y:Math.floor(b.y-yt.SafeBorderPadding),w:Math.floor(b.width+2*yt.SafeBorderPadding),h:Math.floor(b.height+2*yt.SafeBorderPadding)}}return M}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var v,l;const{op:e,isFullWork:n,replaceId:i}=t,a=(v=this.workId)==null?void 0:v.toString();if(!a)return;const s=[];for(let p=0;p<e.length;p+=3)s.push([e[p],e[p+1],e[p+2]]);const o=n?this.fullLayer:this.drawLayer||this.fullLayer,f=this.draw({ps:s,workId:a,layer:o,isDrawing:!1,replaceId:i});return this.oldRect=f,(l=this.vNodes)==null||l.setInfo(a,{rect:f,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&yt.getCenterPos(f,o)}),f}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var T,c;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,fontColor:o,fontBgColor:f,bold:v,italic:l,lineThrough:p,underline:y,fontSize:O}=n,x=i.get(e.name);let m=e;if(e.tagName==="GROUP"&&(m=e.children[0]),a&&(m.setAttribute("strokeColor",a),(T=x==null?void 0:x.opt)!=null&&T.strokeColor&&(x.opt.strokeColor=a)),s&&(s==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",s),(c=x==null?void 0:x.opt)!=null&&c.fillColor&&(x.opt.fillColor=s)),x!=null&&x.opt.textOpt){const h=x.opt.textOpt;o&&h.fontColor&&(h.fontColor=o),f&&h.fontBgColor&&(h.fontBgColor=f),v&&(h.bold=v),l&&(h.italic=l),ce(p)&&(h.lineThrough=p),ce(y)&&(h.underline=y),O&&(h.fontSize=O)}return x&&i.setInfo(e.name,x),yt.updateNodeOpt(t)}}class zn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Star);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,vertices:v,innerVerticeStep:l,innerRatio:p,scale:y,rotate:O,translate:x}=this.workOptions,m=n.worldScaling,{rect:T,pos:c,points:h}=this.computDrawPoints(o,v,l,p),u={close:!0,points:h,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0,lineJoin:"round"},g={name:e,id:e,zIndex:f,pos:c,anchor:[.5,.5],size:[T.w,T.h],className:`${c[0]},${c[1]}`};y&&(g.scale=y),O&&(g.rotate=O),x&&(g.translate=x);const M=new se(g);if(i){const b=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/m[0],1/m[1]]});M.append(b)}const A=new pe({...u,pos:[0,0]});M.append(A),this.replace(n,e,M);const I=M.getBoundingClientRect();return{x:Math.floor(I.x-yt.SafeBorderPadding),y:Math.floor(I.y-yt.SafeBorderPadding),w:Math.floor(I.width+yt.SafeBorderPadding*2),h:Math.floor(I.height+yt.SafeBorderPadding*2)}}computDrawPoints(t,e,n,i){const a=wt(this.tmpPoints),s=[Math.floor(a.x+a.w/2),Math.floor(a.y+a.h/2)],o=Tn(a.w,a.h),f=Math.floor(Math.min(a.w,a.h)/2),v=i*f,l=[],p=2*Math.PI/e;for(let O=0;O<e;O++){const x=O*p-.5*Math.PI;let m,T;O%n===1?(m=v*o[0]*Math.cos(x),T=v*o[1]*Math.sin(x)):(m=f*o[0]*Math.cos(x),T=f*o[1]*Math.sin(x),l.push(m,T)),l.push(m,T)}return{rect:wt(this.tmpPoints,t),pos:s,points:l}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,vertices:f,innerVerticeStep:v,innerRatio:l}=n,p=i.get(e.name),y=p==null?void 0:p.opt;let O=e;return e.tagName==="GROUP"&&(O=e.children[0]),a&&(O.setAttribute("strokeColor",a),y!=null&&y.strokeColor&&(y.strokeColor=a)),s&&(s==="transparent"?O.setAttribute("fillColor","rgba(0,0,0,0)"):O.setAttribute("fillColor",s),y!=null&&y.fillColor&&(y.fillColor=s)),o===ht.Star&&(f&&(y.vertices=f),v&&(y.innerVerticeStep=v),l&&(y.innerRatio=l)),p&&i.setInfo(e.name,{...p,opt:y}),yt.updateNodeOpt(t)}}class Gn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Polygon);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,vertices:v,scale:l,rotate:p,translate:y}=this.workOptions,O=n.worldScaling,{rect:x,pos:m,points:T}=this.computDrawPoints(o,v),c={close:!0,points:T,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0,lineJoin:"round"},h={name:e,id:e,zIndex:f,pos:m,anchor:[.5,.5],size:[x.w,x.h]};l&&(h.scale=l),p&&(h.rotate=p),y&&(h.translate=y);const u=new se(h);if(i){const A=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/O[0],1/O[1]]});u.append(A)}const g=new pe({...c,pos:[0,0]});u.append(g),this.replace(n,e,u);const M=u.getBoundingClientRect();return{x:Math.floor(M.x-yt.SafeBorderPadding),y:Math.floor(M.y-yt.SafeBorderPadding),w:Math.floor(M.width+yt.SafeBorderPadding*2),h:Math.floor(M.height+yt.SafeBorderPadding*2)}}computDrawPoints(t,e){const n=wt(this.tmpPoints),i=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],a=Tn(n.w,n.h),s=Math.floor(Math.min(n.w,n.h)/2),o=[],f=2*Math.PI/e;for(let l=0;l<e;l++){const p=l*f-.5*Math.PI,y=s*a[0]*Math.cos(p),O=s*a[1]*Math.sin(p);o.push(y,O)}return{rect:wt(this.tmpPoints,t),pos:i,points:o}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,vertices:f}=n,v=i.get(e.name),l=v==null?void 0:v.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),a&&(p.setAttribute("strokeColor",a),l!=null&&l.strokeColor&&(l.strokeColor=a)),s&&(s==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",s),l!=null&&l.fillColor&&(l.fillColor=s)),o===ht.Polygon&&f&&(l.vertices=f),v&&i.setInfo(e.name,{...v,opt:l}),yt.updateNodeOpt(t)}}class _t{static bezier(r,t){const e=[];for(let n=0;n<t.length;n+=4){const i=t[n],a=t[n+1],s=t[n+2],o=t[n+3];i&&a&&s&&o?e.push(..._t.getBezierPoints(r,i,a,s,o)):i&&a&&s?e.push(..._t.getBezierPoints(r,i,a,s)):i&&a?e.push(..._t.getBezierPoints(r,i,a)):i&&e.push(i)}return e}static getBezierPoints(r=10,t,e,n,i){let a=null;const s=[];!n&&!i?a=_t.oneBezier:n&&!i?a=_t.twoBezier:n&&i&&(a=_t.threeBezier);for(let o=0;o<r;o++)a&&s.push(a(o/r,t,e,n,i));return i?s.push(i):n&&s.push(n),s}static oneBezier(r,t,e){const n=t.x+(e.x-t.x)*r,i=t.y+(e.y-t.y)*r;return new _(n,i)}static twoBezier(r,t,e,n){const i=(1-r)*(1-r)*t.x+2*r*(1-r)*e.x+r*r*n.x,a=(1-r)*(1-r)*t.y+2*r*(1-r)*e.y+r*r*n.y;return new _(i,a)}static threeBezier(r,t,e,n,i){const a=t.x*(1-r)*(1-r)*(1-r)+3*e.x*r*(1-r)*(1-r)+3*n.x*r*r*(1-r)+i.x*r*r*r,s=t.y*(1-r)*(1-r)*(1-r)+3*e.y*r*(1-r)*(1-r)+3*n.y*r*r*(1-r)+i.y*r*r*r;return new _(a,s)}}class Hn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.SpeechBalloon);nt(this,"ratio",.8);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,fillColor:a,thickness:s,zIndex:o,placement:f,scale:v,rotate:l,translate:p}=this.workOptions,{rect:y,pos:O,points:x}=this.computDrawPoints(s,f),m={points:x.map(g=>g.XY),lineWidth:s,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,className:`${O[0]},${O[1]}`,lineJoin:"round",close:!0},T={name:e,id:e,zIndex:o,pos:O,anchor:[.5,.5],size:[y.w,y.h]};v&&(T.scale=v),l&&(T.rotate=l),p&&(T.translate=p);const c=new se(T),h=new pe({...m,pos:[0,0]});c.append(h),this.replace(n,e,c);const u=c.getBoundingClientRect();return{x:Math.floor(u.x-yt.SafeBorderPadding),y:Math.floor(u.y-yt.SafeBorderPadding),w:Math.floor(u.width+yt.SafeBorderPadding*2),h:Math.floor(u.height+yt.SafeBorderPadding*2)}}transformControlPoints(t){const e=wt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const n=e.y+e.h*this.ratio;return[new _(e.x,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,n,0),new _(e.x,n,0)]}case"top":case"topLeft":case"topRight":{const n=e.y+e.h*(1-this.ratio);return[new _(e.x,n,0),new _(e.x+e.w,n,0),new _(e.x+e.w,e.y+e.h,0),new _(e.x,e.y+e.h,0)]}case"left":case"leftBottom":case"leftTop":{const n=e.x+e.w*(1-this.ratio);return[new _(n,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,e.y+e.h,0),new _(n,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const n=e.x+e.w*this.ratio;return[new _(e.x,e.y,0),new _(n,e.y,0),new _(n,e.y+e.h,0),new _(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const n=wt(this.tmpPoints),i=this.transformControlPoints(e),a=Math.floor(n.w*.1),s=Math.floor(n.h*.1),o=[],f=_.Add(i[0],new _(0,s,0)),v=_.Add(i[0],new _(a,0,0)),l=_t.getBezierPoints(10,f,i[0],v),p=_.Sub(i[1],new _(a,0,0)),y=_.Add(i[1],new _(0,s,0)),O=_t.getBezierPoints(10,p,i[1],y),x=_.Sub(i[2],new _(0,s,0)),m=_.Sub(i[2],new _(a,0,0)),T=_t.getBezierPoints(10,x,i[2],m),c=_.Add(i[3],new _(a,0,0)),h=_.Sub(i[3],new _(0,s,0)),u=_t.getBezierPoints(10,c,i[3],h),g=a*(1-this.ratio)*10,M=s*(1-this.ratio)*10;switch(e){case"bottom":{const b=_.Sub(i[2],new _(a*5-g/2,0,0)),E=_.Sub(i[2],new _(a*5,-M,0)),L=_.Sub(i[2],new _(a*5+g/2,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"bottomRight":{const b=_.Sub(i[2],new _(a*1.1,0,0)),E=_.Sub(i[2],new _(a*1.1+g/2,-M,0)),L=_.Sub(i[2],new _(a*1.1+g,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"bottomLeft":{const b=_.Add(i[3],new _(a*1.1+g,0,0)),E=_.Add(i[3],new _(a*1.1+g/2,M,0)),L=_.Add(i[3],new _(a*1.1,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"top":{const b=_.Sub(i[1],new _(a*5-g/2,0,0)),E=_.Sub(i[1],new _(a*5,M,0)),L=_.Sub(i[1],new _(a*5+g/2,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"topRight":{const b=_.Sub(i[1],new _(a*1.1,0,0)),E=_.Sub(i[1],new _(a*1.1+g/2,M,0)),L=_.Sub(i[1],new _(a*1.1+g,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"topLeft":{const b=_.Add(i[0],new _(a*1.1+g,0,0)),E=_.Add(i[0],new _(a*1.1+g/2,-M,0)),L=_.Add(i[0],new _(a*1.1,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"left":{const b=_.Add(i[0],new _(0,s*5-M/2,0)),E=_.Add(i[0],new _(-g,s*5,0)),L=_.Add(i[0],new _(0,s*5+M/2,0));o.push(E,b,...l,...O,...T,...u,L);break}case"leftTop":{const b=_.Add(i[0],new _(0,s*1.1,0)),E=_.Add(i[0],new _(-g,s*1.1+M/2,0)),L=_.Add(i[0],new _(0,s*1.1+M,0));o.push(E,b,...l,...O,...T,...u,L);break}case"leftBottom":{const b=_.Sub(i[3],new _(0,s*1.1+M,0)),E=_.Sub(i[3],new _(g,s*1.1+M/2,0)),L=_.Sub(i[3],new _(0,s*1.1,0));o.push(E,b,...l,...O,...T,...u,L);break}case"right":{const b=_.Add(i[1],new _(0,s*5-M/2,0)),E=_.Add(i[1],new _(g,s*5,0)),L=_.Add(i[1],new _(0,s*5+M/2,0));o.push(E,L,...T,...u,...l,...O,b);break}case"rightTop":{const b=_.Add(i[1],new _(0,s*1.1,0)),E=_.Add(i[1],new _(g,s*1.1+M/2,0)),L=_.Add(i[1],new _(0,s*1.1+M,0));o.push(E,L,...T,...u,...l,...O,b);break}case"rightBottom":{const b=_.Sub(i[2],new _(0,s*1.1+M,0)),E=_.Sub(i[2],new _(-g,s*1.1+M/2,0)),L=_.Sub(i[2],new _(0,s*1.1,0));o.push(E,L,...T,...u,...l,...O,b);break}}const A=wt(this.tmpPoints,t),I=[Math.floor(A.x+A.w/2),Math.floor(A.y+A.h/2)];return{rect:A,pos:I,points:o}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,placement:f}=n,v=i.get(e.name),l=v==null?void 0:v.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),a&&(p.setAttribute("strokeColor",a),l!=null&&l.strokeColor&&(l.strokeColor=a)),s&&(s==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",s),l!=null&&l.fillColor&&(l.fillColor=s)),o===ht.SpeechBalloon&&f&&(l.placement=f),v&&i.setInfo(e.name,{...v,opt:l}),yt.updateNodeOpt(t)}}class Le extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Image);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=Le.getScaleType(this.workOptions)}consume(){return{type:ct.None}}consumeAll(){return{type:ct.None}}draw(t){const{layer:e,workId:n,replaceId:i,imageBitmap:a,isMainThread:s}=t,{centerX:o,centerY:f,width:v,height:l,rotate:p,zIndex:y}=this.workOptions,O={anchor:[.5,.5],pos:[o,f],name:n,size:[v,l],zIndex:y,rotate:!s&&180+(p||0)||p,texture:a},x=new Vh(O);this.replace(e,i||n,x);const m=x.getBoundingClientRect();if(m)return{x:Math.floor(m.x-yt.SafeBorderPadding),y:Math.floor(m.y-yt.SafeBorderPadding),w:Math.floor(m.width+yt.SafeBorderPadding*2),h:Math.floor(m.height+yt.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var l,p,y,O;const{isFullWork:e,replaceId:n,scene:i,isMainThread:a}=t,{src:s,uuid:o}=this.workOptions,f=((l=this.workId)==null?void 0:l.toString())||o,v=e?this.fullLayer:this.drawLayer||this.fullLayer;if(s){const x=await i.preload({id:o,src:this.workOptions.src}),m=this.draw({workId:f,layer:v,replaceId:n,imageBitmap:x[0],isMainThread:a});return this.oldRect=f&&((y=(p=this.vNodes)==null?void 0:p.get(f))==null?void 0:y.rect)||void 0,(O=this.vNodes)==null||O.setInfo(f,{rect:m,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&yt.getCenterPos(m,v)}),m}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:n}=t;return e!==!1||n&&Math.abs(n)%90>0?jt.proportional:jt.all}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i,targetNode:a}=t,{translate:s,box:o,boxScale:f,boxTranslate:v,angle:l,isLocked:p,zIndex:y}=n,O=a&&Jt(a)||i.get(e.name);if(!O)return;const x=e.parent;if(x){if(Qt(y)&&(e.setAttribute("zIndex",y),O.opt.zIndex=y),ce(p)&&(O.opt.locked=p),o&&v&&f){const{centerX:m,centerY:T,width:c,height:h,uniformScale:u,rotate:g}=O.opt,M=Math.min(f[0],f[1]),A=u!==!1?[M,M]:f,I=yn({x:m-c/2,y:T-h/2,w:c,h},g||0),b=Lh(I,new _(m,T),A),E=bh(b,new _(m,T),-(g||0)),L=wt(E);O.opt.width=Math.round(L.w),O.opt.height=Math.round(L.h);const D=[v[0]/x.worldScaling[0],v[1]/x.worldScaling[1]];O.opt.centerX=m+D[0],O.opt.centerY=T+D[1];const R=[O.centerPos[0]+D[0],O.centerPos[1]+D[1]];if(O.centerPos=R,a){let C=xn(O.rect,f);C=Re(C,D),O.rect=C}}else if(s){const m=[s[0]/x.worldScaling[0],s[1]/x.worldScaling[1]];if(O.opt.centerX=O.opt.centerX+m[0],O.opt.centerY=O.opt.centerY+m[1],O.centerPos=[O.centerPos[0]+m[0],O.centerPos[1]+m[1]],a){const T=Re(O.rect,m);O.rect=T}}else if(Qt(l)&&(O.opt.rotate=l,O.scaleType=Le.getScaleType(O.opt),a)){const m=Sn(O.rect,l);O.rect=m}return O&&i.setInfo(e.name,O),O==null?void 0:O.rect}}}class Kn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.both);nt(this,"toolsType",ht.Straight);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"straightTipWidth");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,thickness:a,zIndex:s,scale:o,rotate:f,translate:v}=this.workOptions,l=n.worldPosition,p=n.worldScaling,{d:y,rect:O}=this.computDrawPoints(a),x=[O.x+O.w/2,O.y+O.h/2],m={pos:x,name:e,id:e,d:y,fillColor:i,strokeColor:i,lineWidth:0,className:`${x[0]},${x[1]}`,normalize:!0,zIndex:s};o&&(m.scale=o),f&&(m.rotate=f),v&&(m.translate=v);const T=new ge(m);if(this.replace(n,e,T),f||o||v){const h=T.getBoundingClientRect();return{x:Math.floor(h.x-yt.SafeBorderPadding),y:Math.floor(h.y-yt.SafeBorderPadding),w:Math.floor(h.width+yt.SafeBorderPadding*2),h:Math.floor(h.height+yt.SafeBorderPadding*2)}}return{x:Math.floor(O.x*p[0]+l[0]-yt.SafeBorderPadding),y:Math.floor(O.y*p[1]+l[1]-yt.SafeBorderPadding),w:Math.floor(O.w*p[0]+2*yt.SafeBorderPadding),h:Math.floor(O.h*p[1]+2*yt.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t):this.computDotPoints(t)}computFullPoints(t){const e=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=_.Per(e).mul(t/2),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=xt.Sub(this.tmpPoints[1],n),o=xt.Add(this.tmpPoints[1],n),f=xt.GetSemicircleStroke(this.tmpPoints[1],s,-1,8),v=xt.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),l=[i,s,...f,o,a,...v];return{d:Oe(l,!0),rect:wt(l),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=xt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:Oe(e,!0),rect:wt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a)),s&&i.setInfo(e.name,s),yt.updateNodeOpt(t)}}class be extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Text);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:ct.None}}consumeAll(){return{type:ct.None}}consumeService(){}async draw(t){const{workId:e,layer:n,isDrawLabel:i}=t,{boxSize:a,boxPoint:s,zIndex:o}=this.workOptions,f=n.worldPosition,v=n.worldScaling;if(!s||!a)return;const l={name:e,id:e,pos:[s[0]+a[0]/2,s[1]+a[1]/2],anchor:[.5,.5],size:a,zIndex:o},p=new se(l),y={x:s[0],y:s[1],w:a[0],h:a[1]},O=new hr({normalize:!0,pos:[0,0],size:a}),x=i&&be.createLabels(this.workOptions,n)||[];return p.append(...x,O),this.replace(n,e,p),i&&(await new Promise(m=>{setTimeout(m,0)}),this.updateLabelsWidth(p)),{x:Math.floor(y.x*v[0]+f[0]),y:Math.floor(y.y*v[1]+f[1]),w:Math.floor(y.w*v[0]),h:Math.floor(y.h*v[1])}}async consumeServiceAsync(t){var f,v,l,p;const e=(f=this.workId)==null?void 0:f.toString();if(!e)return;const{isFullWork:n,replaceId:i,isDrawLabel:a}=t;this.oldRect=i&&((l=(v=this.vNodes)==null?void 0:v.get(i))==null?void 0:l.rect)||void 0;const s=n?this.fullLayer:this.drawLayer||this.fullLayer,o=await this.draw({workId:e,layer:s,isDrawLabel:a||this.workOptions.workState===Rt.Done});return(p=this.vNodes)==null||p.setInfo(e,{rect:o,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&yt.getCenterPos(o,s)}),o}updateLabelsWidth(t){t.children.forEach(e=>{if(e.tagName==="LABEL"){const n=e.name,{width:i}=e.getBoundingClientRect(),[a]=t.worldScaling,{underline:s,lineThrough:o}=this.getWorkOptions();s&&t.getElementsByName(`${n}_underline`)[0].attr({points:[0,0,i/a,0]}),o&&t.getElementsByName(`${n}_lineThrough`)[0].attr({points:[0,0,i/a,0]})}})}updataOptService(){}async updataOptServiceAsync(t){var y,O;if(!this.workId)return;const e=this.workId.toString(),{fontColor:n,fontBgColor:i,bold:a,italic:s,lineThrough:o,underline:f,zIndex:v}=t,l=(y=this.vNodes)==null?void 0:y.get(e);if(!l)return;n&&(l.opt.fontColor=n),i&&(l.opt.fontBgColor=i),a&&(l.opt.bold=a),s&&(l.opt.italic=s),ce(o)&&(l.opt.lineThrough=o),ce(f)&&(l.opt.underline=f),i&&(l.opt.fontBgColor=i),Qt(v)&&(l.opt.zIndex=v),this.oldRect=l.rect;const p=await this.draw({workId:e,layer:this.fullLayer,isDrawLabel:this.workOptions.workState===Rt.Done});return(O=this.vNodes)==null||O.setInfo(e,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&yt.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getFontWidth(t){const{ctx:e,opt:n,text:i}=t,{bold:a,italic:s,fontSize:o,fontFamily:f}=n;return e.font=`${a} ${s} ${o}px ${f}`,e.measureText(i).width}static createLabels(t,e){const n=[],i=t.text.split(","),a=i.length;for(let s=0;s<a;s++){const o=i[s],{fontSize:f,lineHeight:v,bold:l,textAlign:p,italic:y,boxSize:O,fontFamily:x,verticalAlign:m,fontColor:T,underline:c,lineThrough:h}=t,u=v||f*1.2,g=e&&e.parent.canvas.getContext("2d"),M=g&&be.getFontWidth({text:o,opt:t,ctx:g,worldScaling:e.worldScaling});if(M){const A={anchor:[0,.5],text:o,fontSize:f,lineHeight:u,fontFamily:x,fontWeight:l,fillColor:T,textAlign:p,fontStyle:y,name:s.toString(),className:"label"},I=[0,0];if(m==="middle"){const E=(a-1)/2;I[1]=(s-E)*u}if(p==="left"){const E=O&&-O[0]/2||0;I[0]=y==="italic"&&E||E+5,console.log("text-left",I)}A.pos=I;const b=new Hh(A);if(n.push(b),c){const E={normalize:!1,pos:[A.pos[0],A.pos[1]+f/2],lineWidth:2*Math.floor(f/20),points:[0,0,M,0],strokeColor:T,name:`${s}_underline`,className:"underline"},L=new pe(E);n.push(L)}if(h){const E={normalize:!1,pos:A.pos,lineWidth:2*Math.floor(f/20),points:[0,0,M,0],strokeColor:T,name:`${s}_lineThrough`,className:"lineThrough"},L=new pe(E);n.push(L)}}}return n}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i,targetNode:a}=t,{fontBgColor:s,fontColor:o,translate:f,box:v,boxScale:l,boxTranslate:p,bold:y,italic:O,lineThrough:x,underline:m,fontSize:T,textInfos:c,zIndex:h}=n,u=a&&Jt(a)||i.get(e.name);if(!u)return;const g=e.parent;if(!g)return;const M=u.opt;if(Qt(h)&&(e.setAttribute("zIndex",h),u.opt.zIndex=h),o&&M.fontColor&&(M.fontColor=o,e.children.forEach(A=>{A.tagName==="LABEL"?A.setAttribute("fillColor",o):A.tagName==="POLYLINE"&&A.setAttribute("strokeColor",o)})),s&&M.fontBgColor&&(M.fontBgColor=s),y&&(M.bold=y),O&&(M.italic=O),ce(x)&&(M.lineThrough=x),ce(m)&&(M.underline=m),T&&(M.fontSize=T),v&&p&&l){const A=c==null?void 0:c.get(e.name);if(A){const{fontSize:E,boxSize:L}=A;M.boxSize=L||M.boxSize,M.fontSize=E||M.fontSize}const I=u.rect,b=Re(xn(I,l),p);M.boxPoint=b&&[(b.x-g.worldPosition[0])/g.worldScaling[0],(b.y-g.worldPosition[1])/g.worldScaling[1]]}else if(f&&M.boxPoint){const A=[f[0]/g.worldScaling[0],f[1]/g.worldScaling[1]];M.boxPoint=[M.boxPoint[0]+A[0],M.boxPoint[1]+A[1]],u.centerPos=[u.centerPos[0]+A[0],u.centerPos[1]+A[1]],u.rect=Re(u.rect,A)}return u&&i.setInfo(e.name,u),u==null?void 0:u.rect}static getRectFromLayer(t,e){const n=t.getElementsByName(e)[0];if(n){const i=n.getBoundingClientRect();return{x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width),h:Math.floor(i.height)}}}}function Vn(d){switch(d){case ht.Arrow:return jn;case ht.Pencil:return On;case ht.Straight:return Kn;case ht.Ellipse:return Un;case ht.Polygon:case ht.Triangle:return Gn;case ht.Star:case ht.Rhombus:return zn;case ht.Rectangle:return $n;case ht.SpeechBalloon:return Hn;case ht.Text:return be;case ht.LaserPen:return En;case ht.Eraser:return ae;case ht.Selector:return Nt;case ht.Image:return Le}}function yr(d,r){const{toolsType:t,...e}=d;switch(t){case ht.Arrow:return new jn(e);case ht.Pencil:return new On(e);case ht.Straight:return new Kn(e);case ht.Ellipse:return new Un(e);case ht.Polygon:case ht.Triangle:return new Gn(e);case ht.Star:case ht.Rhombus:return new zn(e);case ht.Rectangle:return new $n(e);case ht.SpeechBalloon:return new Hn(e);case ht.Text:return new be(e);case ht.LaserPen:return new En(e);case ht.Eraser:return new ae(e,r);case ht.Selector:return e.vNodes?new Nt({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case ht.Image:return new Le(e);default:return}}function Yn(d){const r=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE"];for(const e of d){if(e.tagName==="GROUP"&&e.children.length)return Yn(e.children);e.tagName&&t.includes(e.tagName)&&r.push(e)}return r}class l0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetColorNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s,textUpdateForWoker:o}=e,f=n.render||[],v=n.sp||[];if(a)for(const[l,p]of i.entries())o&&p.toolsType===ht.Text?v.push({...p,workId:l,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):v.push({...p,workId:l,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:f,sp:v}}}class c0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.ZIndexNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s}=e,o=n.render||[],f=n.sp||[];if(a&&f)for(const[v,l]of i.entries())f.push({...l,workId:v,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:o,sp:f}}}class f0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.TranslateNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var v,l;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,emitEventType:f}=t;e===Nt.selectorId&&n&&(n.workState===Rt.Done&&(n!=null&&n.translate)&&(n.translate[0]||n.translate[1])||n.workState!==Rt.Done?await((v=this.localWork)==null?void 0:v.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,isSync:!0,textUpdateForWoker:o,emitEventType:f,scene:this.scene,callback:this.updateSelectorCallback})):n.workState===Rt.Done&&((l=this.localWork)==null||l.vNodes.deleteLastTarget()))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v,textUpdateForWoker:l}=e,p=v.workState,y=n.render||[],O=n.sp||[];if(p===Rt.Start)return{sp:[],render:[]};const x=s==null?void 0:s.selectRect;if(o){p===Rt.Doing&&O.push({type:ct.Select,selectIds:a.selectIds,selectRect:x,willSyncService:!0,isSync:!0,points:a.getChildrenPoints(),textOpt:a.textOpt});for(const[m,T]of i.entries())l&&T.toolsType===ht.Text?O.push({...T,workId:m,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):O.push({...T,workId:m,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f})}return{render:y,sp:O}}}class u0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.DeleteNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.RemoveNode){if(n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0;if(n===Tt.Service&&i===this.emitEventType)return this.consumeForServiceWorker(t),!0}}consumeForLocalWorker(t){if(!this.localWork)return;const{removeIds:e,willRefresh:n,willSyncService:i,viewId:a}=t;if(!(e!=null&&e.length))return;let s;const o=[],f=[],v=[];for(const l of e){if(l===Nt.selectorId){const y=this.localWork.workShapes.get(Nt.selectorId);if(!y)return;const O=y.selectIds&&[...y.selectIds]||[];for(const m of O){if(this.localWork.vNodes.get(m)){const c=this.commandDeleteText(m);c&&o.push(c)}s=Ot(s,this.localWork.removeNode(m)),v.push(m)}const x=y==null?void 0:y.updateSelectIds([]);s=Ot(s,x.bgRect),this.localWork.clearWorkShapeNodeCache(Nt.selectorId),this.localWork.workShapes.delete(Nt.selectorId),o.push({type:ct.Select,selectIds:[],willSyncService:i});continue}const p=this.commandDeleteText(l);p&&o.push(p),s=Ot(s,this.localWork.removeNode(l)),v.push(l)}i&&o.push({type:ct.RemoveNode,removeIds:v}),s&&n&&f.push({rect:Bt(s),clearCanvas:Mt.Bg,isClear:!0,viewId:a},{rect:Bt(s),drawCanvas:Mt.Bg,viewId:a}),(f.length||o.length)&&this.localWork._post({render:f,sp:o})}consumeForServiceWorker(t){this.serviceWork&&this.serviceWork.removeSelectWork(t)}commandDeleteText(t){var n;const e=(n=this.localWork)==null?void 0:n.vNodes.get(t);if(e&&e.toolsType===ht.Text)return{type:ct.TextUpdate,toolsType:ht.Text,workId:t,dataType:Tt.Local}}}class h0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.ScaleNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var s;const{workId:e,updateNodeOpt:n,willSyncService:i,willSerializeData:a}=t;e===Nt.selectorId&&n&&await((s=this.localWork)==null?void 0:s.updateSelector({updateSelectorOpt:n,willSyncService:i,willSerializeData:a,isSync:!0,scene:this.scene,callback:this.updateSelectorCallback.bind(this)}))}updateSelectorCallback(t){const{param:e,postData:n,workShapeNode:i,res:a,newServiceStore:s}=t,{updateSelectorOpt:o,willSyncService:f,willSerializeData:v}=e,l=o.workState,p=n.render||[],y=n.sp||[],O=a==null?void 0:a.selectRect;if(l===Rt.Start)return{sp:[],render:[]};if(f){l===Rt.Doing&&y.push({type:ct.Select,selectIds:i.selectIds,selectRect:O,willSyncService:!0,isSync:!0,points:i.getChildrenPoints(),textOpt:i.textOpt}),v&&l===Rt.Done&&y.push({type:ct.Select,selectIds:i.selectIds,selectRect:O,willSyncService:!1,isSync:!0,points:i.getChildrenPoints(),textOpt:i.textOpt});for(const[x,m]of s.entries())m.toolsType===ht.Text?y.push({...m,workId:x,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):y.push({...m,workId:x,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:!0})}return{render:p,sp:y}}}class d0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.RotateNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,emitEventType:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,emitEventType:o,isSync:!0,scene:this.scene,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,workShapeNode:i,res:a,newServiceStore:s}=t,{updateSelectorOpt:o,willSyncService:f,willSerializeData:v,isSync:l}=e,p=o.workState,y=n.render||[],O=n.sp||[],x=a==null?void 0:a.selectRect;if(f){v&&p===Rt.Done&&O.push({type:ct.Select,selectIds:i.selectIds,selectRect:x,willSyncService:!0,isSync:l,points:i.getChildrenPoints(),textOpt:i.textOpt,selectorColor:i.selectorColor,strokeColor:i.strokeColor,fillColor:i.fillColor,canTextEdit:i.canTextEdit,canRotate:i.canRotate,scaleType:i.scaleType,opt:i.getWorkOptions()||void 0,canLock:i.canLock,isLocked:i.isLocked,toolsTypes:i.toolsTypes,shapeOpt:i.shapeOpt});for(const[m,T]of s.entries())O.push({...T,workId:m,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:l})}return{render:y,sp:O}}}class g0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetFontStyle)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v,textUpdateForWoker:l}=e,p=n.render||[],y=n.sp||[],O=s==null?void 0:s.selectRect;if(o&&y){v.fontSize&&y.push({type:ct.Select,selectIds:a.selectIds,selectRect:O,willSyncService:o,isSync:f,points:a.getChildrenPoints()});for(const[x,m]of i.entries())l&&m.toolsType===ht.Text?y.push({...m,workId:x,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):y.push({...m,workId:x,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f})}return{render:p,sp:y}}}class p0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetPoint)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,emitEventType:this.emitEventType,willSerializeData:s,isSync:!0,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f}=e,v=n.render||[],l=n.sp||[],p=s==null?void 0:s.selectRect;if(o&&l){for(const[y,O]of i.entries())l.push({...O,workId:y,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f});l.push({type:ct.Select,selectIds:a.selectIds,selectRect:p,willSyncService:o,isSync:f,points:a.getChildrenPoints()})}return{render:v,sp:l}}}class v0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetLock)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v}=e,l=n.render||[],p=n.sp||[],y=s==null?void 0:s.selectRect;if(o&&p){for(const[O,x]of i.entries())p.push({...x,workId:O,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f});p.push({isLocked:v.isLocked,selectorColor:a.selectorColor,scaleType:a.scaleType,canRotate:a.canRotate,type:ct.Select,selectIds:a.selectIds,selectRect:y,willSyncService:o,isSync:f})}return{render:l,sp:p}}}class m0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetShapeOpt)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s}=e,o=n.render||[],f=n.sp||[];if(a&&f)for(const[v,l]of i.entries())f.push({...l,workId:v,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:o,sp:f}}}class y0{constructor(r){nt(this,"builders",new Map);this.builders=new Map(r.map(t=>[t,this.build(t)]))}build(r){switch(r){case Lt.TranslateNode:return new f0;case Lt.ZIndexNode:return new c0;case Lt.CopyNode:return new Ch;case Lt.SetColorNode:return new l0;case Lt.DeleteNode:return new u0;case Lt.ScaleNode:return new h0;case Lt.RotateNode:return new d0;case Lt.SetFontStyle:return new g0;case Lt.SetPoint:return new p0;case Lt.SetLock:return new v0;case Lt.SetShapeOpt:return new m0}}registerForWorker(r,t,e){return this.builders.forEach(n=>{n&&n.registerForWorker(r,t,e)}),this}consumeForWorker(r){for(const t of this.builders.values())if(t!=null&&t.consume(r))return!0;return!1}}const Sr="cursorhover";class S0{constructor(r,t){nt(this,"viewId");nt(this,"scene");nt(this,"scenePath");nt(this,"fullLayer");nt(this,"curNodeMap",new Map);nt(this,"targetNodeMap",[]);this.viewId=r,this.scene=t}init(r){this.fullLayer=r}get(r){return this.curNodeMap.get(r)}hasRenderNodes(){let r=!1;for(const t of this.curNodeMap.values())Bh(t)&&(r=!0);return r}has(r){this.curNodeMap.has(r)}setInfo(r,t){const e=this.curNodeMap.get(r)||{name:r,rect:t.rect};t.rect&&(e.rect=Jt(t.rect)),t.op&&(e.op=Jt(t.op)),t.canRotate&&(e.canRotate=t.canRotate),t.scaleType&&(e.scaleType=t.scaleType),t.opt&&(e.opt=Jt(t.opt)),t.toolsType&&(e.toolsType=t.toolsType),t.centerPos&&(e.centerPos=Jt(t.centerPos)),ce(t.isSelected)&&(e.isSelected=t.isSelected),e.rect?this.curNodeMap.set(r,e):this.curNodeMap.delete(r)}selected(r){this.setInfo(r,{isSelected:!0})}unSelected(r){this.setInfo(r,{isSelected:!1})}delete(r){this.curNodeMap.delete(r)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}hasRectIntersectRange(r,t=!0){for(const e of this.curNodeMap.values())if(Ce(r,e.rect)){if(t&&e.toolsType===ht.Image&&e.opt.locked||t&&e.toolsType===ht.Text&&(e.opt.workState===Rt.Doing||e.opt.workState===Rt.Start))continue;return!0}return!1}getRectIntersectRange(r,t=!0){let e;const n=new Map;for(const[i,a]of this.curNodeMap.entries())if(Ce(r,a.rect)){if(t&&a.toolsType===ht.Image&&a.opt.locked||t&&a.toolsType===ht.Text&&(a.opt.workState===Rt.Doing||a.opt.workState===Rt.Start))continue;e=Ot(e,a.rect),n.set(i,a)}return{rectRange:e,nodeRange:n}}getNodeRectFormShape(r,t){const e=Vn(t.toolsType);return this.fullLayer&&(e==null?void 0:e.getRectFromLayer(this.fullLayer,r))}updateNodesRect(){this.curNodeMap.forEach((r,t)=>{const e=this.getNodeRectFormShape(t,r);e?(r.rect=e,this.curNodeMap.set(t,r)):this.curNodeMap.delete(t)})}combineIntersectRect(r){let t=r;return this.curNodeMap.forEach(e=>{Ce(t,e.rect)&&(t=Ot(t,e.rect))}),t}setTarget(){return this.targetNodeMap.push(Jt(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length=this.targetNodeMap.length-1}getTarget(r){return this.targetNodeMap[r]}deleteTarget(r){this.targetNodeMap.length=r}}class Xn{constructor(r,t){nt(this,"viewId");nt(this,"fullLayer");nt(this,"vNodes");nt(this,"dpr");nt(this,"opt");nt(this,"cameraOpt");nt(this,"scene");nt(this,"isSafari",!1);nt(this,"combinePostMsg",new Set);nt(this,"workerTaskId");this.viewId=r,this.opt=t,this.dpr=t.dpr,this.scene=this.createScene(t.offscreenCanvasOpt),this.fullLayer=this.createLayer("fullLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.vNodes=new S0(r,this.scene)}setIsSafari(r){this.isSafari=r}async on(r,t){const{msgType:e,toolsType:n,opt:i,workId:a,workState:s,dataType:o}=r;switch(Qt(t)&&this.post({workerTasksqueueCount:t}),e){case ct.Destroy:this.destroy();break;case ct.Clear:this.clearAll();break;case ct.UpdateTools:if(n&&i){const f={toolsType:n,toolsOpt:i};this.localWork.setToolsOpt(f)}break;case ct.CreateWork:a&&i&&(!this.localWork.getTmpWorkShapeNode()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:i}),this.setWorkOpt({workId:a,toolsOpt:i}));break;case ct.DrawWork:s===Rt.Done&&o===Tt.Local?this.consumeDrawAll(o,r):this.consumeDraw(o,r);break}}updateScene(r){this.scene.attr({...r});const{width:t,height:e}=r;this.scene.container.width=t,this.scene.container.height=e,this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(r){const{width:t,height:e}=r;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",t),this.fullLayer.parent.setAttribute("height",e),this.fullLayer.setAttribute("size",[t,e]),this.fullLayer.setAttribute("pos",[t*.5,e*.5]))}createScene(r){const{width:t,height:e}=r,n=new OffscreenCanvas(t,e);return new Kh({container:n,displayRatio:this.dpr,depth:!1,desynchronized:!0,...r})}createLayer(r,t,e){const{width:n,height:i}=e,a=`offscreen-${r}`,s=t.layer(a,e),o=new se({anchor:[.5,.5],pos:[n*.5,i*.5],size:[n,i],name:"viewport",id:r});return s.append(o),o}clearAll(){var r;this.fullLayer&&(this.fullLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.fullLayer.removeAllChildren()),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy()}setToolsOpt(r){this.localWork.setToolsOpt(r)}setWorkOpt(r){const{workId:t,toolsOpt:e}=r;t&&e&&this.localWork.setWorkOptions(t,e)}destroy(){var r;this.vNodes.clear(),this.fullLayer.remove(),this.scene.remove(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy()}post(r){this.combinePostMsg.add(r),this.runBatchPostData()}runBatchPostData(){this.workerTaskId||(this.workerTaskId=requestAnimationFrame(this.combinePost.bind(this)))}combinePostData(){var a,s;this.workerTaskId=void 0;const r=[],t=[];let e,n;const i=new Set;for(const o of this.combinePostMsg.values()){if((a=o.render)!=null&&a.length)for(const f of o.render){let v=!1;if(f.workId&&i.add(f.workId),f.isClearAll&&(f.rect=this.getSceneRect(),f.isClear=!0,delete f.isClearAll),f.drawCanvas){const l=this.getLayer(f.drawCanvas);if(!l)continue;if(l.parent.render(),f.isDrawAll){const p=this.getSceneRect(),{rectRange:y}=this.vNodes.getRectIntersectRange(p,!1);f.rect=y,delete f.isDrawAll}}for(const l of r)if(f.viewId===l.viewId){f.isClear&&l.clearCanvas&&l.isClear&&l.clearCanvas===f.clearCanvas&&(l.rect=Ot(l.rect,f.rect),v=!0),l.drawCanvas&&l.drawCanvas===f.drawCanvas&&(l.rect=Ot(l.rect,f.rect),v=!0);continue}if(!v)if(f.isClear&&!f.drawCanvas){const l=r.find(p=>p.drawCanvas===f.clearCanvas&&le(p.rect,f.rect));l!=null&&l.rect&&(l.rect=Bt(l.rect,2)),r.unshift(f)}else f.drawCanvas&&!f.clearCanvas&&f.rect&&r.find(l=>l.isClear&&l.clearCanvas===f.drawCanvas&&le(l.rect,f.rect))&&(f.rect=Bt(f.rect,2)),r.push(f)}if((s=o.sp)!=null&&s.length)for(const f of o.sp){let v=!1;for(const l of t)if(le(f,l)){v=!0;break}v||t.push(f)}Qt(o.drawCount)&&(e=o.drawCount),Qt(o.workerTasksqueueCount)&&(n=o.workerTasksqueueCount)}return this.combinePostMsg.clear(),{render:r,sp:t,drawCount:e,workerTasksqueueCount:n,workIds:i}}safariFixRect(r){if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;const t=this.scene.width,e=this.scene.height,n={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(t,r.w)),h:Math.floor(Math.min(e,r.h))};return n.x+n.w>t&&(n.w=Math.floor(t-n.x)),n.y+n.h>e&&(n.h=Math.floor(e-n.y)),n}getSceneRect(){const{width:r,height:t}=this.scene;return{x:0,y:0,w:Math.floor(r),h:Math.floor(t)}}}class Jn{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"thread");nt(this,"fullLayer");nt(this,"drawLayer");nt(this,"_post");nt(this,"tmpWorkShapeNode");nt(this,"tmpOpt");nt(this,"workShapes",new Map);nt(this,"workShapeState",new Map);nt(this,"effectWorkId");nt(this,"drawCount",0);this.thread=r.thread,this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this._post=this.thread.post.bind(r.thread)}destroy(){this.workShapeState.clear(),this.workShapes.clear()}getWorkShape(r){return this.workShapes.get(r)}getTmpWorkShapeNode(){return this.tmpWorkShapeNode}setTmpWorkId(r){if(r&&this.tmpWorkShapeNode){this.tmpWorkShapeNode.setWorkId(r),this.workShapes.set(r,this.tmpWorkShapeNode),this.tmpOpt&&this.setToolsOpt(this.tmpOpt);return}}setWorkOptions(r,t){var n;this.workShapes.get(r)||this.setTmpWorkId(r),(n=this.workShapes.get(r))==null||n.setWorkOptions(t)}createWorkShapeNode(r){var t;return yr({...r,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(t=this.thread)==null?void 0:t.serviceWork)}setToolsOpt(r){var t,e;((t=this.tmpOpt)==null?void 0:t.toolsType)!==r.toolsType&&(e=this.tmpOpt)!=null&&e.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=r,this.tmpWorkShapeNode=this.createWorkShapeNode(r)}clearWorkShapeNodeCache(r){var t;(t=this.getWorkShape(r))==null||t.clearTmpPoints(),this.workShapes.delete(r),this.workShapeState.delete(r)}clearAllWorkShapesCache(){this.workShapes.forEach(r=>r.clearTmpPoints()),this.workShapes.clear(),this.workShapeState.clear()}setFullWork(r){const{workId:t,opt:e,toolsType:n}=r;if(t&&e&&n){const i=t&&this.workShapes.get(t)||this.createWorkShapeNode({toolsOpt:e,toolsType:n,workId:t});return i?(i.setWorkId(t),this.workShapes.set(t,i),i):void 0}}}var x0=Zt,T0=function(){return x0.Date.now()},M0=T0,O0=/\s/;function E0(d){for(var r=d.length;r--&&O0.test(d.charAt(r)););return r}var P0=E0,A0=P0,C0=/^\s+/;function R0(d){return d&&d.slice(0,A0(d)+1).replace(C0,"")}var I0=R0,L0=ue,b0=ie,D0="[object Symbol]";function w0(d){return typeof d=="symbol"||b0(d)&&L0(d)==D0}var N0=w0,W0=I0,Qn=oe,B0=N0,Zn=NaN,F0=/^[-+]0x[0-9a-f]+$/i,j0=/^0b[01]+$/i,U0=/^0o[0-7]+$/i,$0=parseInt;function z0(d){if(typeof d=="number")return d;if(B0(d))return Zn;if(Qn(d)){var r=typeof d.valueOf=="function"?d.valueOf():d;d=Qn(r)?r+"":r}if(typeof d!="string")return d===0?d:+d;d=W0(d);var t=j0.test(d);return t||U0.test(d)?$0(d.slice(2),t?2:8):F0.test(d)?Zn:+d}var G0=z0,H0=oe,xr=M0,kn=G0,K0="Expected a function",V0=Math.max,Y0=Math.min;function X0(d,r,t){var e,n,i,a,s,o,f=0,v=!1,l=!1,p=!0;if(typeof d!="function")throw new TypeError(K0);r=kn(r)||0,H0(t)&&(v=!!t.leading,l="maxWait"in t,i=l?V0(kn(t.maxWait)||0,r):i,p="trailing"in t?!!t.trailing:p);function y(M){var A=e,I=n;return e=n=void 0,f=M,a=d.apply(I,A),a}function O(M){return f=M,s=setTimeout(T,r),v?y(M):a}function x(M){var A=M-o,I=M-f,b=r-A;return l?Y0(b,i-I):b}function m(M){var A=M-o,I=M-f;return o===void 0||A>=r||A<0||l&&I>=i}function T(){var M=xr();if(m(M))return c(M);s=setTimeout(T,x(M))}function c(M){return s=void 0,p&&e?y(M):(e=n=void 0,a)}function h(){s!==void 0&&clearTimeout(s),f=0,e=o=n=s=void 0}function u(){return s===void 0?a:c(xr())}function g(){var M=xr(),A=m(M);if(e=arguments,n=this,o=M,A){if(s===void 0)return O(o);if(l)return clearTimeout(s),s=setTimeout(T,r),y(o)}return s===void 0&&(s=setTimeout(T,r)),a}return g.cancel=h,g.flush=u,g}var J0=X0,Q0=J0,Z0=oe,k0="Expected a function";function q0(d,r,t){var e=!0,n=!0;if(typeof d!="function")throw new TypeError(k0);return Z0(t)&&(e="leading"in t?!!t.leading:e,n="trailing"in t?!!t.trailing:n),Q0(d,r,{leading:e,maxWait:r,trailing:n})}var _0=q0,tg=Xt(_0);class eg extends Jn{constructor(t){super(t);nt(this,"combineUnitTime",600);nt(this,"combineTimerId");nt(this,"effectSelectNodeData",new Set);nt(this,"batchEraserWorks",new Set);nt(this,"batchEraserRemoveNodes",new Set);nt(this,"batchEraserCombine",tg(()=>{const t=this.updateBatchEraserCombineNode(this.batchEraserWorks,this.batchEraserRemoveNodes);this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear(),t.length&&this._post({render:t})},100,{leading:!1}))}consumeDraw(t,e){const{op:n,workId:i}=t;if(n!=null&&n.length&&i){const a=this.workShapes.get(i);if(!a)return;const s=a.toolsType;if(s===ht.LaserPen)return;const o=a.consume({data:t,isFullWork:!0});switch(s){case ht.Selector:o.type===ct.Select&&(o.selectIds&&e.runReverseSelectWork(o.selectIds),this.drawSelector(o));break;case ht.Eraser:o!=null&&o.rect&&this.drawEraser(o);break;case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:o&&(this.drawCount++,this.drawPencil(o));break;case ht.Pencil:this.combineTimerId||(this.combineTimerId=setTimeout(()=>{this.combineTimerId=void 0,this.drawPencilCombine(i)},Math.floor(a.getWorkOptions().syncUnitTime||this.combineUnitTime/2))),o&&(this.drawCount++,this.drawPencil(o));break}}}consumeDrawAll(t,e){var a,s,o;this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0);const{workId:n,scenePath:i}=t;if(n){const f=this.workShapes.get(n);if(!f)return;const v=f.toolsType;if(v===ht.LaserPen)return;const l=this.workShapes.get(Sr),p=(a=l==null?void 0:l.selectIds)==null?void 0:a[0],y=f.consumeAll({data:t}),O=this.workShapeState.get(n);switch(v){case ht.Selector:y.selectIds&&p&&((s=y.selectIds)!=null&&s.includes(p))&&l.cursorBlur(),y.selectIds&&e.runReverseSelectWork(y.selectIds),this.drawSelector({...y,scenePath:i}),(o=f.selectIds)!=null&&o.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(n);break;case ht.Eraser:y!=null&&y.rect&&this.drawEraser({...y,scenePath:i}),f.clearTmpPoints();break;case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:this.drawPencilFull({...y,scenePath:i},f.getWorkOptions(),O),this.drawCount=0,this.clearWorkShapeNodeCache(n);break;case ht.Pencil:y!=null&&y.rect&&(this.drawPencilFull({...y,scenePath:i},f.getWorkOptions(),O),this.drawCount=0),this.clearWorkShapeNodeCache(n);break}}}async consumeFull(t,e){var a,s;const n=this.setFullWork(t),i=t.ops&&Ie(t.ops);if(n){const o=(a=t.workId)==null?void 0:a.toString();if(!o)return;const f=(s=this.vNodes.get(o))==null?void 0:s.rect;let v,l;n.toolsType===ht.Image&&e?(v=await n.consumeServiceAsync({scene:e,isFullWork:!0,replaceId:o}),l=(t==null?void 0:t.updateNodeOpt)&&n.updataOptService(t.updateNodeOpt)):n.toolsType===ht.Text?v=await n.consumeServiceAsync({isFullWork:!0,replaceId:o}):(v=n.consumeService({op:i,isFullWork:!0,replaceId:o}),l=(t==null?void 0:t.updateNodeOpt)&&n.updataOptService(t.updateNodeOpt)),v=Ot(v,l);const p=[],y=[];if(t.workId&&this.workShapes.delete(t.workId),n.toolsType===ht.Text&&console.log("text-render",n.getWorkOptions(),v,t.willRefresh,this.fullLayer.children),v&&t.willRefresh&&(f&&p.push({rect:v,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}),p.push({rect:v,drawCanvas:Mt.Bg,viewId:this.viewId})),t.willSyncService&&y.push({opt:t.opt,toolsType:t.toolsType,type:ct.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),p.length||y.length){const O={render:p,sp:y};this._post(O)}}}removeWork(t){const{workId:e}=t,n=e==null?void 0:e.toString();if(n){const i=this.removeNode(n);i&&this._post({render:[{rect:Bt(i),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(i),drawCanvas:Mt.Bg,viewId:this.viewId}]})}}removeNode(t){var i;this.workShapes.has(t)&&this.clearWorkShapeNodeCache(t);let e;const n=this.vNodes.get(t);return n&&(this.fullLayer.getElementsByName(t).concat(((i=this.drawLayer)==null?void 0:i.getElementsByName(t))||[]).forEach(a=>{a.remove()}),e=Ot(e,n.rect),this.vNodes.delete(t)),e}async checkTextActive(t){const{op:e,viewId:n,dataType:i}=t;if(e!=null&&e.length){let a;for(const s of this.vNodes.curNodeMap.values()){const{rect:o,name:f,toolsType:v,opt:l}=s,p=e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y=e[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];if(v===ht.Text&&Nh([p,y],o)&&l.workState===Rt.Done){a=f;break}}a&&(await this.blurSelector({viewId:n,msgType:ct.Select,dataType:i,isSync:!0}),this._post({sp:[{type:ct.GetTextActive,toolsType:ht.Text,workId:a}]}))}}async colloctEffectSelectWork(t){const e=this.workShapes.get(Nt.selectorId),{workId:n,msgType:i}=t;if(e&&n&&e.selectIds&&e.selectIds.includes(n.toString())){i===ct.RemoveNode?e.selectIds=e.selectIds.filter(a=>a!==n.toString()):this.effectSelectNodeData.add(t),await new Promise(a=>{setTimeout(()=>{a(!0)},0)}),await this.runEffectSelectWork(!0).then(()=>{var a;(a=this.effectSelectNodeData)==null||a.clear()});return}return t}async updateSelector(t){var O;const e=this.workShapes.get(Nt.selectorId);if(!((O=e==null?void 0:e.selectIds)!=null&&O.length))return;const{callback:n,...i}=t,{updateSelectorOpt:a,willSerializeData:s,scene:o}=i,f=await(e==null?void 0:e.updateSelector({updateSelectorOpt:a,selectIds:e.selectIds,vNodes:this.vNodes,willSerializeData:s,worker:this,scene:o})),v=new Map;e.selectIds.forEach(x=>{const m=this.vNodes.get(x);if(m){const{toolsType:T,op:c,opt:h}=m;v.set(x,{opt:h,toolsType:T,ops:(c==null?void 0:c.length)&&qt(c)||void 0})}});const l=[],p=[];f!=null&&f.rect&&l.push({rect:Bt(f.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(f.rect),drawCanvas:Mt.Bg,viewId:this.viewId});const y=n&&n({res:f,workShapeNode:e,param:i,postData:{render:l,sp:p},newServiceStore:v})||{render:l,sp:p};(y.render.length||y.sp.length)&&this._post(y)}async blurSelector(t){var i;const e=this.workShapes.get(Nt.selectorId),n=e==null?void 0:e.blurSelector();if(this.clearWorkShapeNodeCache(Nt.selectorId),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(a=>{a.name===Nt.selectorId&&a.remove()}),n){const a=[];a.push({...n,isSync:t==null?void 0:t.isSync}),this._post({render:(n==null?void 0:n.rect)&&[{rect:Bt(n.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(n.rect),drawCanvas:Mt.Bg,viewId:this.viewId}],sp:a})}}reRenderSelector(t=!1){var a;const e=this.workShapes.get(Nt.selectorId);if(!e)return;if(e&&!((a=e.selectIds)!=null&&a.length))return this.blurSelector();const n=e.oldSelectRect,i=e.reRenderSelector();if(i){const s=Ot(n,i)||i;this._post({render:[{rect:Bt(s),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(s),drawCanvas:Mt.Bg,viewId:this.viewId}],sp:[{type:ct.Select,selectIds:e.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:e.getChildrenPoints(),textOpt:e.textOpt,selectorColor:e.selectorColor,strokeColor:e.strokeColor,fillColor:e.fillColor,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,opt:e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt}]})}}updateFullSelectWork(t){var i,a,s,o,f,v,l;const e=this.workShapes.get(Nt.selectorId),{selectIds:n}=t;if(!(n!=null&&n.length)){this.blurSelector(t);return}if(!e){!this.setFullWork(t)&&t.workId&&((i=this.tmpWorkShapeNode)==null?void 0:i.toolsType)===ht.Selector&&this.setTmpWorkId(t.workId),this.updateFullSelectWork(t);return}if(e&&(n!=null&&n.length)){const{bgRect:p,selectRect:y}=e.updateSelectIds(n),O={render:[],sp:[]};p&&((a=O.render)==null||a.push({rect:Bt(p),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(p),drawCanvas:Mt.Bg,viewId:this.viewId})),(l=O.sp)==null||l.push({...t,selectorColor:((s=t.opt)==null?void 0:s.strokeColor)||e.selectorColor,strokeColor:((o=t.opt)==null?void 0:o.strokeColor)||e.strokeColor,fillColor:((f=t.opt)==null?void 0:f.fillColor)||e.fillColor,textOpt:((v=t.opt)==null?void 0:v.textOpt)||e.textOpt,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,type:ct.Select,selectRect:y,points:e.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt}),this._post(O)}}destroy(){super.destroy(),this.effectSelectNodeData.clear(),this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear()}drawPencilCombine(t){var n,i,a;const e=(n=this.workShapes.get(t))==null?void 0:n.combineConsume();if(e){const s={render:[],drawCount:this.drawCount};if(e!=null&&e.rect){const o=Bt(e.rect);(i=s.render)==null||i.push({rect:o,isClear:!0,clearCanvas:Mt.Float,viewId:this.viewId}),(a=s.render)==null||a.push({rect:o,drawCanvas:Mt.Float,viewId:this.viewId})}this._post(s)}}drawSelector(t){var n;const e={render:[],sp:[t]};t.rect&&((n=e.render)==null||n.push({rect:Bt(t.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(t.rect),drawCanvas:Mt.Bg,viewId:this.viewId})),this._post(e)}async drawEraser(t){var n,i;const e=[];if((n=t.newWorkDatas)!=null&&n.size){for(const a of t.newWorkDatas.values()){const s=a.workId.toString();this.batchEraserWorks.add(s),e.push({type:ct.FullWork,workId:s,ops:qt(a.op),opt:a.opt,toolsType:a.toolsType,updateNodeOpt:{useAnimation:!1}})}delete t.newWorkDatas}(i=t.removeIds)==null||i.forEach(a=>{this.batchEraserRemoveNodes.add(a)}),e.push(t),this._post({sp:e}),this.batchEraserCombine()}drawPencil(t){this._post({drawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]})}drawPencilFull(t,e,n){var s;let i=(n==null?void 0:n.willClear)||(e==null?void 0:e.isOpacity)||!1;!i&&t.rect&&(i=this.vNodes.hasRectIntersectRange(t.rect));const a={drawCount:1/0,render:[],sp:[t]};(s=a.render)==null||s.push({isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId},{rect:t.rect,isClear:i,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Mt.Bg,viewId:this.viewId}),this._post(a)}updateBatchEraserCombineNode(t,e){const n=[];let i;for(const a of e.keys())this.fullLayer.getElementsByName(a).forEach(s=>{const o=s.getBoundingClientRect();i=Ot(i,{x:o.x-ae.SafeBorderPadding,y:o.y-ae.SafeBorderPadding,w:o.width+ae.SafeBorderPadding*2,h:o.height+ae.SafeBorderPadding*2}),s.remove()});return t.forEach(a=>{const s=this.vNodes.get(a);if(s)if(this.fullLayer.getElementsByName(a)[0])i=Ot(i,s.rect);else{const f=this.setFullWork({...s,workId:a}),v=f&&f.consumeService({op:s.op,isFullWork:!0});v&&(s.rect=v,i=Ot(i,v))}}),i&&n.push({rect:i,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:i,drawCanvas:Mt.Bg,viewId:this.viewId}),n}async runEffectSelectWork(t){var e,n,i;for(const a of this.effectSelectNodeData.values()){const s=this.setFullWork(a);if(s){const o=(e=s.getWorkId())==null?void 0:e.toString();if(s.toolsType===ht.Image)await s.consumeServiceAsync({scene:(i=(n=this.drawLayer)==null?void 0:n.parent)==null?void 0:i.parent,isFullWork:!0,replaceId:o});else if(s.toolsType===ht.Text)await s.consumeServiceAsync({isFullWork:!0,replaceId:o});else{const f=a.ops&&Ie(a.ops);s.consumeService({op:f,isFullWork:!0,replaceId:o}),a!=null&&a.updateNodeOpt&&s.updataOptService(a.updateNodeOpt)}a.workId&&this.workShapes.delete(a.workId)}}this.reRenderSelector(t)}cursorHover(t){var s;const{opt:e,toolsType:n,point:i}=t,a=this.setFullWork({workId:Sr,toolsType:n,opt:e});if(a&&i){const o=a.cursorHover(i),f={render:[]};o&&o.type===ct.CursorHover&&o.rect&&((s=f.render)==null||s.push({rect:Bt(o.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(o.rect),drawCanvas:Mt.Bg,viewId:this.viewId}),this._post(f))}}}class rg{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"fullLayer");nt(this,"drawLayer");nt(this,"workShapes",new Map);nt(this,"selectorWorkShapes",new Map);nt(this,"animationId");nt(this,"willRunEffectSelectorIds",new Set);nt(this,"runEffectId");nt(this,"noAnimationRect");nt(this,"post");this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this.post=r.thread.post.bind(r.thread)}destroy(){this.workShapes.clear(),this.selectorWorkShapes.clear(),this.willRunEffectSelectorIds.clear()}consumeDraw(r){this.activeWorkShape(r),this.runAnimation()}consumeFull(r){this.activeWorkShape(r),this.runAnimation()}clearAllWorkShapesCache(){this.workShapes.forEach((r,t)=>{r.toolsType===ht.LaserPen?setTimeout(()=>{this.workShapes.delete(t)},2e3):this.workShapes.delete(t)})}runSelectWork(r){this.activeSelectorShape(r);const{workId:t}=r,e=t==null?void 0:t.toString();e&&this.willRunEffectSelectorIds.add(e),this.runEffect()}setNodeKey(r,t,e){return r.toolsType=t,r.node=yr({toolsType:t,toolsOpt:e,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),r}runReverseSelectWork(r){r.forEach(t=>{this.selectorWorkShapes.forEach((e,n)=>{var i;if((i=e.selectIds)!=null&&i.length){const a=e.selectIds.indexOf(t);a>-1&&(e.selectIds.splice(a,1),this.willRunEffectSelectorIds.add(n))}})}),this.willRunEffectSelectorIds.size&&this.runEffect()}removeWork(r){const{workId:t}=r,e=t==null?void 0:t.toString();if(e){const n=this.workShapes.get(e);if(n){this.workShapes.delete(e),this.removeNode(e,r,n==null?void 0:n.totalRect,!1);return}this.removeNode(e,r)}}removeSelectWork(r){const{workId:t}=r,e=t==null?void 0:t.toString();e&&(this.activeSelectorShape(r),this.willRunEffectSelectorIds.add(e)),this.runEffect()}removeNode(r,t,e,n=!0){var s;r.indexOf(Nt.selectorId)>-1&&this.removeSelectWork(t);let i=e;const a=(s=this.vNodes.get(r))==null?void 0:s.rect;a&&(i=Ot(a,i)),this.fullLayer.getElementsByName(r).forEach(o=>{o.remove()}),this.drawLayer.getElementsByName(r).forEach(o=>{o.remove()}),this.vNodes.delete(r),i&&this.post({render:[{rect:Bt(i),isClear:!0,clearCanvas:n?Mt.Bg:Mt.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId},{rect:Bt(i),drawCanvas:n?Mt.Bg:Mt.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId}]})}activeWorkShape(r){var y,O,x,m;const{workId:t,opt:e,toolsType:n,type:i,updateNodeOpt:a,ops:s,op:o,useAnimation:f}=r;if(!t)return;const v=t.toString(),l=(y=this.vNodes.get(v))==null?void 0:y.rect;if(!((O=this.workShapes)!=null&&O.has(v))){let T={toolsType:n,animationWorkData:o||[],animationIndex:0,type:i,updateNodeOpt:a,ops:s,useAnimation:typeof f<"u"?f:typeof(a==null?void 0:a.useAnimation)<"u"?a==null?void 0:a.useAnimation:!0,oldRect:l,isDiff:!1};n&&e&&(T=this.setNodeKey(T,n,e)),(x=this.workShapes)==null||x.set(v,T)}const p=(m=this.workShapes)==null?void 0:m.get(v);i&&(p.type=i),s&&(p.animationWorkData=Ie(s),p.ops=s),a&&(p.updateNodeOpt=a),o&&(p.isDiff=this.hasDiffData(p.animationWorkData||[],o,p.toolsType),p.animationWorkData=o),p.node&&p.node.getWorkId()!==v&&p.node.setWorkId(v),l&&(p.oldRect=l),n&&e&&(p.toolsType!==n&&n&&e&&this.setNodeKey(p,n,e),p.node&&p.node.setWorkOptions(e))}hasDiffData(r,t,e){const n=r.length;if(t.length<n)return!0;switch(e){case ht.Pencil:{for(let i=0;i<n;i+=3)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break}case ht.LaserPen:{for(let i=0;i<n;i+=2)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break}}return!1}async animationDraw(){var n,i,a,s,o,f,v,l,p,y,O,x,m,T,c,h,u,g,M,A,I,b,E,L,D,R,C,W;this.animationId=void 0;let r=!1;const t={render:[]},e=new Map;for(const[z,H]of this.workShapes.entries())switch(H.toolsType){case ht.Image:{const X=H.oldRect;X&&((n=t.render)==null||n.push({rect:X,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}));const Z=await((a=H.node)==null?void 0:a.consumeServiceAsync({isFullWork:!0,scene:(i=this.fullLayer.parent)==null?void 0:i.parent}));this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.runEffect())}),this.workShapes.delete(z),(s=t.render)==null||s.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId});break}case ht.Text:{if(H.node){const X=H.oldRect,Z=await H.node.consumeServiceAsync({isFullWork:!0,replaceId:z});this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.runEffect())}),(o=H.node)==null||o.clearTmpPoints(),this.workShapes.delete(z),(f=t.render)==null||f.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId})}break}case ht.Arrow:case ht.Straight:case ht.Rectangle:case ht.Ellipse:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:{const X=!!H.ops;if((v=H.animationWorkData)!=null&&v.length){const Z=H.oldRect,j=H.node.oldRect;Z&&((l=t.render)==null||l.push({rect:Z,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}),(p=t.render)==null||p.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId})),j&&((y=t.render)==null||y.push({rect:j,isClear:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId}));const G=(O=H.node)==null?void 0:O.consumeService({op:H.animationWorkData,isFullWork:X});e.set(z,{workState:Z?H.ops?Rt.Done:Rt.Doing:Rt.Start,op:H.animationWorkData.filter((Q,tt)=>{if(tt%3!==2)return!0}).slice(-2)}),X?(this.selectorWorkShapes.forEach((Q,tt)=>{var et;(et=Q.selectIds)!=null&&et.includes(z)&&(this.willRunEffectSelectorIds.add(tt),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.noAnimationRect=Ot(this.noAnimationRect,j),this.noAnimationRect=Ot(this.noAnimationRect,G),this.runEffect())}),(x=H.node)==null||x.clearTmpPoints(),this.workShapes.delete(z),(m=t.render)==null||m.push({rect:G,drawCanvas:Mt.Bg,viewId:this.viewId})):(T=t.render)==null||T.push({rect:G,drawCanvas:Mt.ServiceFloat,workerType:X?void 0:Tt.Service,viewId:this.viewId}),H.animationWorkData.length=0}break}case ht.Pencil:{if(!H.useAnimation&&H.ops){let X=(c=H.node)==null?void 0:c.consumeService({op:H.animationWorkData||[],isFullWork:!0,replaceId:z});const Z=(h=H.node)==null?void 0:h.updataOptService(H.updateNodeOpt);X=Ot(X,Z),(u=t.render)==null||u.push({isClear:!0,rect:Ot(H.oldRect,X),clearCanvas:Mt.Bg,viewId:this.viewId}),(g=t.render)==null||g.push({rect:Ot(H.oldRect,X),drawCanvas:Mt.Bg,viewId:this.viewId}),this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.runEffect())}),(M=H.node)==null||M.clearTmpPoints(),this.workShapes.delete(z)}else if(H.useAnimation){if(H.isDel){(A=H.node)==null||A.clearTmpPoints(),this.workShapes.delete(z);break}const X=3,Z=this.computNextAnimationIndex(H,X),j=H.isDiff?0:Math.max(0,(H.animationIndex||0)-X),G=(H.animationWorkData||[]).slice(j,Z),Q=(b=(I=H.node)==null?void 0:I.getWorkId())==null?void 0:b.toString();if((H.animationIndex||0)<Z||H.isDiff){const tt=(E=H.node)==null?void 0:E.consumeService({op:G,isFullWork:!1});if((L=t.render)==null||L.push({rect:tt,drawCanvas:Mt.ServiceFloat,viewId:this.viewId}),H.animationIndex=Z,H.isDiff&&(H.isDiff=!1),G.length){const et=G.filter((at,q)=>{if(q%X!==X-1)return!0}).slice(-2);e.set(z,{workState:j===0?Rt.Start:Z===((D=H.animationWorkData)==null?void 0:D.length)?Rt.Done:Rt.Doing,op:et})}}else if(H.ops){const tt=(R=H.node)==null?void 0:R.consumeService({op:H.animationWorkData||[],isFullWork:!0,replaceId:Q});H.isDel=!0,(C=t.render)==null||C.push({isClear:!0,rect:tt,clearCanvas:Mt.ServiceFloat,viewId:this.viewId},{rect:tt,drawCanvas:Mt.ServiceFloat,viewId:this.viewId},{isClear:!0,rect:tt,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:tt,drawCanvas:Mt.Bg,viewId:this.viewId}),e.set(z,{workState:Rt.Done,op:G.filter((et,at)=>{if(at%X!==X-1)return!0}).slice(-2)})}r=!0;break}break}}r&&this.runAnimation(),e.size&&(t.sp=[],e.forEach((z,H)=>{var X;(X=t.sp)==null||X.push({type:ct.Cursor,uid:H.split(pr)[0],op:z.op,workState:z.workState,viewId:this.viewId})})),(W=t.render)!=null&&W.length&&this.post(t)}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationDraw.bind(this)))}computNextAnimationIndex(r,t){var n;const e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/(((n=r.node)==null?void 0:n.syncUnitTime)||1e3))*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length)}runEffect(){this.runEffectId||(this.runEffectId=setTimeout(this.effectRunSelector.bind(this),0))}effectRunSelector(){this.runEffectId=void 0;let r=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(t=>{var i,a;const e=this.selectorWorkShapes.get(t),n=e&&e.selectIds&&((i=e.node)==null?void 0:i.selectServiceNode(t,e,!0));r=Ot(r,n),(a=e==null?void 0:e.selectIds)!=null&&a.length||this.selectorWorkShapes.delete(t)}),r&&this.post({render:[{rect:Bt(r),isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:Bt(r),drawCanvas:Mt.Bg,viewId:this.viewId}]}),this.willRunEffectSelectorIds.clear(),this.noAnimationRect=void 0}activeSelectorShape(r){var f,v,l;const{workId:t,opt:e,toolsType:n,type:i,selectIds:a}=r;if(!t)return;const s=t.toString();if(!((f=this.selectorWorkShapes)!=null&&f.has(s))){let p={toolsType:n,selectIds:a,type:i,opt:e};n&&e&&(p=this.setNodeKey(p,n,e)),(v=this.selectorWorkShapes)==null||v.set(s,p)}const o=(l=this.selectorWorkShapes)==null?void 0:l.get(s);i&&(o.type=i),o.node&&o.node.getWorkId()!==s&&o.node.setWorkId(s),o.selectIds=a||[]}}class ng extends Jn{constructor(t){super(t);nt(this,"combineDrawTimer")}async runFullWork(t){var i,a;const e=this.setFullWork(t),n=t.ops&&Ie(t.ops);if(e){let s,o;const f=(i=e.getWorkId())==null?void 0:i.toString();return e.toolsType===ht.Image?s=await e.consumeServiceAsync({isFullWork:!0,scene:(a=this.fullLayer.parent)==null?void 0:a.parent}):e.toolsType===ht.Text?s=await e.consumeServiceAsync({isFullWork:!0,replaceId:f,isDrawLabel:!0}):(s=e.consumeService({op:n,isFullWork:!0,replaceId:f}),o=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt)),t.workId&&this.workShapes.delete(t.workId),Ot(s,o)}}runSelectWork(t){var n;const e=this.setFullWork(t);e&&((n=t.selectIds)!=null&&n.length)&&t.workId&&e.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1)}consumeDraw(t){const{workId:e}=t,n=this.workShapes.get(e);if(!n)return;const i=n.toolsType,a=n.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0});switch(i){case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:{a&&(this.drawCount++,this.drawArrow(a));break}case ht.Pencil:{a&&(this.drawCount++,this.drawPencil(a,e==null?void 0:e.toString()));break}}}consumeDrawAll(t){const{workId:e}=t;if(e){const n=this.workShapes.get(e);if(!n)return;switch(n.toolsType){case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Pencil:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e);break}}}updateLabels(t,e){t.children.forEach(n=>{if(n.tagName==="LABEL"){const i=n.name,{width:a}=n.getBoundingClientRect(),[s]=t.worldScaling,{underline:o,lineThrough:f}=e.opt;o&&t.getElementsByName(`${i}_underline`)[0].attr({points:[0,0,a/s,0]}),f&&t.getElementsByName(`${i}_lineThrough`)[0].attr({points:[0,0,a/s,0]})}})}drawPencil(t,e){this._post({drawCount:this.drawCount,render:[{rect:t==null?void 0:t.rect,workId:e,drawCanvas:Mt.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]})}drawArrow(t){this._post({drawCount:this.drawCount,render:[{rect:(t==null?void 0:t.rect)&&Bt(t.rect),isClear:!0,clearCanvas:Mt.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&Bt(t.rect),drawCanvas:Mt.Float,viewId:this.viewId}]})}}class ig{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"topLayer");nt(this,"post");nt(this,"serviceWorkShapes",new Map);nt(this,"localWorkShapes",new Map);nt(this,"tmpOpt");nt(this,"tmpWorkShapeNode");nt(this,"animationId");this.viewId=r.viewId,this.vNodes=r.vNodes,this.topLayer=r.topLayer,this.post=r.thread.post.bind(r.thread)}getWorkShape(r){return this.localWorkShapes.get(r)}getTmpWorkShapeNode(){return this.tmpWorkShapeNode}setTmpWorkId(r){if(r&&this.tmpWorkShapeNode){this.tmpWorkShapeNode.setWorkId(r),this.localWorkShapes.set(r,{node:this.tmpWorkShapeNode,toolsType:this.tmpWorkShapeNode.toolsType,workState:Rt.Start}),this.tmpOpt&&this.setToolsOpt(this.tmpOpt);return}}setWorkOptions(r,t){var n,i,a;((n=this.localWorkShapes.get(r))==null?void 0:n.node)||this.setTmpWorkId(r),(a=(i=this.localWorkShapes.get(r))==null?void 0:i.node)==null||a.setWorkOptions(t)}createWorkShapeNode(r){const{toolsType:t}=r;if(t===ht.LaserPen)return yr({...r,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(r=>{var t;return(t=r.node)==null?void 0:t.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(r){this.tmpOpt=r,this.tmpWorkShapeNode=this.createWorkShapeNode(r)}consumeDraw(r){const{workId:t,dataType:e}=r;if(e===Tt.Service)this.activeServiceWorkShape(r);else{const n=this.localWorkShapes.get(t);if(!n)return;const i=n.node.consume({data:r,isFullWork:!1,isSubWorker:!0});i.rect&&(n.totalRect=Ot(i.rect,n.totalRect),n.result=i,n.workState=Rt.Doing,t&&this.localWorkShapes.set(t,n))}this.runAnimation()}consumeDrawAll(r){const{workId:t,dataType:e}=r;if(e===Tt.Service)this.activeServiceWorkShape(r);else{const n=this.localWorkShapes.get(t);if(!n)return;const i=n.node.consumeAll({data:r});n.totalRect=Ot(i.rect,n.totalRect),n.result=i,n.workState=Rt.Done,t&&this.localWorkShapes.set(t,n)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(r,t,e){return r.toolsType=t,r.node=this.createWorkShapeNode({toolsType:t,toolsOpt:e}),r}activeServiceWorkShape(r){var p,y;const{workId:t,opt:e,toolsType:n,type:i,updateNodeOpt:a,ops:s,op:o}=r;if(!t)return;const f=t.toString(),v=(p=this.vNodes.get(f))==null?void 0:p.rect;if(!((y=this.serviceWorkShapes)!=null&&y.has(f))){let O={toolsType:n,animationWorkData:o||[],animationIndex:0,type:i,updateNodeOpt:a,ops:s,oldRect:v};n&&e&&(O=this.setNodeKey(O,n,e)),this.serviceWorkShapes.set(f,O)}const l=this.serviceWorkShapes.get(f);i&&(l.type=i),s&&(l.animationWorkData=Ie(s),l.ops=s),a&&(l.updateNodeOpt=a),o&&(l.animationWorkData=o),l.node&&l.node.getWorkId()!==f&&l.node.setWorkId(f),v&&(l.oldRect=v),n&&e&&(l.toolsType!==n&&n&&e&&this.setNodeKey(l,n,e),l.node&&l.node.setWorkOptions(e))}computNextAnimationIndex(r,t){var n;const e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/(((n=r.node)==null?void 0:n.syncUnitTime)||1e3))*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length)}async animationDraw(){var a,s,o,f;this.animationId=void 0;let r=!1;const t=new Map,e=[],n=[],i=[];for(const[v,l]of this.serviceWorkShapes.entries())switch(l.toolsType){case ht.LaserPen:{const y=this.computNextAnimationIndex(l,8),O=Math.max(0,l.animationIndex||0),x=(l.animationWorkData||[]).slice(O,y);if((l.animationIndex||0)<y){const m=(a=l.node)==null?void 0:a.consumeService({op:x,isFullWork:!1});l.totalRect=Ot(l.totalRect,m),l.animationIndex=y,x.length&&t.set(v,{workState:O===0?Rt.Start:y===((s=l.animationWorkData)==null?void 0:s.length)?Rt.Done:Rt.Doing,op:x.slice(-2)})}if(n.push({isClear:!0,rect:l.totalRect,clearCanvas:Mt.TopFloat,viewId:this.viewId}),e.push({rect:l.totalRect,drawCanvas:Mt.TopFloat,viewId:this.viewId}),l.isDel){(o=l.node)==null||o.clearTmpPoints(),this.serviceWorkShapes.delete(v);break}l.ops&&l.animationIndex===((f=l.animationWorkData)==null?void 0:f.length)&&!l.isDel&&(this.topLayer.getElementsByName(v.toString())[0]||(l.isDel=!0,this.serviceWorkShapes.set(v,l))),r=!0;break}}for(const[v,l]of this.localWorkShapes.entries()){const{result:p,toolsType:y,totalRect:O,isDel:x,workState:m}=l;switch(y){case ht.LaserPen:{if(O&&(n.push({isClear:!0,rect:O,clearCanvas:Mt.TopFloat,viewId:this.viewId}),e.push({rect:O,drawCanvas:Mt.TopFloat,viewId:this.viewId})),x){l.node.clearTmpPoints(),this.localWorkShapes.delete(v),i.push({removeIds:[v.toString()],viewId:this.viewId,type:ct.RemoveNode});break}p&&((p.op||p.ops)&&i.push(p),l.result=void 0),!this.topLayer.getElementsByName(v.toString())[0]&&m===Rt.Done&&(l.isDel=!0,this.localWorkShapes.set(v,l)),r=!0;break}}}r&&this.runAnimation(),t.size&&t.forEach((v,l)=>{i.push({type:ct.Cursor,uid:l.split(pr)[0],op:v.op,workState:v.workState,viewId:this.viewId})}),(e.length||n.length||i.length)&&this.post({render:[...n,...e],sp:i})}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationDraw.bind(this)))}}var qn=(d=>(d.Full="full",d.Sub="sub",d))(qn||{});class sg{constructor(r,t){nt(this,"_self");nt(this,"type");nt(this,"workThreadMap",new Map);this._self=r,this.type=t,this.register()}init(r){const{viewId:t,dpr:e,offscreenCanvasOpt:n,layerOpt:i,isSafari:a}=r;if(!e||!n||!i)return;let s;this.type==="full"&&(s=new og(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),this.type==="sub"&&(s=new ag(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),s&&a&&s.setIsSafari(a),s&&r.cameraOpt&&s.setCameraOpt(r.cameraOpt),s&&this.workThreadMap.set(t,s)}register(){onmessage=r=>{const t=r.data;if(t)for(const e of t.values()){const{msgType:n,viewId:i,tasksqueue:a,mainTasksqueueCount:s}=e;if(n===ct.Init){this.init(e);continue}if(n===ct.TasksQueue&&(a!=null&&a.size)&&s){for(const[f,v]of this.workThreadMap.entries()){const l=a.get(f);l&&v.on(l,s)}continue}if(i===Zh){for(const f of this.workThreadMap.values())f.on(e),n===ct.Destroy&&this.workThreadMap.delete(i);continue}const o=this.workThreadMap.get(i);o&&(o.on(e),n===ct.Destroy&&this.workThreadMap.delete(i))}}}post(r,t){t?this._self.postMessage(r,t):this._self.postMessage(r)}}class og extends Xn{constructor(t,e,n){super(t,e);nt(this,"serviceDrawLayer");nt(this,"localDrawLayer");nt(this,"snapshotFullLayer");nt(this,"methodBuilder");nt(this,"localWork");nt(this,"serviceWork");nt(this,"_post");this._post=n,this.serviceDrawLayer=this.createLayer("serviceDrawLayer",this.scene,{...e.layerOpt,bufferSize:1e3}),this.localDrawLayer=this.createLayer("localDrawLayer",this.scene,{...e.layerOpt,bufferSize:1e3});const i={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer};this.localWork=new eg({...i,drawLayer:this.localDrawLayer}),this.serviceWork=new rg({...i,drawLayer:this.serviceDrawLayer}),this.methodBuilder=new y0([Lt.CopyNode,Lt.SetColorNode,Lt.DeleteNode,Lt.RotateNode,Lt.ScaleNode,Lt.TranslateNode,Lt.ZIndexNode,Lt.SetFontStyle,Lt.SetPoint,Lt.SetLock,Lt.SetShapeOpt]).registerForWorker(this.localWork,this.serviceWork,this.scene),this.vNodes.init(this.fullLayer)}async combinePost(){var a,s,o,f;const{render:t,...e}=this.combinePostData();let n;if(t!=null&&t.length){const v=[];for(const l of t)if(l.rect){if(l.drawCanvas&&(l.rect=this.safariFixRect(Jt(l.rect))),!l.rect)continue;if(l.drawCanvas&&l.rect){const p=await this.getRectImageBitmap(l);l.imageBitmap=p,n||(n=[]),n.push(p)}v.push(l)}e.render=v}const i=(a=e.sp)==null?void 0:a.filter(v=>v.type!==ct.None||Object.keys(v).filter(l=>l==="type").length);i!=null&&i.length&&(e.sp=i.map(v=>({...v,viewId:this.viewId}))),((s=e.sp)==null?void 0:s.length)===0&&delete e.sp,e.drawCount===void 0&&delete e.drawCount,e.workerTasksqueueCount===void 0&&delete e.workerTasksqueueCount,(e!=null&&e.drawCount||e!=null&&e.workerTasksqueueCount||(o=e.sp)!=null&&o.length||(f=e.render)!=null&&f.length)&&this._post(e,n)}async on(t,e){if(this.methodBuilder.consumeForWorker(t))return;const{msgType:n,dataType:i,workId:a}=t;switch(n){case ct.UpdateCamera:await this.updateCamera(t),e&&this.post({workerTasksqueueCount:e});return;case ct.Select:i===Tt.Service&&(a===Nt.selectorId?this.localWork.updateFullSelectWork(t):this.serviceWork.runSelectWork(t));return;case ct.UpdateNode:case ct.FullWork:await this.consumeFull(i,t);return;case ct.RemoveNode:await this.removeNode(t);return;case ct.GetTextActive:this.checkTextActive(t);return;case ct.CursorHover:this.cursorHover(t);return}await super.on(t)}async removeNode(t){const{dataType:e,workId:n}=t;if(n===Nt.selectorId){this.localWork.blurSelector(t);return}e===Tt.Local&&(this.localWork.removeWork(t),await this.localWork.colloctEffectSelectWork(t)),e===Tt.Service&&(this.serviceWork.removeWork(t),await this.localWork.colloctEffectSelectWork(t))}checkTextActive(t){const{dataType:e}=t;e===Tt.Local&&this.localWork.checkTextActive(t)}clearAll(){this.vNodes.clear(),super.clearAll(),this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.localDrawLayer.removeAllChildren()),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.serviceDrawLayer.removeAllChildren()),this.post({render:[{isClearAll:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId}],sp:[{type:ct.Clear}]})}updateLayer(t){const{width:e,height:n}=t;super.updateLayer(t),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",e),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[e,n]),this.localDrawLayer.setAttribute("pos",[e*.5,n*.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",e),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[e,n]),this.serviceDrawLayer.setAttribute("pos",[e*.5,n*.5]))}setCameraOpt(t){this.cameraOpt=t;const{scale:e,centerX:n,centerY:i,width:a,height:s}=t;(a!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:a,height:s}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[e,e]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[e,e]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[e,e]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]))}getLayer(t){switch(t){case Mt.Bg:return this.fullLayer;case Mt.ServiceFloat:return this.serviceDrawLayer;case Mt.Float:return this.localDrawLayer}}getOffscreen(t){return this.getLayer(t).parent.canvas}async consumeFull(t,e){const n=await this.localWork.colloctEffectSelectWork(e);n&&t===Tt.Local&&await this.localWork.consumeFull(n,this.scene),n&&t===Tt.Service&&this.serviceWork.consumeFull(n)}consumeDraw(t,e){t===Tt.Local&&this.localWork.consumeDraw(e,this.serviceWork),t===Tt.Service&&this.serviceWork.consumeDraw(e)}consumeDrawAll(t,e){t===Tt.Local&&this.localWork.consumeDrawAll(e,this.serviceWork)}async updateCamera(t){var i;const e=[],{cameraOpt:n}=t;if(n&&!le(this.cameraOpt,n)){const a=this.localWork.getWorkShape(Sr);a&&((i=a.selectIds)!=null&&i.length)&&a.cursorBlur();const s=!!this.localDrawLayer.children.length,o=!!this.serviceDrawLayer.children.length;if(this.setCameraOpt(n),this.localWork.workShapes.forEach((f,v)=>{(f.toolsType===ht.Pencil||f.toolsType===ht.Arrow||f.toolsType===ht.Straight||f.toolsType===ht.Ellipse||f.toolsType===ht.Rectangle||f.toolsType===ht.Star||f.toolsType===ht.Polygon||f.toolsType===ht.SpeechBalloon||f.toolsType===ht.Text)&&this.localWork.workShapeState.set(v,{willClear:!0})}),this.vNodes.curNodeMap.size&&(this.vNodes.updateNodesRect(),this.localWork.reRenderSelector(),this.serviceWork.selectorWorkShapes.size))for(const[f,v]of this.serviceWork.selectorWorkShapes.entries())this.serviceWork.runSelectWork({workId:f,selectIds:v.selectIds,msgType:ct.Select,dataType:Tt.Service,viewId:this.viewId});this.vNodes.hasRenderNodes()&&(s&&e.push({isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId}),o&&e.push({isClearAll:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId}),e.push({isClearAll:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Mt.Bg,viewId:this.viewId})),e.length&&this.post({render:e})}}getRectImageBitmap(t){const{rect:e,drawCanvas:n}=t,i=e.x*this.dpr,a=e.y*this.dpr,s=e.w*this.dpr,o=e.h*this.dpr;return createImageBitmap(this.getOffscreen(n),i,a,s,o,{resizeQuality:"low"})}cursorHover(t){this.localWork.cursorHover(t)}}class ag extends Xn{constructor(t,e,n){super(t,e);nt(this,"_post");nt(this,"topLayer");nt(this,"snapshotFullLayer");nt(this,"serviceWork");nt(this,"localWork");nt(this,"topLayerWork");this._post=n,this.topLayer=this.createLayer("topLayer",this.scene,{...e.layerOpt,bufferSize:1500});const i={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new ng(i),this.topLayerWork=new ig(i),this.vNodes.init(this.fullLayer)}async combinePost(){var a,s,o,f,v;const{render:t,...e}=this.combinePostData();let n;if(t!=null&&t.length){const l=[];for(const p of t)if(p.rect){if(p.drawCanvas&&(p.rect=this.safariFixRect(Jt(p.rect))),!p.rect)continue;if(p.drawCanvas&&p.rect){const y=await this.getRectImageBitmap(p);p.imageBitmap=y,n||(n=[]),n.push(y)}l.push(p)}e.render=l}if((a=e.workIds)!=null&&a.size&&e.drawCount)for(const l of e.workIds.values())this.fullLayer.getElementsByName(l).forEach(p=>{p.id&&e.drawCount&&Number(p.id)<e.drawCount&&p.remove()});const i=(s=e.sp)==null?void 0:s.filter(l=>l.type!==ct.None||Object.keys(l).filter(p=>p==="type").length);i!=null&&i.length&&(e.sp=i.map(l=>({...l,viewId:this.viewId}))),((o=e.sp)==null?void 0:o.length)===0&&delete e.sp,e.drawCount===void 0&&delete e.drawCount,e.workerTasksqueueCount===void 0&&delete e.workerTasksqueueCount,((f=e.sp)!=null&&f.length||e.drawCount||(v=e==null?void 0:e.render)!=null&&v.length)&&(console.log("msg---layer--sub--000",this.fullLayer.children.map(l=>({name:l.name,id:l.id})),this.fullLayer),this._post(e,n))}getLayer(t,e){if(e&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case Mt.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(t){const{msgType:e,toolsType:n,opt:i,workId:a,dataType:s}=t;switch(e){case ct.UpdateCamera:await this.updateCamera(t);break;case ct.UpdateTools:if(n===ht.LaserPen&&i){const o={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(o);return}break;case ct.CreateWork:if(n===ht.LaserPen&&a&&i){this.topLayerWork.getTmpWorkShapeNode()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(a,i);return}break;case ct.FullWork:if(n===ht.LaserPen){this.consumeDrawAll(s,t);return}break;case ct.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.snapshotFullLayer&&(await this.getSnapshot(t),this.snapshotFullLayer=void 0);return;case ct.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.snapshotFullLayer&&(await this.getBoundingRect(t),this.snapshotFullLayer=void 0);return}await super.on(t)}getOffscreen(t,e){return this.getLayer(t,e).parent.canvas}consumeDraw(t,e){const{op:n,workId:i}=e;if(n!=null&&n.length&&i){if(this.localWork.workShapes.get(i)){this.localWork.consumeDraw(e);return}if(this.topLayerWork.localWorkShapes.get(i)){this.topLayerWork.consumeDraw(e);return}}}consumeDrawAll(t,e){const{ops:n,op:i,workId:a}=e;if((n||i!=null&&i.length)&&a){if(this.localWork.workShapes.get(a)){this.localWork.consumeDrawAll(e);return}if(this.topLayerWork.localWorkShapes.get(a)){this.topLayerWork.consumeDrawAll(e);return}}}clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.topLayer.removeAllChildren()),this.post({render:[{isClearAll:!0,clearCanvas:Mt.TopFloat,viewId:this.viewId}],sp:[{type:ct.Clear}]})}getRectImageBitmap(t,e=!1,n){const{rect:i,drawCanvas:a}=t,s=i.x*this.dpr,o=i.y*this.dpr,f=i.w*this.dpr,v=i.h*this.dpr;return createImageBitmap(this.getOffscreen(a,e),s,o,f,v,n)}updateLayer(t){const{width:e,height:n}=t;super.updateLayer(t),this.topLayer&&(this.topLayer.parent.setAttribute("width",e),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[e,n]),this.topLayer.setAttribute("pos",[e*.5,n*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",e),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[e,n]),this.snapshotFullLayer.setAttribute("pos",[e*.5,n*.5]))}async updateCamera(t){const e=[],{cameraOpt:n}=t;if(n&&!le(this.cameraOpt,n)){const i=!!this.topLayerWork.localWorkShapes.size;if(this.setCameraOpt(n),i){e.push({isClearAll:!0,clearCanvas:Mt.TopFloat,viewId:this.viewId});for(const[a,s]of this.topLayerWork.localWorkShapes.entries())if(s.totalRect){let o;this.topLayer.getElementsByName(a.toString()).forEach(f=>{const v=f.getBoundingClientRect(),l=Bt({x:v.x,y:v.y,w:v.width,h:v.height});o=Ot(o,l)}),s.totalRect=o,this.topLayerWork.localWorkShapes.set(a,s)}}e.length&&this.post({render:e})}}setCameraOpt(t,e){this.cameraOpt=t;const{scale:n,centerX:i,centerY:a,width:s,height:o}=t;(s!==this.scene.width||o!==this.scene.height)&&this.updateScene({width:s,height:o}),e?(e.setAttribute("scale",[n,n]),e.setAttribute("translate",[-i,-a])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-a]),this.topLayer.setAttribute("scale",[n,n]),this.topLayer.setAttribute("translate",[-i,-a]))}async getSnapshot(t){const{scenePath:e,scenes:n,cameraOpt:i,w:a,h:s}=t;if(e&&n&&i&&this.snapshotFullLayer){const o=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let f;for(const[l,p]of Object.entries(n))if(p!=null&&p.type)switch(p==null?void 0:p.type){case ct.UpdateNode:case ct.FullWork:{const{opt:y}=p,O=await this.localWork.runFullWork({...p,opt:y,workId:l,msgType:ct.FullWork,dataType:Tt.Service,viewId:this.viewId});f=Ot(f,O);break}}let v;a&&s&&(v={resizeWidth:a,resizeHeight:s}),await new Promise(l=>{setTimeout(l,500)}),await this.getSnapshotRender({scenePath:e,curCameraOpt:o,options:v}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(t){var s,o;const{scenePath:e,curCameraOpt:n,options:i}=t;((s=this.snapshotFullLayer)==null?void 0:s.parent).render();const a=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:Mt.None},!0,i);a&&(this._post({sp:[{type:ct.Snapshot,scenePath:e,imageBitmap:a,viewId:this.viewId}]},[a]),a.close(),(o=this.snapshotFullLayer)==null||o.removeAllChildren(),this.setCameraOpt(n,this.fullLayer))}async getBoundingRect(t){const{scenePath:e,scenes:n,cameraOpt:i}=t;if(e&&n&&i&&this.snapshotFullLayer){const a=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=this.snapshotFullLayer;let s;for(const[o,f]of Object.entries(n))if(f!=null&&f.type)switch(f==null?void 0:f.type){case ct.UpdateNode:case ct.FullWork:{const v=await this.localWork.runFullWork({...f,workId:o,msgType:ct.FullWork,dataType:Tt.Service,viewId:this.viewId});s=Ot(s,v);break}}s&&this.post({sp:[{type:ct.BoundingBox,scenePath:e,rect:s}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,this.snapshotFullLayer.removeAllChildren(),this.setCameraOpt(a,this.fullLayer)}}}const lg=self;new sg(lg,qn.Sub)})();
566
+ `||c===" "||c==="\f"||c==="\r"}function x(c,h){var u=[];if(c=m(u,""+c,h),c!=="")throw new Error("Unmatched selector: "+c);return u}function m(c,h,u){var g=[],M=!1;function A(){var Q=h.match(e);if(!Q)throw new Error("Expected name, found "+h);var tt=Q[0];return h=h.substr(tt.length),y(tt)}function I(Q){for(;O(h.charAt(Q));)Q++;h=h.substr(Q)}function b(Q){for(var tt=0;h.charAt(--Q)==="\\";)tt++;return(tt&1)===1}for(I(0);h!=="";){var E=h.charAt(0);if(O(E))M=!0,I(1);else if(E in s)g.push({type:s[E]}),M=!1,I(1);else if(E===","){if(g.length===0)throw new Error("Empty sub-selector");c.push(g),g=[],M=!1,I(1)}else if(M&&(g.length>0&&g.push({type:"descendant"}),M=!1),E==="*")h=h.substr(1),g.push({type:"universal"});else if(E in o){var L=o[E],D=L[0],R=L[1];h=h.substr(1),g.push({type:"attribute",name:D,action:R,value:A(),ignoreCase:!1})}else if(E==="["){h=h.substr(1);var C=h.match(i);if(!C)throw new Error("Malformed attribute selector: "+h);h=h.substr(C[0].length);var W=y(C[1]);(!u||("lowerCaseAttributeNames"in u?u.lowerCaseAttributeNames:!u.xmlMode))&&(W=W.toLowerCase()),g.push({type:"attribute",name:W,action:a[C[2]],value:y(C[4]||C[5]||""),ignoreCase:!!C[6]})}else if(E===":"){if(h.charAt(1)===":"){h=h.substr(2),g.push({type:"pseudo-element",name:A().toLowerCase()});continue}h=h.substr(1);var z=A().toLowerCase(),C=null;if(h.charAt(0)==="(")if(f.has(z)){var H=h.charAt(1),X=l.has(H);if(h=h.substr(X?2:1),C=[],h=m(C,h,u),X){if(h.charAt(0)!==H)throw new Error("Unmatched quotes in :"+z);h=h.substr(1)}if(h.charAt(0)!==")")throw new Error("Missing closing parenthesis in :"+z+" ("+h+")");h=h.substr(1)}else{for(var Z=1,j=1;j>0&&Z<h.length;Z++)h.charAt(Z)==="("&&!b(Z)?j++:h.charAt(Z)===")"&&!b(Z)&&j--;if(j)throw new Error("Parenthesis not matched");if(C=h.substr(1,Z-2),h=h.substr(Z),v.has(z)){var H=C.charAt(0);H===C.slice(-1)&&l.has(H)&&(C=C.slice(1,-1)),C=y(C)}}g.push({type:"pseudo",name:z,data:C})}else if(e.test(h)){var G=A();(!u||("lowerCaseTags"in u?u.lowerCaseTags:!u.xmlMode))&&(G=G.toLowerCase()),g.push({type:"tag",name:G})}else return g.length&&g[g.length-1].type==="descendant"&&g.pop(),T(c,g),h}return T(c,g),h}function T(c,h){if(c.length>0&&h.length===0)throw new Error("Empty sub-selector");c.push(h)}},function(d,r,t){Object.defineProperty(r,"__esModule",{value:!0});var e={equals:"",element:"~",start:"^",end:"$",any:"*",not:"!",hyphen:"|"};function n(o){return o.map(i).join(", ")}r.default=n;function i(o){return o.map(a).join("")}function a(o){switch(o.type){case"child":return" > ";case"parent":return" < ";case"sibling":return" ~ ";case"adjacent":return" + ";case"descendant":return" ";case"universal":return"*";case"tag":return o.name;case"pseudo-element":return"::"+o.name;case"pseudo":return o.data===null?":"+o.name:typeof o.data=="string"?":"+o.name+"("+o.data+")":":"+o.name+"("+n(o.data)+")";case"attribute":return o.action==="exists"?"["+o.name+"]":o.name==="id"&&o.action==="equals"&&!o.ignoreCase?"#"+o.value:o.name==="class"&&o.action==="element"&&!o.ignoreCase?"."+o.value:"["+o.name+e[o.action]+"='"+o.value+"'"+(o.ignoreCase?"i":"")+"]";default:throw new Error("Unknown type")}}function s(o){return o}},function(d,r,t){d.exports=i;var e=t(279),n={__proto__:null,exists:10,equals:8,not:7,start:6,end:6,any:5,hyphen:4,element:4};function i(s){for(var o=s.map(a),f=1;f<s.length;f++){var v=o[f];if(!(v<0))for(var l=f-1;l>=0&&v<o[l];l--){var p=s[l+1];s[l+1]=s[l],s[l]=p,o[l+1]=o[l],o[l]=v}}}function a(s){var o=e[s.type];if(o===e.attribute)o=n[s.action],o===n.equals&&s.name==="id"&&(o=9),s.ignoreCase&&(o>>=1);else if(o===e.pseudo)if(!s.data)o=3;else if(s.name==="has"||s.name==="contains")o=0;else if(s.name==="matches"||s.name==="not"){o=0;for(var f=0;f<s.data.length;f++)if(s.data[f].length===1){var v=a(s.data[f][0]);if(v===0){o=0;break}v>o&&(o=v)}s.data.length>1&&o>0&&(o-=1)}else o=1;return o}},function(d){d.exports=JSON.parse('{"universal":50,"tag":30,"attribute":1,"pseudo":0,"descendant":-1,"child":-1,"parent":-1,"sibling":-1,"adjacent":-1}')},function(d,r,t){var e=t(281),n=t(282);d.exports={__proto__:null,attribute:e.compile,pseudo:n.compile,tag:function(i,a,s){var o=a.name,f=s.adapter;return function(l){return f.getName(l)===o&&i(l)}},descendant:function(i,a,s){var o=typeof WeakSet<"u"?new WeakSet:null,f=s.adapter;return function(l){for(var p=!1;!p&&(l=f.getParent(l));)(!o||!o.has(l))&&(p=i(l),!p&&o&&o.add(l));return p}},_flexibleDescendant:function(i,a,s){var o=s.adapter;return function(v){for(var l=i(v);!l&&(v=o.getParent(v));)l=i(v);return l}},parent:function(i,a,s){if(s&&s.strict)throw new Error("Parent selector isn't part of CSS3");var o=s.adapter;return function(l){return o.getChildren(l).some(f)};function f(v){return o.isTag(v)&&i(v)}},child:function(i,a,s){var o=s.adapter;return function(v){var l=o.getParent(v);return!!l&&i(l)}},sibling:function(i,a,s){var o=s.adapter;return function(v){for(var l=o.getSiblings(v),p=0;p<l.length;p++)if(o.isTag(l[p])){if(l[p]===v)break;if(i(l[p]))return!0}return!1}},adjacent:function(i,a,s){var o=s.adapter;return function(v){for(var l=o.getSiblings(v),p,y=0;y<l.length;y++)if(o.isTag(l[y])){if(l[y]===v)break;p=l[y]}return!!p&&i(p)}},universal:function(i){return i}}},function(d,r,t){var e=t(273).falseFunc,n=/[-[\]{}()*+?.,\\^$|#\s]/g,i={__proto__:null,equals:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;return s.ignoreCase?(v=v.toLowerCase(),function(y){var O=l.getAttributeValue(y,f);return O!=null&&O.toLowerCase()===v&&a(y)}):function(y){return l.getAttributeValue(y,f)===v&&a(y)}},hyphen:function(a,s,o){var f=s.name,v=s.value,l=v.length,p=o.adapter;return s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&(x.length===l||x.charAt(l)==="-")&&x.substr(0,l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l)===v&&(x.length===l||x.charAt(l)==="-")&&a(O)}},element:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;if(/\s/.test(v))return e;v=v.replace(n,"\\$&");var p="(?:^|\\s)"+v+"(?:$|\\s)",y=s.ignoreCase?"i":"",O=new RegExp(p,y);return function(m){var T=l.getAttributeValue(m,f);return T!=null&&O.test(T)&&a(m)}},exists:function(a,s,o){var f=s.name,v=o.adapter;return function(p){return v.hasAttrib(p,f)&&a(p)}},start:function(a,s,o){var f=s.name,v=s.value,l=v.length,p=o.adapter;return l===0?e:s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(0,l)===v&&a(O)}},end:function(a,s,o){var f=s.name,v=s.value,l=-v.length,p=o.adapter;return l===0?e:s.ignoreCase?(v=v.toLowerCase(),function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(l).toLowerCase()===v&&a(O)}):function(O){var x=p.getAttributeValue(O,f);return x!=null&&x.substr(l)===v&&a(O)}},any:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;if(v==="")return e;if(s.ignoreCase){var p=new RegExp(v.replace(n,"\\$&"),"i");return function(O){var x=l.getAttributeValue(O,f);return x!=null&&p.test(x)&&a(O)}}return function(O){var x=l.getAttributeValue(O,f);return x!=null&&x.indexOf(v)>=0&&a(O)}},not:function(a,s,o){var f=s.name,v=s.value,l=o.adapter;return v===""?function(y){return!!l.getAttributeValue(y,f)&&a(y)}:s.ignoreCase?(v=v.toLowerCase(),function(y){var O=l.getAttributeValue(y,f);return O!=null&&O.toLowerCase()!==v&&a(y)}):function(y){return l.getAttributeValue(y,f)!==v&&a(y)}}};d.exports={compile:function(a,s,o){if(o&&o.strict&&(s.ignoreCase||s.action==="not"))throw new Error("Unsupported attribute selector");return i[s.action](a,s,o)},rules:i}},function(d,r,t){var e=t(283),n=t(273),i=t(281),a=n.trueFunc,s=n.falseFunc,o=i.rules.equals;function f(T,c){var h={name:T,value:c};return function(g,M,A){return o(g,h,A)}}function v(T,c){return function(h){return!!c.getParent(h)&&T(h)}}var l={contains:function(T,c,h){var u=h.adapter;return function(M){return T(M)&&u.getText(M).indexOf(c)>=0}},icontains:function(T,c,h){var u=c.toLowerCase(),g=h.adapter;return function(A){return T(A)&&g.getText(A).toLowerCase().indexOf(u)>=0}},"nth-child":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=0;b<I.length;b++)if(g.isTag(I[b])){if(I[b]===A)break;E++}return u(E)&&T(A)}},"nth-last-child":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=I.length-1;E>=0;E--)if(g.isTag(I[E])){if(I[E]===A)break;b++}return u(b)&&T(A)}},"nth-of-type":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=0;E<I.length;E++)if(g.isTag(I[E])){if(I[E]===A)break;g.getName(I[E])===g.getName(A)&&b++}return u(b)&&T(A)}},"nth-last-of-type":function(T,c,h){var u=e(c),g=h.adapter;return u===s?u:u===a?v(T,g):function(A){for(var I=g.getSiblings(A),b=0,E=I.length-1;E>=0;E--)if(g.isTag(I[E])){if(I[E]===A)break;g.getName(I[E])===g.getName(A)&&b++}return u(b)&&T(A)}},root:function(T,c,h){var u=h.adapter;return function(g){return!u.getParent(g)&&T(g)}},scope:function(T,c,h,u){var g=h.adapter;if(!u||u.length===0)return l.root(T,c,h);function M(A,I){return typeof g.equals=="function"?g.equals(A,I):A===I}return u.length===1?function(A){return M(u[0],A)&&T(A)}:function(A){return u.indexOf(A)>=0&&T(A)}},checkbox:f("type","checkbox"),file:f("type","file"),password:f("type","password"),radio:f("type","radio"),reset:f("type","reset"),image:f("type","image"),submit:f("type","submit"),hover:function(T,c,h){var u=h.adapter;return typeof u.isHovered=="function"?function(M){return T(M)&&u.isHovered(M)}:s},visited:function(T,c,h){var u=h.adapter;return typeof u.isVisited=="function"?function(M){return T(M)&&u.isVisited(M)}:s},active:function(T,c,h){var u=h.adapter;return typeof u.isActive=="function"?function(M){return T(M)&&u.isActive(M)}:s}};function p(T,c){for(var h=0;T&&h<T.length;h++)if(c.isTag(T[h]))return T[h]}var y={empty:function(T,c){return!c.getChildren(T).some(function(h){return c.isTag(h)||h.type==="text"})},"first-child":function(T,c){return p(c.getSiblings(T),c)===T},"last-child":function(T,c){for(var h=c.getSiblings(T),u=h.length-1;u>=0;u--){if(h[u]===T)return!0;if(c.isTag(h[u]))break}return!1},"first-of-type":function(T,c){for(var h=c.getSiblings(T),u=0;u<h.length;u++)if(c.isTag(h[u])){if(h[u]===T)return!0;if(c.getName(h[u])===c.getName(T))break}return!1},"last-of-type":function(T,c){for(var h=c.getSiblings(T),u=h.length-1;u>=0;u--)if(c.isTag(h[u])){if(h[u]===T)return!0;if(c.getName(h[u])===c.getName(T))break}return!1},"only-of-type":function(T,c){for(var h=c.getSiblings(T),u=0,g=h.length;u<g;u++)if(c.isTag(h[u])){if(h[u]===T)continue;if(c.getName(h[u])===c.getName(T))return!1}return!0},"only-child":function(T,c){for(var h=c.getSiblings(T),u=0;u<h.length;u++)if(c.isTag(h[u])&&h[u]!==T)return!1;return!0},link:function(T,c){return c.hasAttrib(T,"href")},selected:function(T,c){if(c.hasAttrib(T,"selected"))return!0;if(c.getName(T)!=="option")return!1;var h=c.getParent(T);if(!h||c.getName(h)!=="select"||c.hasAttrib(h,"multiple"))return!1;for(var u=c.getChildren(h),g=!1,M=0;M<u.length;M++)if(c.isTag(u[M]))if(u[M]===T)g=!0;else if(g){if(c.hasAttrib(u[M],"selected"))return!1}else return!1;return g},disabled:function(T,c){return c.hasAttrib(T,"disabled")},enabled:function(T,c){return!c.hasAttrib(T,"disabled")},checked:function(T,c){return c.hasAttrib(T,"checked")||y.selected(T,c)},required:function(T,c){return c.hasAttrib(T,"required")},optional:function(T,c){return!c.hasAttrib(T,"required")},parent:function(T,c){return!y.empty(T,c)},header:O(["h1","h2","h3","h4","h5","h6"]),button:function(T,c){var h=c.getName(T);return h==="button"||h==="input"&&c.getAttributeValue(T,"type")==="button"},input:O(["input","textarea","select","button"]),text:function(T,c){var h;return c.getName(T)==="input"&&(!(h=c.getAttributeValue(T,"type"))||h.toLowerCase()==="text")}};function O(T){if(typeof Set<"u"){var c=new Set(T);return function(h,u){return c.has(u.getName(h))}}return function(h,u){return T.indexOf(u.getName(h))>=0}}function x(T,c,h){if(h===null){if(T.length>2&&c!=="scope")throw new Error("pseudo-selector :"+c+" requires an argument")}else if(T.length===2)throw new Error("pseudo-selector :"+c+" doesn't have any arguments")}var m=/^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/;d.exports={compile:function(T,c,h,u){var g=c.name,M=c.data,A=h.adapter;if(h&&h.strict&&!m.test(g))throw new Error(":"+g+" isn't part of CSS3");if(typeof l[g]=="function")return l[g](T,M,h,u);if(typeof y[g]=="function"){var I=y[g];return x(I,g,M),I===s?I:T===a?function(E){return I(E,A,M)}:function(E){return I(E,A,M)&&T(E)}}else throw new Error("unmatched pseudo-class :"+g)},filters:l,pseudos:y}},function(d,r,t){var e=t(284),n=t(285);d.exports=function(a){return n(e(a))},d.exports.parse=e,d.exports.compile=n},function(d,r){d.exports=e;var t=/^([+\-]?\d*n)?\s*(?:([+\-]?)\s*(\d+))?$/;function e(n){if(n=n.trim().toLowerCase(),n==="even")return[2,0];if(n==="odd")return[2,1];var i=n.match(t);if(!i)throw new SyntaxError("n-th rule couldn't be parsed ('"+n+"')");var a;return i[1]?(a=parseInt(i[1],10),isNaN(a)&&(i[1].charAt(0)==="-"?a=-1:a=1)):a=0,[a,i[3]?parseInt((i[2]||"")+i[3],10):0]}},function(d,r,t){d.exports=a;var e=t(273),n=e.trueFunc,i=e.falseFunc;function a(s){var o=s[0],f=s[1]-1;if(f<0&&o<=0)return i;if(o===-1)return function(l){return l<=f};if(o===0)return function(l){return l===f};if(o===1)return f<0?n:function(l){return l>=f};var v=f%o;return v<0&&(v+=o),o>1?function(l){return l>=f&&l%o===v}:(o*=-1,function(l){return l<=f&&l%o===v})}},function(d,r,t){t.r(r),t.d(r,"default",function(){return M});var e=t(12),n=t(74),i=t(1),a=t(68),s=t(250),o=t(213),f=t(218);t(1).glMatrix.setMatrixArrayType(Array);function v(A,I){if(A==null)return{};var b=l(A,I),E,L;if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(A);for(L=0;L<D.length;L++)E=D[L],!(I.indexOf(E)>=0)&&Object.prototype.propertyIsEnumerable.call(A,E)&&(b[E]=A[E])}return b}function l(A,I){if(A==null)return{};var b={},E=Object.keys(A),L,D;for(D=0;D<E.length;D++)L=E[D],!(I.indexOf(L)>=0)&&(b[L]=A[L]);return b}const p={antialias:!0,autoRender:!0,alpha:!0},y=Symbol("autoRender"),O=Symbol("renderer"),x=Symbol("timeline"),m=Symbol("prepareRender"),T=Symbol("tickRender"),c=Symbol("pass"),h=Symbol("fbo"),u=Symbol("tickers"),g=Symbol("layerTransformInvert");class M extends s.default{constructor(I={}){if(super(),!I.canvas){const{width:D,height:R}=this.getResolution(),C=e.ENV.createCanvas(D,R,{offscreen:!!I.offscreen,id:I.id,extra:I.extra});C.style&&(C.style.position="absolute"),C.dataset&&(C.dataset.layerId=I.id),C.contextType&&(I.contextType=C.contextType),I.canvas=C}const b=I.canvas,E=Object.assign({},p,I);this[y]=E.autoRender,delete I.autoRender;const L=E.Renderer||e.Renderer;this[O]=new L(b,E),this.options=I,this.id=I.id,this[c]=[],this.setResolution(b),this.canvas=b,this[x]=new n.Timeline,this.__mouseCapturedTarget=null,this[g]=null}get autoRender(){return this[y]}get displayRatio(){return this.parent&&this.parent.options?this.parent.options.displayRatio:1}get height(){const{height:I}=this.getResolution();return I/this.displayRatio}get gl(){return this.renderer.glRenderer?this.renderer.glRenderer.gl:null}get layer(){return this}get offscreen(){return!!this.options.offscreen||this.canvas._offscreen}get pass(){return this[c]}get prepareRender(){return this[m]?this[m]:Promise.resolve()}get renderer(){return this[O]}get renderOffset(){if(this.parent&&this.parent.options){const{left:I,top:b}=this.parent.options;return[I,b]}return[this.options.left|0,this.options.top|0]}get timeline(){return this[x]}get width(){const{width:I}=this.getResolution();return I/this.displayRatio}get localMatrix(){const{x:I,y:b}=this.attributes;return[1,0,0,1,I,b]}get layerTransformInvert(){if(this[g])return this[g];const I=this.transformMatrix;return I[0]===1&&I[1]===0&&I[2]===0&&I[3]===1&&I[4]===0&&I[5]===0?null:(this[g]=i.mat2d.invert(Array.of(0,0,0,0,0,0),I),this[g])}forceContextLoss(){const I=this.renderer.glRenderer;if(I){const b=I.getExtension("WEBGL_lose_context");if(b)return b.loseContext(),!0}return!1}addPass({vertex:I,fragment:b,options:E,uniforms:L}={}){if(this.renderer.glRenderer){const{width:D,height:R}=this.getResolution(),C=this.renderer.createPassProgram({vertex:I,fragment:b,options:E}),W=new e.Figure2D;W.rect(0,0,D/this.displayRatio,R/this.displayRatio);const z=new e.Mesh2D(W);return z.setUniforms(L),z.setProgram(C),this[c].push(z),this.forceUpdate(),z}return null}deleteTexture(I){return Object(f.deleteTexture)(I,this.renderer)}dispatchPointerEvent(I){const b=I.type;if(b==="mousedown"||b==="mouseup"||b==="mousemove"){const C=this.__mouseCapturedTarget;if(C){if(C.layer===this)return C.dispatchEvent(I),!0;this.__mouseCapturedTarget=null}}let E,L;const D=this.layerTransformInvert;if(D){E=I.x,L=I.y;const C=D,W=C[0]*E+C[2]*L+C[4],z=C[1]*E+C[3]*L+C[5];delete I.x,delete I.y,delete I.layerX,delete I.layerY,Object.defineProperties(I,{layerX:{value:W,configurable:!0},layerY:{value:z,configurable:!0},x:{value:W,configurable:!0},y:{value:z,configurable:!0}})}const R=super.dispatchPointerEvent(I);return D&&Object.defineProperties(I,{layerX:{value:E,configurable:!0},layerY:{value:L,configurable:!0},x:{value:E,configurable:!0},y:{value:L,configurable:!0}}),R}forceUpdate(){if(!this[m])if(this.parent&&this.parent.hasOffscreenCanvas){this.parent.forceUpdate();let I=null;const b=new Promise(E=>{I=E});b._resolve=I,this[m]=b}else{let I=null,b=null;const E=new Promise(L=>{I=L,this[y]&&(b=Object(a.requestAnimationFrame)(()=>{delete E._requestID,this.render()}))});E._resolve=I,E._requestID=b,this[m]=E}}getFBO(){const I=this.renderer.glRenderer,{width:b,height:E}=this.getResolution();return I&&(!this[h]||this[h].width!==b||this[h].height!==E)?(this[h]={width:b,height:E,target:I.createFBO(),buffer:I.createFBO(),swap(){[this.target,this.buffer]=[this.buffer,this.target]}},this[h]):this[h]?this[h]:null}updateGlobalTransform(){if(this.layerTransformInvert){const I=this.renderer,b=I.__globalTransformMatrix||I.globalTransformMatrix;I.__globalTransformMatrix=b;const E=i.mat2d.fromValues(1,0,0,1,0,0);I.setGlobalTransform(...i.mat2d.multiply(E,b,this.transformMatrix))}}onPropertyChange(I,b,E){if(super.onPropertyChange(I,b,E),I==="zIndex"&&(this.canvas.style.zIndex=b),I==="transform"||I==="translate"||I==="rotate"||I==="scale"||I==="skew"){const L=this[g];if(this[g]=null,this.updateGlobalTransform(),L&&!this.layerTransformInvert){const D=this.renderer,R=D.__globalTransformMatrix||D.globalTransformMatrix;D.setGlobalTransform(...R)}}}_prepareRenderFinished(){this[m]&&(this[m]._requestID&&Object(a.cancelAnimationFrame)(this[m]._requestID),this[m]._resolve(),delete this[m])}render({clear:I=!0}={}){const b=this[c].length?this.getFBO():null;b&&this.renderer.glRenderer.bindFBO(b.target),I&&this[O].clear();const E=this.draw();if(E&&E.length&&(this.renderer.drawMeshes(E),this.canvas.draw&&this.canvas.draw()),b){const L=this.renderer.glRenderer,D=this[c].length,{width:R,height:C}=this.getResolution(),W=[0,0,R/this.displayRatio,C/this.displayRatio];this[c].forEach((z,H)=>{z.blend=!0,z.setTexture(b.target.texture,{rect:W}),H===D-1?L.bindFBO(null):(b.swap(),L.bindFBO(b.target)),this[O].clear(),this.renderer.drawMeshes([z])})}this._prepareRenderFinished()}setResolution({width:I,height:b}){const E=this.renderer,L=E.__globalTransformMatrix||E.globalTransformMatrix,D=L[4],R=L[5],C=L[0],{width:W,height:z}=this.getResolution();(W!==I||z!==b)&&(super.setResolution({width:I,height:b}),this.canvas&&(this.canvas.width=I,this.canvas.height=b,E.updateResolution&&E.updateResolution()),this.attributes.size=[I,b],this[c].length&&this[c].forEach(j=>{const G=new e.Figure2D;G.rect(0,0,I/this.displayRatio,b/this.displayRatio),j.contours=G.contours}));const[H,X]=this.renderOffset,Z=this.displayRatio;(D!==H||R!==X||C!==Z)&&(E.setGlobalTransform(Z,0,0,Z,H,X),E.__globalTransformMatrix=null,this[g]=null,this.updateGlobalTransform(),this.forceUpdate())}tick(I=null,b={}){let{duration:E=1/0}=b,L=v(b,["duration"]);const D=this.timeline.fork(L),R=this;this[u]=this[u]||[],this[u].push({handler:I,duration:E});const C=()=>{let W=null,z=null;const H=()=>{const X=this[u].map(({handler:Z,duration:j})=>{const G=Math.min(1,D.currentTime/j);return{value:Z?Z(D.currentTime,G):null,p:G}});R[T]||(R[T]=Promise.resolve().then(()=>{R[y]&&R.render(),delete R[T];for(let Z=X.length-1;Z>=0;Z--){const{value:j,p:G}=X[Z];(j===!1||G>=1)&&this[u].splice(Z,1)}this[u].length>0&&C()}))};if(this[m]&&this[m]._type!=="ticker"&&(Object(a.cancelAnimationFrame)(this[m]._requestID),delete this[m]),!this[m]){const X=new Promise(Z=>{W=Z,z=Object(a.requestAnimationFrame)(H)});X._resolve=W,X._requestID=z,X._type="ticker",this[m]=X}};C()}toGlobalPos(I,b){if(this.layerTransformInvert){const W=this.transformMatrix;I=W[0]*I+W[2]*b+W[4],b=W[1]*I+W[3]*b+W[5]}const{width:E,height:L}=this.getResolution(),D=this.renderOffset,R=[this.canvas.clientWidth,this.canvas.clientHeight];I=I*R[0]/E+D[0],b=b*R[1]/L+D[1];const C=this.displayRatio;return I*=C,b*=C,[I,b]}toLocalPos(I,b){const{width:E,height:L}=this.getResolution(),D=this.renderOffset,R=[this.canvas.clientWidth,this.canvas.clientHeight];I=I*E/R[0]-D[0],b=b*L/R[1]-D[1];const C=this.displayRatio;I/=C,b/=C;const W=this.layerTransformInvert;return W&&(I=W[0]*I+W[2]*b+W[4],b=W[1]*I+W[3]*b+W[5]),[I,b]}}o.default.registerNode(M,"layer")},function(d,r,t){t.r(r),t.d(r,"default",function(){return m});var e=t(224),n=t(288),i=t(213),a=t(252),s=t(72);t(1).glMatrix.setMatrixArrayType(Array);function o(T,c){if(T==null)return{};var h=f(T,c),u,g;if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(T);for(g=0;g<M.length;g++)u=M[g],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(T,u)&&(h[u]=T[u])}return h}function f(T,c){if(T==null)return{};var h={},u=Object.keys(T),g,M;for(M=0;M<u.length;M++)g=u[M],!(c.indexOf(g)>=0)&&(h[g]=T[g]);return h}function v(T,c,h){return c in T?Object.defineProperty(T,c,{value:h,enumerable:!0,configurable:!0,writable:!0}):T[c]=h,T}const l="http://www.w3.org/2000/svg",p=Symbol.for("spritejs_setAttribute"),y=Symbol("root"),O=Symbol("task");function x(T,c=!0){const h=T[y];if(h&&h.children[0]){const u=T.svg,g=T.layer?T.layer.displayRatio:1;if(!u.hasAttribute("data-original-width")){let I=u.getAttribute("width");I=I?Object(s.sizeToPixel)(I):300;let b=u.getAttribute("height");b=b?Object(s.sizeToPixel)(b):150,u.hasAttribute("viewBox")||u.setAttribute("viewBox",`0 0 ${Math.round(I)} ${Math.round(b)}`),u.setAttribute("data-original-width",I),u.setAttribute("data-original-height",b)}let M=T.attributes.width||Number(u.getAttribute("data-original-width")),A=T.attributes.height||Number(u.getAttribute("data-original-height"));if(M*=g,A*=g,c&&T.attributes.flexible){const I=T.attributes.scale[0];if(M*=I,A*=I,u.setAttribute("width",M),u.setAttribute("height",A),M&&A&&T.textureImage){const b=T.textureImage.width,E=T.textureImage.height,L=T.clientSize;T.attributes.textureRect=[0,0,Math.round(L[0]*b/M),Math.round(L[1]*E/A)]}}else T[O]||(u.setAttribute("width",M),u.setAttribute("height",A),T[O]=Promise.resolve().then(()=>{delete T[O];const I=h.innerHTML,b=new Blob([I],{type:"image/svg+xml"}),E=URL.createObjectURL(b),L=new Image;L.onload=function(){L.width&&L.height?(T.attributes[p]("texture",L),T.attributes.flexible&&(T.attributes.textureRect=null)):T.attributes[p]("texture",null)},L.src=E}))}}class m extends e.default{constructor(c={}){typeof c=="string"&&(c={svgText:c});let{svgText:h}=c,u=o(c,["svgText"]);if(super(u),this[y]=document.createElement("div"),h){this[y].innerHTML=h;const g=this[y].children[0];g?g.setAttribute("xmlns",l):(fetch(h).then(M=>M.text()).then(M=>{this[y].innerHTML=M,(!this.observer||this.attributes.flexible)&&x(this)}),h=null)}if(!h){const g=document.createElementNS(l,"svg");g.setAttribute("xmlns",l),this[y].appendChild(g)}if(typeof MutationObserver=="function"){const g=new MutationObserver(M=>{x(this,!1)});g.observe(this[y],{attributes:!0,subtree:!0,characterData:!0,childList:!0}),this.observer=g}}get children(){return[this.svg]}get childNodes(){return[this.svg]}get svg(){return this[y]?this[y].children[0]:null}setResolution({width:c,height:h}){super.setResolution({width:c,height:h}),x(this)}dispatchPointerEvent(c){const h=super.dispatchPointerEvent(c);if(h&&this.attributes.passEvents&&typeof MouseEvent=="function"){const{x:u,y:g}=c;let[M,A]=this.getOffsetPosition(u,g);const I=c.originalEvent,b=this.attributes.anchor,E=this.clientSize;M=(M+b[0]*E[0])/2,A=(A+b[1]*E[1])/2;const L=c.type;if(L===I.type){let D=null;if(I instanceof MouseEvent)D=new MouseEvent(L,{screenX:M,screenY:A,clientX:M,clientY:A,bubbles:I.bubbles,button:I.button,buttons:I.buttons,cancelBubble:I.cancelBubble,cancelable:I.cancelable,currentTarget:I.currentTarget,fromElement:I.fromElement,relatedTarget:I.relatedTarget,returnValue:I.returnValue,srcElement:I.srcElement,target:I.target,toElement:I.toElement,which:I.witch});else if(I instanceof TouchEvent){let R=null;const C=I.changedTouches||[I];for(let W=0;W<C.length;W++){const z=C[W];if(c.identifier===z.identifier){R=z;break}}if(R){const W=new Touch({identifier:R.identifier,target:R.target,clientX:M,clientY:A,screenX:M,screenY:A,pageX:M,pageY:A,radiusX:R.radiusX,radiusY:R.radiusY,rotationAngle:R.rotationAngle,force:R.force});D=new TouchEvent(L,{cancelable:I.cancelable,bubbles:I.bubbles,composed:I.composed,touches:[W],targetTouches:[W],changedTouches:[W]})}}else D=I;D&&this.svg.dispatchEvent(D)}}return h}getElementById(c){return Object(a.querySelector)(`#${c}`,this)}getElementsByClassName(c){return Object(a.querySelectorAll)(`.${c}`,this)}getElementsByName(c){return Object(a.querySelectorAll)(`[name="${c}"]`,this)}getElementsByTagName(c){return Object(a.querySelectorAll)(c,this)}querySelector(c){return Object(a.querySelector)(c,this)}querySelectorAll(c){return Object(a.querySelectorAll)(c,this)}onPropertyChange(c,h,u){super.onPropertyChange(c,h,u),c==="flexible"&&x(this),this.attributes.flexible&&(c==="width"||c==="height"||c==="scale"||c==="transform")&&x(this)}}v(m,"Attr",n.default),i.default.registerNode(m,"spritesvg")},function(d,r,t){t.r(r),t.d(r,"default",function(){return s});var e=t(225);t(1).glMatrix.setMatrixArrayType(Array);const n=Symbol.for("spritejs_getAttribute"),i=Symbol.for("spritejs_setAttribute"),a=Symbol.for("spritejs_setAttributeDefault");class s extends e.default{constructor(f){super(f),this[a]({passEvents:!1,flexible:!1})}get texture(){return this[n]("texture")}set texture(f){}get passEvents(){return this[n]("passEvents")}set passEvents(f){return this[i]("passEvents",f)}get flexible(){return this[n]("flexible")}set flexible(f){return this[i]("flexible",f)}}},function(d,r,t){t.r(r);var e=t(12);t(1).glMatrix.setMatrixArrayType(Array);function n(f,v){var l=Object.keys(f);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(f);v&&(p=p.filter(function(y){return Object.getOwnPropertyDescriptor(f,y).enumerable})),l.push.apply(l,p)}return l}function i(f){for(var v=1;v<arguments.length;v++){var l=arguments[v]!=null?arguments[v]:{};v%2?n(Object(l),!0).forEach(function(p){a(f,p,l[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(l)):n(Object(l)).forEach(function(p){Object.defineProperty(f,p,Object.getOwnPropertyDescriptor(l,p))})}return f}function a(f,v,l){return v in f?Object.defineProperty(f,v,{value:l,enumerable:!0,configurable:!0,writable:!0}):f[v]=l,f}const s=Symbol("inited");let o=null;typeof Worker=="function"&&(o=class extends Worker{constructor(f){if(f.worker===!0&&(f.worker=`./${f.id}.worker.js`),super(f.worker),this.options=f,!f.canvas){const{width:v,height:l}=this.getResolution(),p=e.ENV.createCanvas(v,l,{offscreen:!1});p.style&&(p.style.position="absolute"),p.dataset&&(p.dataset.layerId=f.id),f.canvas=p}this.canvas=f.canvas}get id(){return this.options.id}setResolution({width:f,height:v}){if(this[s])this.postMessage({type:"resolution_change",width:f,height:v});else{this.canvas.width=f,this.canvas.height=v;const l=this.options,p=l.canvas.transferControlToOffscreen(),y=i({},l);delete y.container,y.canvas=p,this.postMessage({type:"create",options:y},[p]),this[s]=!0}}getResolution(){if(this.canvas){const{width:f,height:v}=this.canvas;return{width:f,height:v}}return{width:300,height:150}}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}connect(f,v){Object.defineProperty(this,"parent",{value:f,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:v,writable:!1,configurable:!0})}disconnect(){delete this.parent,delete this.zOrder}dispatchPointerEvent(f){this.postMessage({type:"event",event:{cancelBubble:f.cancelBubble,bubbles:f.bubbles,detail:f.detail,identifier:f.identifier,layerX:f.layerX,layerY:f.layerY,originalX:f.originalX,originalY:f.originalY,type:f.type,x:f.x,y:f.y}})}}),r.default=o},function(d,r,t){t.r(r),(function(e){t.d(r,"default",function(){return M});var n=t(12),i=t(68),a=t(70),s=t(286),o=t(289),f=t(250),v=t(291),l=t(214),p=t(218),y=t(213);t(1).glMatrix.setMatrixArrayType(Array);const O=Symbol("enteredTargets");function x(A){return A.id=A.id||`_layer${Math.random().toString(36).slice(2,12)}`,A.dataset||(A.dataset={}),A.dataset.layerId=A.id,A.connect=(I,b)=>{A.parent=I,Object.defineProperty(A,"zOrder",{value:b,writable:!1,configurable:!0})},A.disconnect=I=>{delete A.zOrder},A.canvas=A,A.getResolution=()=>({width:0,height:0}),A.setResolution=()=>!1,A.options={handleEvent:!1},A}function m(A,I){const b=A.children;let E=null;for(let L=0;L<b.length;L++){const D=b[L];if((I===D||E!=null)&&(E=D),E&&E!==I&&!E.offscreen)return E.canvas}return null}function T(A,I){const[b,E]=A.renderOffset,{width:L,height:D}=A.getResolution(),R=A.displayRatio;A.renderer.drawImage(I.canvas,-b/R,-E/R,L/R,D/R)}const c={};function h(A){const I=["mousedown","mouseup","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel","click","dblclick","longpress","tap","contextmenu"],b=A.container;b.addEventListener("mouseleave",E=>{const L=A[O];if(L.size){const D=new l.default("mouseleave");D.setOriginalEvent(E),[...L].forEach(R=>{R.dispatchEvent(D)}),A[O].clear()}},{passive:!0}),I.forEach(E=>{b.addEventListener(E,L=>{const{left:D,top:R,displayRatio:C}=A.options,W=A.orderedChildren;Object(v.default)(L,{offsetLeft:D,offsetTop:R,displayRatio:C}).forEach(H=>{const X=H.identifier;if(H.type==="touchmove"||H.type==="touchend"){const j=c[X];j&&j.dispatchEvent(H),H.type==="touchend"&&delete c[X]}else{for(let j=W.length-1;j>=0;j--){const G=W[j];if(G.options.handleEvent!==!1){if(G.dispatchPointerEvent(H)&&H.target!==G)break;H.cancelBubble=!1}}if(H.target===W[0])for(let j=W.length-1;j>=0;j--){const G=W[j];if(G.options.handleEvent!==!1){H.target=G;break}}}const Z=H.target;if(H.type==="touchstart"&&(c[X]=H.target),H.type==="mousemove"){const j=A[O];let G;if(Z){const et=Z.ancestors||[];G=new Set([Z,...et])}else G=new Set;const Q=Object.entries(L);if(!j.has(Z)&&Z){const et=new l.default("mouseenter");et.setOriginalEvent(L),Q.forEach(([q,pt])=>{et[q]=pt}),j.add(Z),Z.dispatchEvent(et);const at=Z.ancestors;at&&at.forEach(q=>{q instanceof a.default&&!j.has(q)&&(j.add(q),q.dispatchEvent(et))})}const tt=new l.default("mouseleave");tt.setOriginalEvent(L),Q.forEach(([et,at])=>{tt[et]=at}),[...j].forEach(et=>{G.has(et)||(j.delete(et),et.dispatchEvent(tt))})}})},{passive:E!=="contextmenu"})})}function u(A,I){if(I&&I.style){let{width:b,height:E,mode:L,container:D}=A;const{clientWidth:R,clientHeight:C}=D;b=b||R,E=E||C,L==="static"?(I.style.width=`${b}px`,I.style.height=`${E}px`):(I.style.top="0",I.style.left="0",I.style.width=`${R}px`,I.style.height=`${C}px`,I.style.transform="",I.style.webkitTransform="")}}const g=Symbol("offscreenLayerCount");class M extends f.default{constructor(I={}){if(super(),!I.container)if(typeof n.ENV.Container=="function")I.container=new n.ENV.Container(I.width||300,I.height||150);else throw new Error("No container specified.");if(this.container=I.container,this.container.style&&(this.container.style.overflow||(this.container.style.overflow="hidden"),this.container.style.position||(this.container.style.position="relative")),this.options=I,I.displayRatio=I.displayRatio||1,I.mode=I.mode||"scale",I.left=0,I.top=0,I.autoResize=I.autoResize!==!1,I.autoResize){let b;if(typeof globalThis<"u"?b=globalThis:b=typeof window<"u"?window:e,b.addEventListener){const E=this;b.addEventListener("resize",function L(){typeof document<"u"&&document.contains(E.container)?E.resize():b.removeEventListener("resize",L)})}}this[O]=new Set,this.setResolution(I),h(this),this[g]=0}get hasOffscreenCanvas(){return this[g]>0}set displayRatio(I){this.options.displayRatio!==I&&(this.options.displayRatio=I,this.resize())}get displayRatio(){return this.options.displayRatio}set height(I){this.options.height!==I&&(this.options.height=I,this.resize())}get height(){return this.options.height}set mode(I){this.options.mode!==I&&(this.options.mode=I,this.resize())}get mode(){return this.options.mode}set width(I){this.options.width!==I&&(this.options.width=I,this.resize())}get width(){return this.options.width}appendChild(I){!(I instanceof s.default)&&!(I instanceof o.default)&&x(I);const b=super.appendChild(I),E=I.canvas;return I.offscreen?this[g]++:this.container.appendChild(E),u(this.options,E),I.setResolution(this.getResolution()),b}forceUpdate(){this.hasOffscreenCanvas&&!this._requestID&&(this._requestID=Object(i.requestAnimationFrame)(()=>{delete this._requestID,this.render()}))}insertBefore(I,b){!(I instanceof s.default)&&!(I instanceof o.default)&&x(I);const E=super.insertBefore(I,b),L=I.canvas;if(!I.offscreen){const D=m(this,I);this.container.insertBefore(L,D)}return u(this.options,L),I.setResolution(this.getResolution()),E}layer(I="default",b={}){b=Object.assign({},this.options,b),b.id=I;const E=this.orderedChildren;for(let R=0;R<E.length;R++)if(E[R].id===I)return E[R];const L=b.worker;let D;return L?D=new o.default(b):D=new s.default(b),this.appendChild(D),D}async preload(...I){const b=[],E=[],L=[];for(let D=0;D<I.length;D++){const R=I[D];let C;if(typeof R=="string")C=Object(p.loadTexture)(R);else if(Array.isArray(R))C=Object(p.loadFrames)(...R);else{const{id:W,src:z}=R;C=Object(p.loadTexture)(z,W)}C instanceof Promise||(C=Promise.resolve(C)),E.push(C.then(W=>{b.push(W),L[D]=W;const z=new l.default({type:"preload",detail:{current:W,loaded:b,resources:I}});this.dispatchEvent(z)}))}return await Promise.all(E),L}removeChild(I){const b=super.removeChild(I);if(b){I._prepareRenderFinished&&I._prepareRenderFinished();const E=I.canvas;E&&E.remove&&E.remove(),I.offscreen&&this[g]--}return b}render(){const I=this.orderedChildren;let b=null;const E=[];for(let L=0;L<I.length;L++){const D=I[L],R=E.length>0;if(D instanceof s.default&&!D.offscreen)if(!D.autoRender)R&&(console.warn("Some offscreen canvas will not be rendered."),E.length=0);else if(b=D,R){D.renderer.clear();for(let C=0;C<E.length;C++){const W=E[C];W.render(),T(D,W)}E.length=0,D.render({clear:!1})}else D.prepareRender&&D.render();else D.offscreen?b?(D.prepareRender&&D.render(),T(b,D)):E.push(D):D instanceof o.default&&R&&(console.warn("Some offscreen canvas will not be rendered."),E.length=0)}}replaceChild(I,b){const E=super.replaceChild(I,b);b.canvas.remove&&b.canvas.remove(),b.offscreen&&this[g]--;const L=I.canvas;if(!I.offscreen){const D=m(this,I);this.container.insertBefore(L,D)}return u(this.options,L),I.setResolution(this.getResolution()),E}resize(){const I=this.options;this.children.forEach(b=>{u(I,b.canvas)}),this.setResolution(I),this.dispatchEvent({type:"resize"})}setResolution({width:I,height:b}={}){const E=this.container,{clientWidth:L,clientHeight:D}=E;(I==null||b==null)&&(I=I??L,b=b??D);const{mode:R,displayRatio:C}=this.options;if(I*=C,b*=C,this.options.left=0,this.options.top=0,R==="stickyHeight"||R==="stickyLeft"||R==="stickyRight"){const W=I;I=L*b/D,R==="stickyHeight"&&(this.options.left=.5*(I-W)),R==="stickyRight"&&(this.options.left=I-W)}else if(R==="stickyWidth"||R==="stickyTop"||R==="stickyBottom"){const W=b;b=D*I/L,R==="stickyWidth"&&(this.options.top=.5*(b-W)),R==="stickyBottom"&&(this.options.top=b-W)}super.setResolution({width:I,height:b})}snapshot({offscreen:I=!1,layers:b}={}){const E=I?"snapshotOffScreenCanvas":"snapshotCanvas",{width:L,height:D}=this.getResolution();this[E]=this[E]||n.ENV.createCanvas(L,D,{offscreen:I});const R=this[E].getContext("2d");b=b||this.orderedChildren,this[E].width=L,this[E].height=D;for(let C=0;C<b.length;C++){const W=b[C];if(!W.options.ignoreSnapshot){W.render&&W.render();const z=W.canvas;z&&z!==W&&R.drawImage(z,0,0,L,D)}}return this[E]}}typeof document<"u"&&(M.prototype.layer3d=function(A,I={}){const b=I.url||"https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.min.js";return new Promise((E,L)=>{const D=document.createElement("script");D.async=!1,D.src=b,D.onload=()=>{try{E(this.layer3d(A,I))}catch(R){L(R)}},document.documentElement.appendChild(D)})}),y.default.registerNode(M,"scene")}).call(this,t(22))},function(d,r,t){t.r(r),t.d(r,"default",function(){return n});var e=t(214);t(1).glMatrix.setMatrixArrayType(Array);function n(i,{offsetTop:a=0,offsetLeft:s=0,displayRatio:o=1}={}){let f,v;const l=[],{left:p,top:y,width:O,height:x}=i.target.getBoundingClientRect(),m=i.target.width,T=i.target.height,c=i.changedTouches||[i];for(let u=0;u<c.length;u++){const g=c[u],M=g.identifier,{clientX:A,clientY:I}=g;A!=null&&I!=null&&l.push({x:Math.round((A|0)-p),y:Math.round((I|0)-y),identifier:M})}l.length<=0&&l.push({x:f,y:v});const h=[];return l.forEach(u=>{u.x!=null&&u.y!=null&&(f=(u.x*m/O-s)/o,v=(u.y*T/x-a)/o);const g=new e.default(i);Object.defineProperties(g,{layerX:{value:f,configurable:!0},layerY:{value:v,configurable:!0},originalX:{value:u.x},originalY:{value:u.y},x:{value:f,configurable:!0},y:{value:v,configurable:!0},identifier:{value:u.identifier}}),h.push(g)}),h}}]);Dt.version,Dt.Arc,Dt.Block,Dt.Cloud,Dt.Color;const Gh=Dt.Ellipse;Dt.Gradient;const se=Dt.Group,Hh=Dt.Label;Dt.Layer,Dt.LayerWorker,Dt.Node,Dt.Parallel;const ge=Dt.Path,pe=Dt.Polyline,hr=Dt.Rect;Dt.Regular,Dt.Ring;const Kh=Dt.Scene,Vh=Dt.Sprite;Dt.SpriteSvg,Dt.Star,Dt.Triangle,Dt.helpers,Dt.createElement,Dt.isSpriteNode,Dt.registerNode,Dt.requestAnimationFrame,Dt.cancelAnimationFrame,Dt.ENV;function Oe(d,r=!0){const t=d.length;if(t<2)return"";let e=d[0],n=d[1];if(t===2)return`M${Te(e)}L${Te(n)}`;let i="";for(let a=2,s=t-1;a<s;a++)e=d[a],n=d[a+1],i+=Me(e,n);return r?`M${Me(d[0],d[1])}Q${Te(d[1])}${Me(d[1],d[2])}T${i}${Me(d[t-1],d[0])}${Me(d[0],d[1])}Z`:`M${Te(d[0])}Q${Te(d[1])}${Me(d[1],d[2])}${d.length>3?"T":""}${i}L${Te(d[t-1])}`}var dr={exports:{}};dr.exports,function(d){var r=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function a(o,f){if(!i[o]){i[o]={};for(var v=0;v<o.length;v++)i[o][o.charAt(v)]=v}return i[o][f]}var s={compressToBase64:function(o){if(o==null)return"";var f=s._compress(o,6,function(v){return e.charAt(v)});switch(f.length%4){default:case 0:return f;case 1:return f+"===";case 2:return f+"==";case 3:return f+"="}},decompressFromBase64:function(o){return o==null?"":o==""?null:s._decompress(o.length,32,function(f){return a(e,o.charAt(f))})},compressToUTF16:function(o){return o==null?"":s._compress(o,15,function(f){return t(f+32)})+" "},decompressFromUTF16:function(o){return o==null?"":o==""?null:s._decompress(o.length,16384,function(f){return o.charCodeAt(f)-32})},compressToUint8Array:function(o){for(var f=s.compress(o),v=new Uint8Array(f.length*2),l=0,p=f.length;l<p;l++){var y=f.charCodeAt(l);v[l*2]=y>>>8,v[l*2+1]=y%256}return v},decompressFromUint8Array:function(o){if(o==null)return s.decompress(o);for(var f=new Array(o.length/2),v=0,l=f.length;v<l;v++)f[v]=o[v*2]*256+o[v*2+1];var p=[];return f.forEach(function(y){p.push(t(y))}),s.decompress(p.join(""))},compressToEncodedURIComponent:function(o){return o==null?"":s._compress(o,6,function(f){return n.charAt(f)})},decompressFromEncodedURIComponent:function(o){return o==null?"":o==""?null:(o=o.replace(/ /g,"+"),s._decompress(o.length,32,function(f){return a(n,o.charAt(f))}))},compress:function(o){return s._compress(o,16,function(f){return t(f)})},_compress:function(o,f,v){if(o==null)return"";var l,p,y={},O={},x="",m="",T="",c=2,h=3,u=2,g=[],M=0,A=0,I;for(I=0;I<o.length;I+=1)if(x=o.charAt(I),Object.prototype.hasOwnProperty.call(y,x)||(y[x]=h++,O[x]=!0),m=T+x,Object.prototype.hasOwnProperty.call(y,m))T=m;else{if(Object.prototype.hasOwnProperty.call(O,T)){if(T.charCodeAt(0)<256){for(l=0;l<u;l++)M=M<<1,A==f-1?(A=0,g.push(v(M)),M=0):A++;for(p=T.charCodeAt(0),l=0;l<8;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}else{for(p=1,l=0;l<u;l++)M=M<<1|p,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=0;for(p=T.charCodeAt(0),l=0;l<16;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}c--,c==0&&(c=Math.pow(2,u),u++),delete O[T]}else for(p=y[T],l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;c--,c==0&&(c=Math.pow(2,u),u++),y[m]=h++,T=String(x)}if(T!==""){if(Object.prototype.hasOwnProperty.call(O,T)){if(T.charCodeAt(0)<256){for(l=0;l<u;l++)M=M<<1,A==f-1?(A=0,g.push(v(M)),M=0):A++;for(p=T.charCodeAt(0),l=0;l<8;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}else{for(p=1,l=0;l<u;l++)M=M<<1|p,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=0;for(p=T.charCodeAt(0),l=0;l<16;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1}c--,c==0&&(c=Math.pow(2,u),u++),delete O[T]}else for(p=y[T],l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;c--,c==0&&(c=Math.pow(2,u),u++)}for(p=2,l=0;l<u;l++)M=M<<1|p&1,A==f-1?(A=0,g.push(v(M)),M=0):A++,p=p>>1;for(;;)if(M=M<<1,A==f-1){g.push(v(M));break}else A++;return g.join("")},decompress:function(o){return o==null?"":o==""?null:s._decompress(o.length,32768,function(f){return o.charCodeAt(f)})},_decompress:function(o,f,v){var l=[],p=4,y=4,O=3,x="",m=[],T,c,h,u,g,M,A,I={val:v(0),position:f,index:1};for(T=0;T<3;T+=1)l[T]=T;for(h=0,g=Math.pow(2,2),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;switch(h){case 0:for(h=0,g=Math.pow(2,8),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;A=t(h);break;case 1:for(h=0,g=Math.pow(2,16),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;A=t(h);break;case 2:return""}for(l[3]=A,c=A,m.push(A);;){if(I.index>o)return"";for(h=0,g=Math.pow(2,O),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;switch(A=h){case 0:for(h=0,g=Math.pow(2,8),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;l[y++]=t(h),A=y-1,p--;break;case 1:for(h=0,g=Math.pow(2,16),M=1;M!=g;)u=I.val&I.position,I.position>>=1,I.position==0&&(I.position=f,I.val=v(I.index++)),h|=(u>0?1:0)*M,M<<=1;l[y++]=t(h),A=y-1,p--;break;case 2:return m.join("")}if(p==0&&(p=Math.pow(2,O),O++),l[A])x=l[A];else if(A===y)x=c+c.charAt(0);else return null;m.push(x),l[y++]=c+x.charAt(0),p--,c=x,p==0&&(p=Math.pow(2,O),O++)}}};return s}();d!=null?d.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}(dr);var Mn=dr.exports;function Ie(d){return JSON.parse(Mn.decompress(d))}function qt(d){return Mn.compress(JSON.stringify(d))}class On extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Pencil);nt(this,"syncTimestamp");nt(this,"syncIndex",0);nt(this,"tmpPoints",[]);nt(this,"MAX_REPEAR",10);nt(this,"uniThickness");nt(this,"workOptions");nt(this,"centerPos",[0,0]);this.workOptions=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var s;const t=(s=this.workId)==null?void 0:s.toString(),e=this.transformDataAll(!0),n={name:t};let i;const a=this.drawLayer||this.fullLayer;return e.length&&(i=this.draw({attrs:n,tasks:e,replaceId:t,layer:a})),{rect:i,type:ct.DrawWork,dataType:Tt.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){var c;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a,drawCount:s,replaceId:o}=t;if(((c=e.op)==null?void 0:c.length)===0)return{type:ct.None};const{workId:f}=e,{tasks:v,effects:l,consumeIndex:p}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,p,Math.max(0,this.tmpPoints.length-2));const y={name:f==null?void 0:f.toString(),id:s==null?void 0:s.toString()};let O,x=!1;const m=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),v.length&&(v[0].taskId-this.syncTimestamp>this.syncUnitTime&&(x=!0,this.syncTimestamp=v[0].taskId,this.syncIndex=this.tmpPoints.length),i||a)){const h=n?this.fullLayer:this.drawLayer||this.fullLayer;O=this.draw({attrs:y,tasks:v,effects:l,layer:h,replaceId:o})}if(i)return p>10&&this.tmpPoints.splice(0,p-10),{rect:O,type:ct.DrawWork,dataType:Tt.Local};const T=[];return this.tmpPoints.slice(m).forEach(h=>{T.push(h.x,h.y,this.computRadius(h.z,this.workOptions.thickness))}),{rect:O,type:ct.DrawWork,dataType:Tt.Local,workId:x?f:void 0,op:x?T:void 0,index:x?m*3:void 0}}consumeAll(t){var v,l;if(t.data){const{op:p,workState:y}=t.data;p!=null&&p.length&&y===Rt.Done&&this.workOptions.strokeType===Vt.Stroke&&this.updateTempPointsWithPressureWhenDone(p)}const e=(v=this.workId)==null?void 0:v.toString();if(!e)return{type:ct.None};const n=this.transformDataAll(!0),i={name:e};let a;const s=this.fullLayer;n.length&&(a=this.draw({attrs:i,tasks:n,replaceId:e,layer:s}));const o=[];this.tmpPoints.map(p=>{o.push(p.x,p.y,this.computRadius(p.z,this.workOptions.thickness))}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const f=qt(o);return(l=this.vNodes)==null||l.setInfo(e,{rect:a,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,s)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:e,ops:f,updateNodeOpt:{pos:this.centerPos,useAnimation:!0},opt:this.workOptions}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var v,l;const{op:e,isFullWork:n,replaceId:i}=t;this.tmpPoints.length=0;for(let p=0;p<e.length;p+=3){const y=new xt(e[p],e[p+1],e[p+2]);if(this.tmpPoints.length>0){const O=this.tmpPoints[this.tmpPoints.length-1],x=_.Sub(y,O).uni();y.setv(x)}this.tmpPoints.push(y)}const a=this.transformDataAll(!1),s=(v=this.workId)==null?void 0:v.toString(),o={name:s};let f;if(s&&a.length){const p=n?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:o,tasks:a,replaceId:i,layer:p}),(l=this.vNodes)==null||l.setInfo(s,{rect:f,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&yt.getCenterPos(f,p)})}return f}transformDataAll(t=!0){return this.getTaskPoints(this.tmpPoints,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:n,replaceId:i,effects:a,layer:s}=t,{strokeColor:o,strokeType:f,thickness:v,zIndex:l,scale:p,rotate:y,translate:O}=this.workOptions;a!=null&&a.size&&(a.forEach(u=>{var g;(g=s.getElementById(u+""))==null||g.remove()}),a.clear());let x;const m=[],T=s.worldPosition,c=s.worldScaling;for(let u=0;u<n.length;u++){const{pos:g,points:M}=n[u],{ps:A,rect:I}=this.computDrawPoints(M);let b;const E=M.length===1;f===Vt.Stroke||E?b=Oe(A,!0):b=Oe(A,!1);const L={pos:g,d:b,fillColor:f===Vt.Stroke||E?o:void 0,lineDash:f===Vt.Dotted&&!E?[1,v*2]:f===Vt.LongDotted&&!E?[v,v*2]:void 0,strokeColor:o,lineCap:f===Vt.Stroke||E?void 0:"round",lineWidth:f===Vt.Stroke||E?0:v};x=Ot(x,{x:Math.floor((I.x+g[0])*c[0]+T[0]-yt.SafeBorderPadding),y:Math.floor((I.y+g[1])*c[1]+T[1]-yt.SafeBorderPadding),w:Math.floor(I.w*c[0]+2*yt.SafeBorderPadding),h:Math.floor(I.h*c[1]+2*yt.SafeBorderPadding)}),m.push(L)}p&&(e.scale=p),y&&(e.rotate=y),O&&(e.translate=O);const h=new se;if(x){this.centerPos=yt.getCenterPos(x,s),h.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:f===Vt.Stroke?o:void 0,pos:this.centerPos,size:[(x.w-2*yt.SafeBorderPadding)/c[0],(x.h-2*yt.SafeBorderPadding)/c[1]],zIndex:l});const u=m.map(g=>(g.pos=[g.pos[0]-this.centerPos[0],g.pos[1]-this.centerPos[1]],new ge(g)));h.append(...u),f===Vt.Stroke&&h.seal(),this.replace(s,i||e.workId,h)}if(p||y||O){const u=h==null?void 0:h.getBoundingClientRect();if(u)return{x:Math.floor(u.x-yt.SafeBorderPadding),y:Math.floor(u.y-yt.SafeBorderPadding),w:Math.floor(u.width+yt.SafeBorderPadding*2),h:Math.floor(u.height+yt.SafeBorderPadding*2)}}return x}computDrawPoints(t){return this.workOptions.strokeType===Vt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const n=t.map(i=>(e=Math.max(e,i.radius),i.point));return{ps:n,rect:wt(n,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],n=[];for(let f=0;f<t.length;f++){const{point:v,radius:l}=t[f];let p=v.v;f===0&&t.length>1&&(p=t[f+1].point.v);const y=_.Per(p).mul(l);e.push(xt.Sub(v,y)),n.push(xt.Add(v,y))}const i=t[t.length-1],a=xt.GetSemicircleStroke(i.point,e[e.length-1],-1,8),s=xt.GetSemicircleStroke(t[0].point,n[0],-1,8),o=e.concat(a,n.reverse(),s);return{ps:o,rect:wt(o)}}computDotStroke(t){const{point:e,radius:n}=t,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i}}transformData(t,e){const{op:n,workState:i}=t;let a=this.tmpPoints.length-1,s=[];if(n!=null&&n.length&&i){const{strokeType:o,thickness:f}=this.workOptions,v=new Set;a=o===Vt.Stroke?this.updateTempPointsWithPressure(n,f,v):this.updateTempPoints(n,f,v);const l=e?this.tmpPoints:this.tmpPoints.slice(a);return s=this.getTaskPoints(l,f),{tasks:s,effects:v,consumeIndex:a}}return{tasks:s,consumeIndex:a}}computRadius(t,e){return t*.03*e+e*.5}getMinZ(t,e){return((e||Math.max(1,Math.floor(t*.3)))-t*.5)*100/t/3}getTaskPoints(t,e){var l;const n=[];if(t.length===0)return[];let i=0,a=t[0].x,s=t[0].y,o=[a,s],f=[],v=t[0].t;for(;i<t.length;){const p=t[i],y=p.x-a,O=p.y-s,x=p.z,m=e?this.computRadius(x,e):x;if(f.push({point:new xt(y,O,x,t[i].v),radius:m}),i>0&&i<t.length-1){const T=t[i].getAngleByPoints(t[i-1],t[i+1]);if(T<90||T>270){const c=(l=f.pop())==null?void 0:l.point.clone();c&&n.push({taskId:v,pos:o,points:[...f,{point:c,radius:m}]}),a=t[i].x,s=t[i].y,o=[a,s];const h=p.x-a,u=p.y-s;f=[{point:new xt(h,u,x),radius:m}],v=Date.now()}}i++}return n.push({taskId:v,pos:o,points:f}),n}updateTempPointsWithPressure(t,e,n){const i=Date.now(),a=this.tmpPoints.length;let s=a;for(let f=0;f<t.length;f+=2){s=Math.min(s,a);const v=this.tmpPoints.length,l=new xt(t[f],t[f+1]);if(v===0){this.tmpPoints.push(l);continue}const p=v-1,y=this.tmpPoints[p],O=_.Sub(l,y).uni();if(l.isNear(y,e)){if(y.z<this.MAX_REPEAR){if(y.setz(Math.min(y.z+1,this.MAX_REPEAR)),s=Math.min(s,p),v>1){let T=v-1;for(;T>0;){const c=this.tmpPoints[T].distance(this.tmpPoints[T-1]),h=Math.max(this.tmpPoints[T].z-this.uniThickness*c,0);if(this.tmpPoints[T-1].z>=h)break;this.tmpPoints[T-1].setz(h),s=Math.min(s,T-1),T--}}}else s=1/0;continue}l.setv(O);const x=l.distance(y),m=Math.max(y.z-this.uniThickness*x,0);v>1&&_.Equals(O,y.v,.02)&&(m>0||y.z<=0)&&(n&&y.t&&n.add(y.t),this.tmpPoints.pop(),s=Math.min(p,s)),l.setz(m),this.tmpPoints.push(l)}if(s===1/0)return this.tmpPoints.length;let o=a;if(s===a){o=Math.max(o-1,0);const f=this.tmpPoints[o].t;f&&(n==null||n.add(f))}else{let f=a-1;for(o=s;f>=0;){const v=this.tmpPoints[f].t;if(v&&(n==null||n.add(v),f<=s)){o=f,f=-1;break}f--}}return this.tmpPoints[o].setT(i),o}updateTempPoints(t,e,n){var f;const i=Date.now(),a=this.tmpPoints.length;let s=a;for(let v=0;v<t.length;v+=2){const l=this.tmpPoints.length,p=new xt(t[v],t[v+1]);if(l===0){this.tmpPoints.push(p);continue}const y=l-1,O=this.tmpPoints[y],x=_.Sub(p,O).uni();if(p.isNear(O,e/2)){s=Math.min(y,s);continue}_.Equals(x,O.v,.02)&&(n&&O.t&&n.add(O.t),this.tmpPoints.pop(),s=Math.min(y,s)),p.setv(x),this.tmpPoints.push(p)}let o=a;if(s===a){o=Math.max(o-1,0);const v=this.tmpPoints[o].t;v&&(n==null||n.add(v))}else{let v=Math.min(a-1,s);for(o=s;v>=0;){const l=(f=this.tmpPoints[v])==null?void 0:f.t;if(l&&(n==null||n.add(l),v<=s)){o=v,v=-1;break}v--}}return this.tmpPoints[o].setT(i),o}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,n=t.length,i=this.getMinZ(e);for(let a=0;a<n;a+=2){const s=this.tmpPoints.length,o=new xt(t[a],t[a+1]);if(s===0){this.tmpPoints.push(o);continue}const f=s-1,v=this.tmpPoints[f],l=_.Sub(o,v).uni(),p=o.distance(v);if(s>1&&v.z===i)break;if(o.isNear(v,e/2)){if(n<3&&v.z<this.MAX_REPEAR&&(v.setz(Math.min(v.z+1,this.MAX_REPEAR)),s>1)){let O=s-1;for(;O>0;){const x=this.tmpPoints[O].distance(this.tmpPoints[O-1]),m=Math.max(this.tmpPoints[O].z-this.uniThickness*x,-e/4);if(this.tmpPoints[O-1].z>=m)break;this.tmpPoints[O-1].setz(m),O--}}continue}o.setv(l);const y=Math.max(v.z-this.uniThickness*p,i);s>1&&_.Equals(l,v.v,.02)&&v.z<=0&&this.tmpPoints.pop(),o.setz(y),this.tmpPoints.push(o)}}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.tagName==="GROUP"?Wh(e)?e.setAttribute("bgcolor",a):e.children.forEach(f=>{f.setAttribute("strokeColor",a),f.getAttribute("fillColor")&&f.setAttribute("fillColor",a)}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a)),s&&i.setInfo(e.name,s),yt.updateNodeOpt(t)}}class En extends yt{constructor(t){super(t);nt(this,"toolsType",ht.LaserPen);nt(this,"canRotate",!1);nt(this,"scaleType",jt.none);nt(this,"syncTimestamp");nt(this,"syncIndex",0);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:n}=t,{workId:i,op:a}=e;if((a==null?void 0:a.length)===0)return{type:ct.None};if(this.updateTempPoints(a||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:ct.None};const{strokeColor:s,thickness:o,strokeType:f}=this.workOptions,v=wt(this.tmpPoints,o);let l=!1;const p=this.syncIndex,y=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const O={name:i==null?void 0:i.toString(),opacity:1,lineDash:f===Vt.Dotted?[1,o*2]:f===Vt.LongDotted?[o,o*2]:void 0,strokeColor:s,lineCap:"round",lineWidth:o,anchor:[.5,.5]},x=this.getTaskPoints(y);if(x.length){const T=Date.now();T-this.syncTimestamp>this.syncUnitTime&&(l=!0,this.syncTimestamp=T,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:O,tasks:x,isDot:!1,layer:this.drawLayer||this.fullLayer})}const m=[];return this.tmpPoints.slice(p).forEach(T=>{m.push(T.x,T.y)}),{rect:{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]},type:ct.DrawWork,dataType:Tt.Local,workId:l?i:void 0,op:l?m:void 0,index:l?p*2:void 0}}consumeAll(){var a;const t=(a=this.workId)==null?void 0:a.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let s=this.tmpPoints.slice(this.consumeIndex);const o=s.length===1,{strokeColor:f,thickness:v,strokeType:l}=this.workOptions;if(o){const O=this.computDotStroke({point:s[0],radius:v/2});s=O.ps,e=O.rect}else e=wt(this.tmpPoints,v);const p={name:t==null?void 0:t.toString(),fillColor:o?f:void 0,opacity:1,lineDash:l===Vt.Dotted&&!o?[1,v*2]:l===Vt.LongDotted&&!o?[v,v*2]:void 0,strokeColor:f,lineCap:o?void 0:"round",lineWidth:o?0:v,anchor:[.5,.5]},y=this.getTaskPoints(s);y.length&&this.draw({attrs:p,tasks:y,isDot:o,layer:this.drawLayer||this.fullLayer})}const n=[];this.tmpPoints.forEach(s=>{n.push(s.x,s.y)});const i=qt(n);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:ct.FullWork,dataType:Tt.Local,workId:t,ops:i,index:this.syncIndex*2}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var x;const{op:e,replaceId:n,isFullWork:i}=t,{strokeColor:a,thickness:s,strokeType:o}=this.workOptions;if(!e.length){const m=wt(this.tmpPoints,s);return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.h*this.fullLayer.worldScaling[1]}}const f=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);let v,l=this.tmpPoints.slice(f);const p=l.length===1;if(p){const m=this.computDotStroke({point:l[0],radius:s/2});l=m.ps,v=m.rect}else v=wt(this.tmpPoints,s);const y={name:(x=this.workId)==null?void 0:x.toString(),fillColor:p?a:void 0,opacity:1,lineDash:o===Vt.Dotted&&!p?[1,s*2]:o===Vt.LongDotted&&!p?[s,s*2]:void 0,strokeColor:a,lineCap:p?void 0:"round",lineWidth:p?0:s,anchor:[.5,.5]},O=this.getTaskPoints(l);if(O.length){const m=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:y,tasks:O,isDot:p,replaceId:n,layer:m})}return{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]}}computDotStroke(t){const{point:e,radius:n}=t,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i}}updateTempPoints(t){const e=this.tmpPoints.length;for(let n=0;n<t.length;n+=2){if(e){const i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new xt(t[n],t[n+1]))}}async draw(t){const{attrs:e,tasks:n,isDot:i,layer:a}=t,{duration:s}=this.workOptions;for(const o of n){const f=new ge,{pos:v,points:l}=o;let p;i?p=Oe(l,!0):p=Oe(l,!1),f.attr({...e,pos:v,d:p});const{vertex:y,fragment:O}=this.workOptions;if(y&&O){const x=a.renderer.createProgram({vertex:y,fragment:O}),{width:m,height:T}=a.getResolution();f.setUniforms({u_time:0,u_resolution:[m,T]}),f.setProgram(x)}a.appendChild(f),f.transition(s).attr({scale:i?[.1,.1]:[1,1],lineWidth:i?0:1}).then(()=>{f.remove()})}}getTaskPoints(t){var f;const e=[];if(t.length===0)return[];let n=0,i=t[0].x,a=t[0].y,s=[i,a],o=[];for(;n<t.length;){const v=t[n],l=v.x-i,p=v.y-a;if(o.push(new xt(l,p)),n>0&&n<t.length-1){const y=t[n].getAngleByPoints(t[n-1],t[n+1]);if(y<90||y>270){const O=(f=o.pop())==null?void 0:f.clone();O&&e.push({pos:s,points:[...o,O]}),i=t[n].x,a=t[n].y,s=[i,a];const x=v.x-i,m=v.y-a;o=[new xt(x,m)]}}n++}return e.push({pos:s,points:o}),e}removeLocal(){}removeService(t){let e;const n=[];return this.fullLayer.getElementsByName(t).forEach(i=>{if(i.name===t){const a=i.getBoundingClientRect();e=Ot(e,{x:a.x,y:a.y,w:a.width,h:a.height}),n.push(i)}}),n.length&&n.forEach(i=>i.remove()),e}}var Yh=Xe;Xe.polyline=Xe,Xe.polygon=Xh;function Xe(d,r,t){var e=d.length,n=Ee(d[0],r),i=[],a,s,o,f,v;for(t||(t=[]),a=1;a<e;a++){for(s=d[a-1],o=d[a],f=v=Ee(o,r);;)if(n|f){if(n&f)break;n?(s=gr(s,o,n,r),n=Ee(s,r)):(o=gr(s,o,f,r),f=Ee(o,r))}else{i.push(s),f!==v?(i.push(o),a<e-1&&(t.push(i),i=[])):a===e-1&&i.push(o);break}n=v}return i.length&&t.push(i),t}function Xh(d,r){var t,e,n,i,a,s,o;for(e=1;e<=8;e*=2){for(t=[],n=d[d.length-1],i=!(Ee(n,r)&e),a=0;a<d.length;a++)s=d[a],o=!(Ee(s,r)&e),o!==i&&t.push(gr(n,s,e,r)),o&&t.push(s),n=s,i=o;if(d=t,!d.length)break}return t}function gr(d,r,t,e){return t&8?[d[0]+(r[0]-d[0])*(e[3]-d[1])/(r[1]-d[1]),e[3]]:t&4?[d[0]+(r[0]-d[0])*(e[1]-d[1])/(r[1]-d[1]),e[1]]:t&2?[e[2],d[1]+(r[1]-d[1])*(e[2]-d[0])/(r[0]-d[0])]:t&1?[e[0],d[1]+(r[1]-d[1])*(e[0]-d[0])/(r[0]-d[0])]:null}function Ee(d,r){var t=0;return d[0]<r[0]?t|=1:d[0]>r[2]&&(t|=2),d[1]<r[1]?t|=4:d[1]>r[3]&&(t|=8),t}var Jh=Xt(Yh);const Pe=class Pe extends yt{constructor(t,e){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.none);nt(this,"toolsType",ht.Eraser);nt(this,"serviceWork");nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"worldPosition");nt(this,"worldScaling");nt(this,"eraserRect");nt(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],n=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:i,height:a}=Pe.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-i*.5,y:n-a*.5,w:i,h:a},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new _(this.tmpPoints[0],this.tmpPoints[1]),n=new _(this.tmpPoints[2],this.tmpPoints[3]),i=_.Sub(n,e).uni(),a=_.Dist(e,n),{width:s,height:o}=Pe.eraserSizes[this.workOptions.thickness],f=Math.min(s,o),v=Math.round(a/f);if(v>1){const l=[];for(let p=0;p<v;p++){const y=_.Mul(i,p*f);l.push(this.tmpPoints[0]+y.x,this.tmpPoints[1]+y.y)}return l.concat(t)}}return t}isNear(t,e){const n=new _(t[0],t[1]),i=new _(e[0],e[1]),{width:a,height:s}=Pe.eraserSizes[this.workOptions.thickness];return _.Dist(n,i)<Math.hypot(a,s)*.5}cutPolyline(t,e){let n=[e],i=0;for(;i<t.length;){const o=t[i];if(o.length<2)break;n=a(n,o),i++}return n;function a(o,f){const v=o;for(let l=0;l<o.length;l++){const p=o[l],y=p.findIndex((O,x)=>x<p.length-1?s([O,p[x+1]],[f[0],f[1]]):!1);if(y!==-1&&y>-1){const O=[],x=p.slice(0,y+1);if(_.Equals(p[y],f[0])||x.push(f[0].clone().setz(p[y].z)),x.length>1&&O.push(x),y+f.length-1<p.length-1){const m=y+f.length-1,T=p.slice(m),c=f[f.length-1];_.Equals(p[m],c)||T.unshift(c.clone().setz(p[m].z)),T.length>1&&O.push(T)}return v.splice(l,1,...O),v}}return v}function s(o,f){const v=_.Sub(o[1],o[0]),l=_.Sub(f[1],f[0]),p=_.Sub(f[0],o[0]);return Math.abs(_.Cpr(v,l))<.1&&Math.abs(_.Cpr(v,p))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let n=0;n<t.length;n++){const i=t[n].filter((o,f,v)=>!(f>0&&this.isSamePoint(o,v[f-1]))),a=[];let s=0;for(;s<i.length;){const o=i[s],f=new _(o[0],o[1]);a.push(f),s++}e.push(a)}return e}isLineEraser(t,e){return!(t===ht.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:n,newWorkDatas:i}=t,{isLine:a}=this.workOptions;let s;for(const[o,f]of e.entries())if(f.rect&&this.eraserRect&&this.eraserPolyline&&Ce(this.eraserRect,f.rect)){const{op:v,toolsType:l}=f,p=this.isLineEraser(l,a),y=[],O=[];for(let m=0;m<v.length;m+=3){const T=new _(v[m]*this.worldScaling[0]+this.worldPosition[0],v[m+1]*this.worldScaling[1]+this.worldPosition[1],v[m+2]);O.push(T),y.push(new xt(T.x,T.y))}const x=y.length&&wt(y)||f.rect;if(Ce(x,this.eraserRect)){if(O.length>1){const m=Jh.polyline(O.map(T=>T.XY),this.eraserPolyline);if(m.length&&(n.add(f.name),!p)){const T=this.translateIntersect(m),c=this.cutPolyline(T,O);for(let h=0;h<c.length;h++){const u=`${o}_s_${h}`,g=[];c[h].forEach(M=>{g.push((M.x-this.worldPosition[0])/this.worldScaling[0],(M.y-this.worldPosition[1])/this.worldScaling[1],M.z)}),f.opt&&f.toolsType&&this.vNodes&&(this.vNodes.setInfo(u,{rect:x,op:g,opt:f.opt,canRotate:f.canRotate,scaleType:f.scaleType,toolsType:f.toolsType}),i.set(u,{workId:u,op:g,opt:f.opt,toolsType:f.toolsType}))}}}else n.add(f.name);s=Ot(s,x)}}return n.forEach(o=>{var f;return(f=this.vNodes)==null?void 0:f.delete(o)}),s&&(s.x-=yt.SafeBorderPadding,s.y-=yt.SafeBorderPadding,s.w+=yt.SafeBorderPadding*2,s.h+=yt.SafeBorderPadding*2),s}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:ct.None};const n=this.tmpPoints.length;if(n>1&&this.isNear([e[0],e[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:ct.None};n===4&&(this.tmpPoints.shift(),this.tmpPoints.shift()),this.tmpPoints.push(e[0],e[1]);const i=this.computRectCenterPoints();let a;const s=new Set,o=new Map;if(!this.vNodes)return{type:ct.None};this.vNodes.setTarget();const f=this.getUnLockNodeMap(this.vNodes.getLastTarget());for(let v=0;v<i.length-1;v+=2){this.createEraserRect(i.slice(v,v+2));const l=this.remove({curNodeMap:f,removeIds:s,newWorkDatas:o});a=Ot(a,l)}if(this.vNodes.deleteLastTarget(),a&&s.size){for(const v of o.keys())s.has(v)&&o.delete(v);return{type:ct.RemoveNode,dataType:Tt.Local,rect:a,removeIds:[...s],newWorkDatas:o}}return{type:ct.None}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const n=Jt(t),i=this.serviceWork.selectorWorkShapes,a=this.serviceWork.workShapes;for(const s of i.values())if((e=s.selectIds)!=null&&e.length)for(const o of s.selectIds)n.delete(o);for(const s of a.keys())n.delete(s);return n}return t}};nt(Pe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let ae=Pe;const pr="++",Qh="selector",Zh="all";var kh="__lodash_hash_undefined__";function qh(d){return this.__data__.set(d,kh),this}var _h=qh;function td(d){return this.__data__.has(d)}var ed=td,rd=br,nd=_h,id=ed;function Je(d){var r=-1,t=d==null?0:d.length;for(this.__data__=new rd;++r<t;)this.add(d[r])}Je.prototype.add=Je.prototype.push=nd,Je.prototype.has=id;var sd=Je;function od(d,r){for(var t=-1,e=d==null?0:d.length;++t<e;)if(r(d[t],t,d))return!0;return!1}var ad=od;function ld(d,r){return d.has(r)}var cd=ld,fd=sd,ud=ad,hd=cd,dd=1,gd=2;function pd(d,r,t,e,n,i){var a=t&dd,s=d.length,o=r.length;if(s!=o&&!(a&&o>s))return!1;var f=i.get(d),v=i.get(r);if(f&&v)return f==r&&v==d;var l=-1,p=!0,y=t&gd?new fd:void 0;for(i.set(d,r),i.set(r,d);++l<s;){var O=d[l],x=r[l];if(e)var m=a?e(x,O,l,r,d,i):e(O,x,l,d,r,i);if(m!==void 0){if(m)continue;p=!1;break}if(y){if(!ud(r,function(T,c){if(!hd(y,c)&&(O===T||n(O,T,t,e,i)))return y.push(c)})){p=!1;break}}else if(!(O===x||n(O,x,t,e,i))){p=!1;break}}return i.delete(d),i.delete(r),p}var Pn=pd;function vd(d){var r=-1,t=Array(d.size);return d.forEach(function(e,n){t[++r]=[n,e]}),t}var md=vd;function yd(d){var r=-1,t=Array(d.size);return d.forEach(function(e){t[++r]=e}),t}var Sd=yd,An=Be,Cn=sn,xd=Ze,Td=Pn,Md=md,Od=Sd,Ed=1,Pd=2,Ad="[object Boolean]",Cd="[object Date]",Rd="[object Error]",Id="[object Map]",Ld="[object Number]",bd="[object RegExp]",Dd="[object Set]",wd="[object String]",Nd="[object Symbol]",Wd="[object ArrayBuffer]",Bd="[object DataView]",Rn=An?An.prototype:void 0,vr=Rn?Rn.valueOf:void 0;function Fd(d,r,t,e,n,i,a){switch(t){case Bd:if(d.byteLength!=r.byteLength||d.byteOffset!=r.byteOffset)return!1;d=d.buffer,r=r.buffer;case Wd:return!(d.byteLength!=r.byteLength||!i(new Cn(d),new Cn(r)));case Ad:case Cd:case Ld:return xd(+d,+r);case Rd:return d.name==r.name&&d.message==r.message;case bd:case wd:return d==r+"";case Id:var s=Md;case Dd:var o=e&Ed;if(s||(s=Od),d.size!=r.size&&!o)return!1;var f=a.get(d);if(f)return f==r;e|=Pd,a.set(d,r);var v=Td(s(d),s(r),e,n,i,a);return a.delete(d),v;case Nd:if(vr)return vr.call(d)==vr.call(r)}return!1}var jd=Fd,In=kr,Ud=1,$d=Object.prototype,zd=$d.hasOwnProperty;function Gd(d,r,t,e,n,i){var a=t&Ud,s=In(d),o=s.length,f=In(r),v=f.length;if(o!=v&&!a)return!1;for(var l=o;l--;){var p=s[l];if(!(a?p in r:zd.call(r,p)))return!1}var y=i.get(d),O=i.get(r);if(y&&O)return y==r&&O==d;var x=!0;i.set(d,r),i.set(r,d);for(var m=a;++l<o;){p=s[l];var T=d[p],c=r[p];if(e)var h=a?e(c,T,p,r,d,i):e(T,c,p,d,r,i);if(!(h===void 0?T===c||n(T,c,t,e,i):h)){x=!1;break}m||(m=p=="constructor")}if(x&&!m){var u=d.constructor,g=r.constructor;u!=g&&"constructor"in d&&"constructor"in r&&!(typeof u=="function"&&u instanceof u&&typeof g=="function"&&g instanceof g)&&(x=!1)}return i.delete(d),i.delete(r),x}var Hd=Gd,mr=Dr,Kd=Pn,Vd=jd,Yd=Hd,Ln=Ke,bn=$e,Dn=_e,Xd=zr,Jd=1,wn="[object Arguments]",Nn="[object Array]",Qe="[object Object]",Qd=Object.prototype,Wn=Qd.hasOwnProperty;function Zd(d,r,t,e,n,i){var a=bn(d),s=bn(r),o=a?Nn:Ln(d),f=s?Nn:Ln(r);o=o==wn?Qe:o,f=f==wn?Qe:f;var v=o==Qe,l=f==Qe,p=o==f;if(p&&Dn(d)){if(!Dn(r))return!1;a=!0,v=!1}if(p&&!v)return i||(i=new mr),a||Xd(d)?Kd(d,r,t,e,n,i):Vd(d,r,o,t,e,n,i);if(!(t&Jd)){var y=v&&Wn.call(d,"__wrapped__"),O=l&&Wn.call(r,"__wrapped__");if(y||O){var x=y?d.value():d,m=O?r.value():r;return i||(i=new mr),n(x,m,t,e,i)}}return p?(i||(i=new mr),Yd(d,r,t,e,n,i)):!1}var kd=Zd,qd=kd,Bn=ie;function Fn(d,r,t,e,n){return d===r?!0:d==null||r==null||!Bn(d)&&!Bn(r)?d!==d&&r!==r:qd(d,r,t,e,Fn,n)}var _d=Fn,t0=_d;function e0(d,r){return t0(d,r)}var r0=e0,le=Xt(r0);const ne=class ne extends yt{constructor(t){super(t);nt(this,"toolsType",ht.Selector);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"vNodes");nt(this,"selectIds");nt(this,"selectorColor");nt(this,"strokeColor");nt(this,"fillColor");nt(this,"oldSelectRect");nt(this,"canRotate",!1);nt(this,"canTextEdit",!1);nt(this,"canLock",!1);nt(this,"scaleType",jt.all);nt(this,"toolsTypes");nt(this,"shapeOpt");nt(this,"textOpt");nt(this,"isLocked");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=wt(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:n,nodeRange:i}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...i.keys()],intersectRect:n,subNodeMap:i}}updateTempPoints(t){const e=this.tmpPoints.length,n=t.length;if(n>1){const i=new xt(t[n-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[n-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,i):this.tmpPoints.push(i)}}drawSelector(t){const{drawRect:e,subNodeMap:n,selectorId:i,layer:a,isService:s}=t,o=new se({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:i,name:i,zIndex:1e3}),f=[];if(s){const v=new hr({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:ne.selectorBorderId});f.push(v)}n.forEach((v,l)=>{const p=[v.rect.x+v.rect.w/2-e.x,v.rect.y+v.rect.h/2-e.y],y=new hr({normalize:!0,pos:p,lineWidth:1,strokeColor:n.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:v.rect.w,height:v.rect.h,id:`selector-${l}`,name:`selector-${l}`});f.push(y)}),f&&o.append(...f),(a==null?void 0:a.parent).appendChild(o)}draw(t,e,n,i=!1){var o,f;const{intersectRect:a,subNodeMap:s}=n;(f=(o=e.parent)==null?void 0:o.getElementById(t))==null||f.remove(),a&&this.drawSelector({drawRect:a,subNodeMap:s,selectorId:t,layer:e,isService:i})}getSelecteorInfo(t){this.scaleType=jt.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0;const e=new Set;let n;for(const i of t.values()){const{opt:a,canRotate:s,scaleType:o,toolsType:f}=i;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),f===ht.SpeechBalloon&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),f===ht.Polygon&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),f===ht.Star&&(e.add(f),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),f===ht.Text&&(this.textOpt=a),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=s,this.scaleType=o),o===jt.none&&(this.scaleType=o),f===ht.Image&&(n=i)}e.size&&(this.toolsTypes=[...e]),n&&(t.size===1?(this.canLock=!0,n.opt.locked&&(this.isLocked=!0,this.scaleType=jt.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1)):t.size>1&&!n.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var t,e;if(this.scaleType===jt.both&&((t=this.selectIds)==null?void 0:t.length)===1){const n=this.selectIds[0],i=(e=this.vNodes.get(n))==null?void 0:e.op;if(i){const a=[];for(let s=0;s<i.length;s+=3)a.push([i[s],i[s+1]]);return a}}}consume(t){const{op:e,workState:n}=t.data;let i=this.oldSelectRect;if(n===Rt.Start&&(i=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:ct.None};this.updateTempPoints(e);const a=this.computSelector();if(this.selectIds&&le(this.selectIds,a.selectIds))return{type:ct.None};this.selectIds=a.selectIds;const s=a.intersectRect;this.getSelecteorInfo(a.subNodeMap),this.draw(ne.selectorId,this.fullLayer,a),this.oldSelectRect=s;const o=this.getChildrenPoints();return{type:ct.Select,dataType:Tt.Local,rect:Ot(s,i),selectIds:a.selectIds,opt:this.workOptions,selectRect:s,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:o,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt}}consumeAll(){var e,n;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,ne.selectorId,!1),(n=this.selectIds)!=null&&n.length&&(t=this.selectedByIds(this.selectIds)),t){const i=this.getChildrenPoints();return{type:ct.Select,dataType:Tt.Local,rect:this.oldSelectRect,selectIds:this.selectIds,opt:this.workOptions,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:i,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt}}return{type:ct.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(t,e=ne.selectorId,n=!1){if(t.length===2){const i=t[0],a=t[1];let s;const{nodeRange:o}=this.vNodes.getRectIntersectRange({x:i,y:a,w:0,h:0},!1),f=[...o.values()].sort((v,l)=>(l.opt.zIndex||0)-(v.opt.zIndex||0));for(const v of f){const l=this.fullLayer.getElementsByName(v.name);if(Yn(l).find(y=>y.isPointCollision(i,a))){s=v;break}}if(s){const v=s.name;if(!le(this.oldSelectRect,s.rect)){const l=new Map([[v,s]]);this.getSelecteorInfo(l),this.draw(e,this.fullLayer,{intersectRect:s.rect,subNodeMap:l,selectIds:this.selectIds||[]},n)}this.selectIds=[v],this.oldSelectRect=s.rect}}}unSelectedAllIds(){let t;for(const[e,n]of this.vNodes.curNodeMap.entries())n.isSelected&&(t=Ot(t,n.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const n of t){const i=this.vNodes.get(n);i&&i.isSelected&&(e=Ot(e,i.rect),this.vNodes.unSelected(n))}return e}selectedByIds(t){let e;for(const n of t){const i=this.vNodes.get(n);i&&(e=Ot(e,i.rect),this.vNodes.selected(n))}return e}getSelectorRect(t,e){var s;let n;const i=(s=t.parent)==null?void 0:s.getElementById(e),a=i==null?void 0:i.getBoundingClientRect();return a&&(n=Ot(n,{x:Math.floor(a.x),y:Math.floor(a.y),w:Math.floor(a.width+1),h:Math.floor(a.height+1)})),n}isCanFillColor(t){return t===ht.Ellipse||t===ht.Triangle||t===ht.Rectangle||t===ht.Polygon||t===ht.Star||t===ht.SpeechBalloon}async updateSelector(t){const{updateSelectorOpt:e,selectIds:n,vNodes:i,willSerializeData:a,worker:s,offset:o,scene:f,isMainThread:v}=t,l=this.fullLayer;if(!l)return;let p;const y=new Map,{box:O,workState:x,angle:m,translate:T}=e;let c=[0,0],h=[1,1],u=[0,0],g,M;if(O||T||Qt(m)){if(x===Rt.Start)return i.setTarget(),{type:ct.Select,dataType:Tt.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(g=i.getLastTarget(),g&&O){let b;n==null||n.forEach(E=>{const L=g==null?void 0:g.get(E);b=Ot(b,L==null?void 0:L.rect)}),b&&(h=[O.w/b.w,O.h/b.h],c=[O.x+O.w/2-(b.x+b.w/2),O.y+O.h/2-(b.y+b.h/2)],u=[b.x+b.w/2,b.y+b.h/2]),M=b}}if(n)for(const b of n){const E=i.get(b);if(E){const{toolsType:L}=E;let D=(l==null?void 0:l.getElementsByName(b))[0];if(D){const R={...e};let C;if(L){if(g&&(C=g.get(b),C&&O)){R.boxScale=h;const z=[C.rect.x+C.rect.w/2,C.rect.y+C.rect.h/2],H=[z[0]-u[0],z[1]-u[1]];R.boxTranslate=[H[0]*(h[0]-1)+c[0]+(o&&o[0]||0),H[1]*(h[1]-1)+c[1]+(o&&o[1]||0)]}const W=Vn(L);if(W==null||W.updateNodeOpt({node:D,opt:R,vNodes:i,willSerializeData:a,targetNode:C}),E&&s&&(a&&(R.angle||R.translate)||R.box&&R.workState!==Rt.Start||R.pointMap&&R.pointMap.has(b)||L===ht.Text&&(R.fontSize||R.translate||R.textInfos&&R.textInfos.get(b))||L===ht.Image&&(R.angle||R.translate||R.boxScale)||L===R.toolsType&&R.willRefresh)){const z=s.createWorkShapeNode({toolsType:L,toolsOpt:E.opt});z==null||z.setWorkId(b);let H;L===ht.Image&&f?H=await z.consumeServiceAsync({isFullWork:!0,replaceId:b,scene:f,isMainThread:v}):L===ht.Text?H=await z.consumeServiceAsync({isFullWork:!0,replaceId:b}):H=z==null?void 0:z.consumeService({op:E.op,isFullWork:!0,replaceId:b}),H&&(E.rect=H),D=(l==null?void 0:l.getElementsByName(b))[0]}E&&(y.set(b,E),p=Ot(p,E.rect))}}}}g&&x===Rt.Done&&i.deleteLastTarget();const A=p;if(M&&e.dir&&A&&!o){const b=[0,0];switch(e.dir){case"top":{const E=[M.x,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h);break}case"topLeft":{const E=[M.x+M.w,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h),e.reverseX?b[0]=E[0]-A.x:b[0]=E[0]-(A.x+A.w);break}case"topRight":{const E=[M.x,M.y+M.h];e.reverseY?b[1]=E[1]-A.y:b[1]=E[1]-(A.y+A.h),e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}case"bottom":{const E=[M.x,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y;break}case"bottomLeft":{const E=[M.x+M.w,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y,e.reverseX?b[0]=E[0]-A.x:b[0]=E[0]-(A.x+A.w);break}case"bottomRight":{const E=[M.x,M.y];e.reverseY?b[1]=E[1]-(A.y+A.h):b[1]=E[1]-A.y,e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}case"right":{const E=[M.x,M.y];e.reverseX?b[0]=E[0]-(A.x+A.w):b[0]=E[0]-A.x;break}}if(b[0]||b[1])return A.x=A.x+b[0],A.y=A.y+b[1],await this.updateSelector({...t,offset:b})}this.getSelecteorInfo(y),this.draw(ne.selectorId,l,{selectIds:n||[],subNodeMap:y,intersectRect:A});const I=Ot(this.oldSelectRect,A);return this.oldSelectRect=A,{type:ct.Select,dataType:Tt.Local,selectRect:A,renderRect:p,rect:Ot(I,A)}}blurSelector(){const t=this.unSelectedAllIds();return{type:ct.Select,dataType:Tt.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(pr,"-")}selectServiceNode(t,e,n){const{selectIds:i}=e,a=this.getRightServiceId(t),s=this.getSelectorRect(this.fullLayer,a);let o;const f=new Map;return i==null||i.forEach(v=>{const l=this.vNodes.get(v);l&&(o=Ot(o,l.rect),f.set(v,l))}),this.getSelecteorInfo(f),this.draw(a,this.fullLayer,{intersectRect:o,selectIds:i||[],subNodeMap:f},n),Ot(o,s)}reRenderSelector(){var n;let t;const e=new Map;return(n=this.selectIds)==null||n.forEach(i=>{const a=this.vNodes.get(i);a&&(t=Ot(t,a.rect),e.set(i,a))},this),this.getSelecteorInfo(e),this.draw(ne.selectorId,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var a;let e;const n=(a=this.selectIds)==null?void 0:a.filter(s=>!t.includes(s));if(n!=null&&n.length&&(e=this.unSelectedByIds(n)),t.length){const s=this.selectedByIds(t);e=Ot(e,s)}this.selectIds=t;const i=this.reRenderSelector();return{bgRect:e,selectRect:i}}cursorHover(t){var a,s;const e=this.oldSelectRect;this.selectIds=[];const n=(a=this.workId)==null?void 0:a.toString(),i=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,n,!0),this.oldSelectRect&&!le(e,this.oldSelectRect))return{type:ct.CursorHover,dataType:Tt.Local,rect:Ot(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((s=this.selectIds)!=null&&s.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:ct.CursorHover,dataType:Tt.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,n;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((n=this.fullLayer)==null?void 0:n.parent).children.forEach(i=>{i.name===t&&i.remove()})}};nt(ne,"selectorId",Qh),nt(ne,"selectorBorderId","selector-border");let Nt=ne;class jn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.both);nt(this,"toolsType",ht.Arrow);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"arrowTipWidth");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,thickness:a,zIndex:s,scale:o,rotate:f,translate:v}=this.workOptions,l=n.worldPosition,p=n.worldScaling,{points:y,rect:O}=this.computDrawPoints(a),m={pos:[O.x+O.w/2,O.y+O.h/2],name:e,id:e,close:!0,points:y,fillColor:i,strokeColor:i,lineWidth:0,normalize:!0,zIndex:s};o&&(m.scale=o),f&&(m.rotate=f),v&&(m.translate=v);const T=new pe(m);if(this.replace(n,e,T),o||f||v){const c=T.getBoundingClientRect();return{x:Math.floor(c.x-yt.SafeBorderPadding),y:Math.floor(c.y-yt.SafeBorderPadding),w:Math.floor(c.width+yt.SafeBorderPadding*2),h:Math.floor(c.height+yt.SafeBorderPadding*2)}}return{x:Math.floor(O.x*p[0]+l[0]-yt.SafeBorderPadding),y:Math.floor(O.y*p[1]+l[1]-yt.SafeBorderPadding),w:Math.floor(O.w*p[0]+2*yt.SafeBorderPadding),h:Math.floor(O.h*p[1]+2*yt.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=_.Per(e).mul(t/2),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=_.Mul(e,this.arrowTipWidth),o=_.Sub(this.tmpPoints[1],s),f=xt.Sub(o,n),v=xt.Add(o,n),l=_.Per(e).mul(t*1.5),p=xt.Sub(o,l),y=xt.Add(o,l),O=[i,f,p,this.tmpPoints[1],y,v,a];return{points:O.map(x=>xt.Sub(x,this.tmpPoints[0]).XY).flat(1),rect:wt(O),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),n=_.Per(t).mul(Math.floor(e*3/8)),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=[i,this.tmpPoints[1],a];return{points:s.map(o=>xt.Sub(o,this.tmpPoints[0]).XY).flat(1),rect:wt(s),isTriangle:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a),s&&i.setInfo(e.name,s)),yt.updateNodeOpt(t)}}class Un extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Ellipse);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,scale:v,rotate:l,translate:p}=this.workOptions,y=n.worldScaling,{radius:O,rect:x,pos:m}=this.computDrawPoints(o),T={pos:m,name:e,id:e,radius:O,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0},c={name:e,id:e,zIndex:f,pos:m,anchor:[.5,.5],size:[x.w,x.h]};v&&(c.scale=v),l&&(c.rotate=l),p&&(c.translate=p);const h=new se(c);if(i){const M=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/y[0],1/y[1]]});h.append(M)}const u=new Gh({...T,pos:[0,0]});h.append(u),this.replace(n,e,h);const g=h.getBoundingClientRect();return{x:Math.floor(g.x-yt.SafeBorderPadding),y:Math.floor(g.y-yt.SafeBorderPadding),w:Math.floor(g.width+yt.SafeBorderPadding*2),h:Math.floor(g.height+yt.SafeBorderPadding*2)}}computDrawPoints(t){const e=wt(this.tmpPoints),n=wt(this.tmpPoints,t),i=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:n,pos:i,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var v,l;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s}=n,o=i.get(e.name);let f=e;return e.tagName==="GROUP"&&(f=e.children[0]),a&&(f.setAttribute("strokeColor",a),(v=o==null?void 0:o.opt)!=null&&v.strokeColor&&(o.opt.strokeColor=a)),s&&(s==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",s),(l=o==null?void 0:o.opt)!=null&&l.fillColor&&(o.opt.fillColor=s)),o&&i.setInfo(e.name,o),yt.updateNodeOpt(t)}}var n0=ue,i0=ie,s0="[object Boolean]";function o0(d){return d===!0||d===!1||i0(d)&&n0(d)==s0}var a0=o0,ce=Xt(a0);class $n extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Rectangle);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=wt(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,n=[];for(const s of t)n.push(new _(...s));const i=wt(n,e),a=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:a,points:n.map(s=>s.XY).flat(1)}}consume(t){var x;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(x=e==null?void 0:e.workId)==null?void 0:x.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};const p=this.transformData();let y;if(i||a){const m=n?this.fullLayer:this.drawLayer||this.fullLayer;y=this.draw({ps:p,workId:s,layer:m,isDrawing:!0})}if(!i){const m=Date.now();return m-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=m,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:p.flat(1),isSync:!0,index:0}):{type:ct.None}}const O=Ot(y,this.oldRect);return this.oldRect=y,{rect:O,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var v,l;const{data:e}=t,n=(v=e==null?void 0:e.workId)==null?void 0:v.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.transformData(),a=this.fullLayer,s=this.draw({ps:i,workId:n,layer:a,isDrawing:!1});this.oldRect=s;const o=i.flat(1),f=qt(o);return(l=this.vNodes)==null||l.setInfo(n,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),{rect:s,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:f,opt:this.workOptions,isSync:!0}}draw(t){const{workId:e,layer:n,isDrawing:i,ps:a,replaceId:s}=t,{strokeColor:o,fillColor:f,thickness:v,zIndex:l,scale:p,rotate:y,translate:O,textOpt:x}=this.workOptions,m=n.worldPosition,T=n.worldScaling,{points:c,rect:h,pos:u}=this.computDrawPoints(a),g={close:!0,normalize:!0,points:c,lineWidth:v,fillColor:f!=="transparent"&&f||void 0,strokeColor:o,lineJoin:"round"},M={x:Math.floor(h.x*T[0]+m[0]-yt.SafeBorderPadding),y:Math.floor(h.y*T[1]+m[1]-yt.SafeBorderPadding),w:Math.floor(h.w*T[0]+2*yt.SafeBorderPadding),h:Math.floor(h.h*T[0]+2*yt.SafeBorderPadding)},A=new se({name:e,id:e,zIndex:l,pos:u,anchor:[.5,.5],size:[h.w,h.h],scale:p,rotate:y,translate:O}),I=new pe({...g,pos:[0,0]});if(A.appendChild(I),i){const b=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/T[0],1/T[1]]});A.appendChild(b)}if(this.replace(n,s||e,A),p||y||O){const b=A.getBoundingClientRect();return{x:Math.floor(b.x-yt.SafeBorderPadding),y:Math.floor(b.y-yt.SafeBorderPadding),w:Math.floor(b.width+2*yt.SafeBorderPadding),h:Math.floor(b.height+2*yt.SafeBorderPadding)}}return M}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var v,l;const{op:e,isFullWork:n,replaceId:i}=t,a=(v=this.workId)==null?void 0:v.toString();if(!a)return;const s=[];for(let p=0;p<e.length;p+=3)s.push([e[p],e[p+1],e[p+2]]);const o=n?this.fullLayer:this.drawLayer||this.fullLayer,f=this.draw({ps:s,workId:a,layer:o,isDrawing:!1,replaceId:i});return this.oldRect=f,(l=this.vNodes)==null||l.setInfo(a,{rect:f,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&yt.getCenterPos(f,o)}),f}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var T,c;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,fontColor:o,fontBgColor:f,bold:v,italic:l,lineThrough:p,underline:y,fontSize:O}=n,x=i.get(e.name);let m=e;if(e.tagName==="GROUP"&&(m=e.children[0]),a&&(m.setAttribute("strokeColor",a),(T=x==null?void 0:x.opt)!=null&&T.strokeColor&&(x.opt.strokeColor=a)),s&&(s==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",s),(c=x==null?void 0:x.opt)!=null&&c.fillColor&&(x.opt.fillColor=s)),x!=null&&x.opt.textOpt){const h=x.opt.textOpt;o&&h.fontColor&&(h.fontColor=o),f&&h.fontBgColor&&(h.fontBgColor=f),v&&(h.bold=v),l&&(h.italic=l),ce(p)&&(h.lineThrough=p),ce(y)&&(h.underline=y),O&&(h.fontSize=O)}return x&&i.setInfo(e.name,x),yt.updateNodeOpt(t)}}class zn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Star);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,vertices:v,innerVerticeStep:l,innerRatio:p,scale:y,rotate:O,translate:x}=this.workOptions,m=n.worldScaling,{rect:T,pos:c,points:h}=this.computDrawPoints(o,v,l,p),u={close:!0,points:h,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0,lineJoin:"round"},g={name:e,id:e,zIndex:f,pos:c,anchor:[.5,.5],size:[T.w,T.h],className:`${c[0]},${c[1]}`};y&&(g.scale=y),O&&(g.rotate=O),x&&(g.translate=x);const M=new se(g);if(i){const b=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/m[0],1/m[1]]});M.append(b)}const A=new pe({...u,pos:[0,0]});M.append(A),this.replace(n,e,M);const I=M.getBoundingClientRect();return{x:Math.floor(I.x-yt.SafeBorderPadding),y:Math.floor(I.y-yt.SafeBorderPadding),w:Math.floor(I.width+yt.SafeBorderPadding*2),h:Math.floor(I.height+yt.SafeBorderPadding*2)}}computDrawPoints(t,e,n,i){const a=wt(this.tmpPoints),s=[Math.floor(a.x+a.w/2),Math.floor(a.y+a.h/2)],o=Tn(a.w,a.h),f=Math.floor(Math.min(a.w,a.h)/2),v=i*f,l=[],p=2*Math.PI/e;for(let O=0;O<e;O++){const x=O*p-.5*Math.PI;let m,T;O%n===1?(m=v*o[0]*Math.cos(x),T=v*o[1]*Math.sin(x)):(m=f*o[0]*Math.cos(x),T=f*o[1]*Math.sin(x),l.push(m,T)),l.push(m,T)}return{rect:wt(this.tmpPoints,t),pos:s,points:l}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,vertices:f,innerVerticeStep:v,innerRatio:l}=n,p=i.get(e.name),y=p==null?void 0:p.opt;let O=e;return e.tagName==="GROUP"&&(O=e.children[0]),a&&(O.setAttribute("strokeColor",a),y!=null&&y.strokeColor&&(y.strokeColor=a)),s&&(s==="transparent"?O.setAttribute("fillColor","rgba(0,0,0,0)"):O.setAttribute("fillColor",s),y!=null&&y.fillColor&&(y.fillColor=s)),o===ht.Star&&(f&&(y.vertices=f),v&&(y.innerVerticeStep=v),l&&(y.innerRatio=l)),p&&i.setInfo(e.name,{...p,opt:y}),yt.updateNodeOpt(t)}}class Gn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Polygon);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n,isDrawing:i}=t,{strokeColor:a,fillColor:s,thickness:o,zIndex:f,vertices:v,scale:l,rotate:p,translate:y}=this.workOptions,O=n.worldScaling,{rect:x,pos:m,points:T}=this.computDrawPoints(o,v),c={close:!0,points:T,lineWidth:o,fillColor:s!=="transparent"&&s||void 0,strokeColor:a,normalize:!0,lineJoin:"round"},h={name:e,id:e,zIndex:f,pos:m,anchor:[.5,.5],size:[x.w,x.h]};l&&(h.scale=l),p&&(h.rotate=p),y&&(h.translate=y);const u=new se(h);if(i){const A=new ge({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/O[0],1/O[1]]});u.append(A)}const g=new pe({...c,pos:[0,0]});u.append(g),this.replace(n,e,u);const M=u.getBoundingClientRect();return{x:Math.floor(M.x-yt.SafeBorderPadding),y:Math.floor(M.y-yt.SafeBorderPadding),w:Math.floor(M.width+yt.SafeBorderPadding*2),h:Math.floor(M.height+yt.SafeBorderPadding*2)}}computDrawPoints(t,e){const n=wt(this.tmpPoints),i=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],a=Tn(n.w,n.h),s=Math.floor(Math.min(n.w,n.h)/2),o=[],f=2*Math.PI/e;for(let l=0;l<e;l++){const p=l*f-.5*Math.PI,y=s*a[0]*Math.cos(p),O=s*a[1]*Math.sin(p);o.push(y,O)}return{rect:wt(this.tmpPoints,t),pos:i,points:o}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,vertices:f}=n,v=i.get(e.name),l=v==null?void 0:v.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),a&&(p.setAttribute("strokeColor",a),l!=null&&l.strokeColor&&(l.strokeColor=a)),s&&(s==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",s),l!=null&&l.fillColor&&(l.fillColor=s)),o===ht.Polygon&&f&&(l.vertices=f),v&&i.setInfo(e.name,{...v,opt:l}),yt.updateNodeOpt(t)}}class _t{static bezier(r,t){const e=[];for(let n=0;n<t.length;n+=4){const i=t[n],a=t[n+1],s=t[n+2],o=t[n+3];i&&a&&s&&o?e.push(..._t.getBezierPoints(r,i,a,s,o)):i&&a&&s?e.push(..._t.getBezierPoints(r,i,a,s)):i&&a?e.push(..._t.getBezierPoints(r,i,a)):i&&e.push(i)}return e}static getBezierPoints(r=10,t,e,n,i){let a=null;const s=[];!n&&!i?a=_t.oneBezier:n&&!i?a=_t.twoBezier:n&&i&&(a=_t.threeBezier);for(let o=0;o<r;o++)a&&s.push(a(o/r,t,e,n,i));return i?s.push(i):n&&s.push(n),s}static oneBezier(r,t,e){const n=t.x+(e.x-t.x)*r,i=t.y+(e.y-t.y)*r;return new _(n,i)}static twoBezier(r,t,e,n){const i=(1-r)*(1-r)*t.x+2*r*(1-r)*e.x+r*r*n.x,a=(1-r)*(1-r)*t.y+2*r*(1-r)*e.y+r*r*n.y;return new _(i,a)}static threeBezier(r,t,e,n,i){const a=t.x*(1-r)*(1-r)*(1-r)+3*e.x*r*(1-r)*(1-r)+3*n.x*r*r*(1-r)+i.x*r*r*r,s=t.y*(1-r)*(1-r)*(1-r)+3*e.y*r*(1-r)*(1-r)+3*n.y*r*r*(1-r)+i.y*r*r*r;return new _(a,s)}}class Hn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.SpeechBalloon);nt(this,"ratio",.8);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x,isDrawing:!0})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,fillColor:a,thickness:s,zIndex:o,placement:f,scale:v,rotate:l,translate:p}=this.workOptions,{rect:y,pos:O,points:x}=this.computDrawPoints(s,f),m={points:x.map(g=>g.XY),lineWidth:s,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,className:`${O[0]},${O[1]}`,lineJoin:"round",close:!0},T={name:e,id:e,zIndex:o,pos:O,anchor:[.5,.5],size:[y.w,y.h]};v&&(T.scale=v),l&&(T.rotate=l),p&&(T.translate=p);const c=new se(T),h=new pe({...m,pos:[0,0]});c.append(h),this.replace(n,e,c);const u=c.getBoundingClientRect();return{x:Math.floor(u.x-yt.SafeBorderPadding),y:Math.floor(u.y-yt.SafeBorderPadding),w:Math.floor(u.width+yt.SafeBorderPadding*2),h:Math.floor(u.height+yt.SafeBorderPadding*2)}}transformControlPoints(t){const e=wt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const n=e.y+e.h*this.ratio;return[new _(e.x,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,n,0),new _(e.x,n,0)]}case"top":case"topLeft":case"topRight":{const n=e.y+e.h*(1-this.ratio);return[new _(e.x,n,0),new _(e.x+e.w,n,0),new _(e.x+e.w,e.y+e.h,0),new _(e.x,e.y+e.h,0)]}case"left":case"leftBottom":case"leftTop":{const n=e.x+e.w*(1-this.ratio);return[new _(n,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,e.y+e.h,0),new _(n,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const n=e.x+e.w*this.ratio;return[new _(e.x,e.y,0),new _(n,e.y,0),new _(n,e.y+e.h,0),new _(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const n=wt(this.tmpPoints),i=this.transformControlPoints(e),a=Math.floor(n.w*.1),s=Math.floor(n.h*.1),o=[],f=_.Add(i[0],new _(0,s,0)),v=_.Add(i[0],new _(a,0,0)),l=_t.getBezierPoints(10,f,i[0],v),p=_.Sub(i[1],new _(a,0,0)),y=_.Add(i[1],new _(0,s,0)),O=_t.getBezierPoints(10,p,i[1],y),x=_.Sub(i[2],new _(0,s,0)),m=_.Sub(i[2],new _(a,0,0)),T=_t.getBezierPoints(10,x,i[2],m),c=_.Add(i[3],new _(a,0,0)),h=_.Sub(i[3],new _(0,s,0)),u=_t.getBezierPoints(10,c,i[3],h),g=a*(1-this.ratio)*10,M=s*(1-this.ratio)*10;switch(e){case"bottom":{const b=_.Sub(i[2],new _(a*5-g/2,0,0)),E=_.Sub(i[2],new _(a*5,-M,0)),L=_.Sub(i[2],new _(a*5+g/2,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"bottomRight":{const b=_.Sub(i[2],new _(a*1.1,0,0)),E=_.Sub(i[2],new _(a*1.1+g/2,-M,0)),L=_.Sub(i[2],new _(a*1.1+g,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"bottomLeft":{const b=_.Add(i[3],new _(a*1.1+g,0,0)),E=_.Add(i[3],new _(a*1.1+g/2,M,0)),L=_.Add(i[3],new _(a*1.1,0,0));o.push(E,L,...u,...l,...O,...T,b);break}case"top":{const b=_.Sub(i[1],new _(a*5-g/2,0,0)),E=_.Sub(i[1],new _(a*5,M,0)),L=_.Sub(i[1],new _(a*5+g/2,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"topRight":{const b=_.Sub(i[1],new _(a*1.1,0,0)),E=_.Sub(i[1],new _(a*1.1+g/2,M,0)),L=_.Sub(i[1],new _(a*1.1+g,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"topLeft":{const b=_.Add(i[0],new _(a*1.1+g,0,0)),E=_.Add(i[0],new _(a*1.1+g/2,-M,0)),L=_.Add(i[0],new _(a*1.1,0,0));o.push(E,b,...O,...T,...u,...l,L);break}case"left":{const b=_.Add(i[0],new _(0,s*5-M/2,0)),E=_.Add(i[0],new _(-g,s*5,0)),L=_.Add(i[0],new _(0,s*5+M/2,0));o.push(E,b,...l,...O,...T,...u,L);break}case"leftTop":{const b=_.Add(i[0],new _(0,s*1.1,0)),E=_.Add(i[0],new _(-g,s*1.1+M/2,0)),L=_.Add(i[0],new _(0,s*1.1+M,0));o.push(E,b,...l,...O,...T,...u,L);break}case"leftBottom":{const b=_.Sub(i[3],new _(0,s*1.1+M,0)),E=_.Sub(i[3],new _(g,s*1.1+M/2,0)),L=_.Sub(i[3],new _(0,s*1.1,0));o.push(E,b,...l,...O,...T,...u,L);break}case"right":{const b=_.Add(i[1],new _(0,s*5-M/2,0)),E=_.Add(i[1],new _(g,s*5,0)),L=_.Add(i[1],new _(0,s*5+M/2,0));o.push(E,L,...T,...u,...l,...O,b);break}case"rightTop":{const b=_.Add(i[1],new _(0,s*1.1,0)),E=_.Add(i[1],new _(g,s*1.1+M/2,0)),L=_.Add(i[1],new _(0,s*1.1+M,0));o.push(E,L,...T,...u,...l,...O,b);break}case"rightBottom":{const b=_.Sub(i[2],new _(0,s*1.1+M,0)),E=_.Sub(i[2],new _(-g,s*1.1+M/2,0)),L=_.Sub(i[2],new _(0,s*1.1,0));o.push(E,L,...T,...u,...l,...O,b);break}}const A=wt(this.tmpPoints,t),I=[Math.floor(A.x+A.w/2),Math.floor(A.y+A.h/2)];return{rect:A,pos:I,points:o}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a)||xt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i}=t,{strokeColor:a,fillColor:s,toolsType:o,placement:f}=n,v=i.get(e.name),l=v==null?void 0:v.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),a&&(p.setAttribute("strokeColor",a),l!=null&&l.strokeColor&&(l.strokeColor=a)),s&&(s==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",s),l!=null&&l.fillColor&&(l.fillColor=s)),o===ht.SpeechBalloon&&f&&(l.placement=f),v&&i.setInfo(e.name,{...v,opt:l}),yt.updateNodeOpt(t)}}class Le extends yt{constructor(t){super(t);nt(this,"canRotate",!0);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Image);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=Le.getScaleType(this.workOptions)}consume(){return{type:ct.None}}consumeAll(){return{type:ct.None}}draw(t){const{layer:e,workId:n,replaceId:i,imageBitmap:a,isMainThread:s}=t,{centerX:o,centerY:f,width:v,height:l,rotate:p,zIndex:y}=this.workOptions,O={anchor:[.5,.5],pos:[o,f],name:n,size:[v,l],zIndex:y,rotate:!s&&180+(p||0)||p,texture:a},x=new Vh(O);this.replace(e,i||n,x);const m=x.getBoundingClientRect();if(m)return{x:Math.floor(m.x-yt.SafeBorderPadding),y:Math.floor(m.y-yt.SafeBorderPadding),w:Math.floor(m.width+yt.SafeBorderPadding*2),h:Math.floor(m.height+yt.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var l,p,y,O;const{isFullWork:e,replaceId:n,scene:i,isMainThread:a}=t,{src:s,uuid:o}=this.workOptions,f=((l=this.workId)==null?void 0:l.toString())||o,v=e?this.fullLayer:this.drawLayer||this.fullLayer;if(s){const x=await i.preload({id:o,src:this.workOptions.src}),m=this.draw({workId:f,layer:v,replaceId:n,imageBitmap:x[0],isMainThread:a});return this.oldRect=f&&((y=(p=this.vNodes)==null?void 0:p.get(f))==null?void 0:y.rect)||void 0,(O=this.vNodes)==null||O.setInfo(f,{rect:m,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&yt.getCenterPos(m,v)}),m}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:n}=t;return e!==!1||n&&Math.abs(n)%90>0?jt.proportional:jt.all}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i,targetNode:a}=t,{translate:s,box:o,boxScale:f,boxTranslate:v,angle:l,isLocked:p,zIndex:y}=n,O=a&&Jt(a)||i.get(e.name);if(!O)return;const x=e.parent;if(x){if(Qt(y)&&(e.setAttribute("zIndex",y),O.opt.zIndex=y),ce(p)&&(O.opt.locked=p),o&&v&&f){const{centerX:m,centerY:T,width:c,height:h,uniformScale:u,rotate:g}=O.opt,M=Math.min(f[0],f[1]),A=u!==!1?[M,M]:f,I=yn({x:m-c/2,y:T-h/2,w:c,h},g||0),b=Lh(I,new _(m,T),A),E=bh(b,new _(m,T),-(g||0)),L=wt(E);O.opt.width=Math.round(L.w),O.opt.height=Math.round(L.h);const D=[v[0]/x.worldScaling[0],v[1]/x.worldScaling[1]];O.opt.centerX=m+D[0],O.opt.centerY=T+D[1];const R=[O.centerPos[0]+D[0],O.centerPos[1]+D[1]];if(O.centerPos=R,a){let C=xn(O.rect,f);C=Re(C,D),O.rect=C}}else if(s){const m=[s[0]/x.worldScaling[0],s[1]/x.worldScaling[1]];if(O.opt.centerX=O.opt.centerX+m[0],O.opt.centerY=O.opt.centerY+m[1],O.centerPos=[O.centerPos[0]+m[0],O.centerPos[1]+m[1]],a){const T=Re(O.rect,m);O.rect=T}}else if(Qt(l)&&(O.opt.rotate=l,O.scaleType=Le.getScaleType(O.opt),a)){const m=Sn(O.rect,l);O.rect=m}return O&&i.setInfo(e.name,O),O==null?void 0:O.rect}}}class Kn extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.both);nt(this,"toolsType",ht.Straight);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");nt(this,"straightTipWidth");nt(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var O;const{data:e,isFullWork:n,isSubWorker:i,isMainThread:a}=t,s=(O=e==null?void 0:e.workId)==null?void 0:O.toString();if(!s)return{type:ct.None};const{op:o,workState:f}=e,v=o==null?void 0:o.length;if(!v||v<2)return{type:ct.None};let l;if(f===Rt.Start?(this.tmpPoints=[new xt(o[0],o[1])],l=!1):l=this.updateTempPoints(o),!l)return{type:ct.None};let p;if(i||a){const x=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:s,layer:x})}if(!i){const x=Date.now();return x-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=x,{type:ct.DrawWork,dataType:Tt.Local,workId:s,op:this.tmpPoints.map(m=>[...m.XY,0]).flat(1),isSync:!0,index:0}):{type:ct.None}}const y=Ot(p,this.oldRect);return this.oldRect=p,{rect:y,type:ct.DrawWork,dataType:Tt.Local,workId:s}}consumeAll(t){var f,v;const{data:e}=t,n=(f=e==null?void 0:e.workId)==null?void 0:f.toString();if(!n)return{type:ct.None};if(this.tmpPoints.length<2)return{type:ct.RemoveNode,removeIds:[n]};const i=this.fullLayer,a=this.draw({workId:n,layer:i});this.oldRect=a;const s=this.tmpPoints.map(l=>[...l.XY,0]).flat(1),o=qt(s);return(v=this.vNodes)==null||v.setInfo(n,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&yt.getCenterPos(a,i)}),{rect:a,type:ct.FullWork,dataType:Tt.Local,workId:n,ops:o,isSync:!0,opt:this.workOptions}}draw(t){const{workId:e,layer:n}=t,{strokeColor:i,thickness:a,zIndex:s,scale:o,rotate:f,translate:v}=this.workOptions,l=n.worldPosition,p=n.worldScaling,{d:y,rect:O}=this.computDrawPoints(a),x=[O.x+O.w/2,O.y+O.h/2],m={pos:x,name:e,id:e,d:y,fillColor:i,strokeColor:i,lineWidth:0,className:`${x[0]},${x[1]}`,normalize:!0,zIndex:s};o&&(m.scale=o),f&&(m.rotate=f),v&&(m.translate=v);const T=new ge(m);if(this.replace(n,e,T),f||o||v){const h=T.getBoundingClientRect();return{x:Math.floor(h.x-yt.SafeBorderPadding),y:Math.floor(h.y-yt.SafeBorderPadding),w:Math.floor(h.width+yt.SafeBorderPadding*2),h:Math.floor(h.height+yt.SafeBorderPadding*2)}}return{x:Math.floor(O.x*p[0]+l[0]-yt.SafeBorderPadding),y:Math.floor(O.y*p[1]+l[1]-yt.SafeBorderPadding),w:Math.floor(O.w*p[0]+2*yt.SafeBorderPadding),h:Math.floor(O.h*p[1]+2*yt.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t):this.computDotPoints(t)}computFullPoints(t){const e=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=_.Per(e).mul(t/2),i=xt.Sub(this.tmpPoints[0],n),a=xt.Add(this.tmpPoints[0],n),s=xt.Sub(this.tmpPoints[1],n),o=xt.Add(this.tmpPoints[1],n),f=xt.GetSemicircleStroke(this.tmpPoints[1],s,-1,8),v=xt.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),l=[i,s,...f,o,a,...v];return{d:Oe(l,!0),rect:wt(l),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=xt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:Oe(e,!0),rect:wt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],{thickness:a}=this.workOptions;if(i.isNear(n,a))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(t){var o,f;const{op:e,isFullWork:n}=t,i=(o=this.workId)==null?void 0:o.toString();if(!i)return;this.tmpPoints.length=0;for(let v=0;v<e.length;v+=3)this.tmpPoints.push(new xt(e[v],e[v+1],e[v+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,s=this.draw({workId:i,layer:a});return this.oldRect=s,(f=this.vNodes)==null||f.setInfo(i,{rect:s,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&yt.getCenterPos(s,a)}),s}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var o;const{node:e,opt:n,vNodes:i}=t,{strokeColor:a}=n,s=i.get(e.name);return a&&(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a),(o=s==null?void 0:s.opt)!=null&&o.strokeColor&&(s.opt.strokeColor=a)),s&&i.setInfo(e.name,s),yt.updateNodeOpt(t)}}class be extends yt{constructor(t){super(t);nt(this,"canRotate",!1);nt(this,"scaleType",jt.all);nt(this,"toolsType",ht.Text);nt(this,"tmpPoints",[]);nt(this,"workOptions");nt(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:ct.None}}consumeAll(){return{type:ct.None}}consumeService(){}async draw(t){const{workId:e,layer:n,isDrawLabel:i}=t,{boxSize:a,boxPoint:s,zIndex:o}=this.workOptions,f=n.worldPosition,v=n.worldScaling;if(!s||!a)return;const l={name:e,id:e,pos:[s[0]+a[0]/2,s[1]+a[1]/2],anchor:[.5,.5],size:a,zIndex:o},p=new se(l),y={x:s[0],y:s[1],w:a[0],h:a[1]},O=new hr({normalize:!0,pos:[0,0],size:a}),x=i&&be.createLabels(this.workOptions,n)||[];return p.append(...x,O),this.replace(n,e,p),i&&(await new Promise(m=>{setTimeout(m,0)}),this.updateLabelsWidth(p)),{x:Math.floor(y.x*v[0]+f[0]),y:Math.floor(y.y*v[1]+f[1]),w:Math.floor(y.w*v[0]),h:Math.floor(y.h*v[1])}}async consumeServiceAsync(t){var f,v,l,p;const e=(f=this.workId)==null?void 0:f.toString();if(!e)return;const{isFullWork:n,replaceId:i,isDrawLabel:a}=t;this.oldRect=i&&((l=(v=this.vNodes)==null?void 0:v.get(i))==null?void 0:l.rect)||void 0;const s=n?this.fullLayer:this.drawLayer||this.fullLayer,o=await this.draw({workId:e,layer:s,isDrawLabel:a||this.workOptions.workState===Rt.Done});return(p=this.vNodes)==null||p.setInfo(e,{rect:o,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&yt.getCenterPos(o,s)}),o}updateLabelsWidth(t){t.children.forEach(e=>{if(e.tagName==="LABEL"){const n=e.name,{width:i}=e.getBoundingClientRect(),[a]=t.worldScaling,{underline:s,lineThrough:o}=this.getWorkOptions();s&&t.getElementsByName(`${n}_underline`)[0].attr({points:[0,0,i/a,0]}),o&&t.getElementsByName(`${n}_lineThrough`)[0].attr({points:[0,0,i/a,0]})}})}updataOptService(){}async updataOptServiceAsync(t){var y,O;if(!this.workId)return;const e=this.workId.toString(),{fontColor:n,fontBgColor:i,bold:a,italic:s,lineThrough:o,underline:f,zIndex:v}=t,l=(y=this.vNodes)==null?void 0:y.get(e);if(!l)return;n&&(l.opt.fontColor=n),i&&(l.opt.fontBgColor=i),a&&(l.opt.bold=a),s&&(l.opt.italic=s),ce(o)&&(l.opt.lineThrough=o),ce(f)&&(l.opt.underline=f),i&&(l.opt.fontBgColor=i),Qt(v)&&(l.opt.zIndex=v),this.oldRect=l.rect;const p=await this.draw({workId:e,layer:this.fullLayer,isDrawLabel:this.workOptions.workState===Rt.Done});return(O=this.vNodes)==null||O.setInfo(e,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&yt.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getFontWidth(t){const{ctx:e,opt:n,text:i}=t,{bold:a,italic:s,fontSize:o,fontFamily:f}=n;return e.font=`${a} ${s} ${o}px ${f}`,e.measureText(i).width}static createLabels(t,e){const n=[],i=t.text.split(","),a=i.length;for(let s=0;s<a;s++){const o=i[s],{fontSize:f,lineHeight:v,bold:l,textAlign:p,italic:y,boxSize:O,fontFamily:x,verticalAlign:m,fontColor:T,underline:c,lineThrough:h}=t,u=v||f*1.2,g=e&&e.parent.canvas.getContext("2d"),M=g&&be.getFontWidth({text:o,opt:t,ctx:g,worldScaling:e.worldScaling});if(M){const A={anchor:[0,.5],text:o,fontSize:f,lineHeight:u,fontFamily:x,fontWeight:l,fillColor:T,textAlign:p,fontStyle:y,name:s.toString(),className:"label"},I=[0,0];if(m==="middle"){const E=(a-1)/2;I[1]=(s-E)*u}if(p==="left"){const E=O&&-O[0]/2||0;I[0]=y==="italic"&&E||E+5,console.log("text-left",I)}A.pos=I;const b=new Hh(A);if(n.push(b),c){const E={normalize:!1,pos:[A.pos[0],A.pos[1]+f/2],lineWidth:Math.floor(f/10),points:[0,0,M,0],strokeColor:T,name:`${s}_underline`,className:"underline"},L=new pe(E);n.push(L)}if(h){const E={normalize:!1,pos:A.pos,lineWidth:Math.floor(f/10),points:[0,0,M,0],strokeColor:T,name:`${s}_lineThrough`,className:"lineThrough"},L=new pe(E);n.push(L)}}}return n}static updateNodeOpt(t){const{node:e,opt:n,vNodes:i,targetNode:a}=t,{fontBgColor:s,fontColor:o,translate:f,box:v,boxScale:l,boxTranslate:p,bold:y,italic:O,lineThrough:x,underline:m,fontSize:T,textInfos:c,zIndex:h}=n,u=a&&Jt(a)||i.get(e.name);if(!u)return;const g=e.parent;if(!g)return;const M=u.opt;if(Qt(h)&&(e.setAttribute("zIndex",h),u.opt.zIndex=h),o&&M.fontColor&&(M.fontColor=o,e.children.forEach(A=>{A.tagName==="LABEL"?A.setAttribute("fillColor",o):A.tagName==="POLYLINE"&&A.setAttribute("strokeColor",o)})),s&&M.fontBgColor&&(M.fontBgColor=s),y&&(M.bold=y),O&&(M.italic=O),ce(x)&&(M.lineThrough=x),ce(m)&&(M.underline=m),T&&(M.fontSize=T),v&&p&&l){const A=c==null?void 0:c.get(e.name);if(A){const{fontSize:E,boxSize:L}=A;M.boxSize=L||M.boxSize,M.fontSize=E||M.fontSize}const I=u.rect,b=Re(xn(I,l),p);M.boxPoint=b&&[(b.x-g.worldPosition[0])/g.worldScaling[0],(b.y-g.worldPosition[1])/g.worldScaling[1]]}else if(f&&M.boxPoint){const A=[f[0]/g.worldScaling[0],f[1]/g.worldScaling[1]];M.boxPoint=[M.boxPoint[0]+A[0],M.boxPoint[1]+A[1]],u.centerPos=[u.centerPos[0]+A[0],u.centerPos[1]+A[1]],u.rect=Re(u.rect,A)}return u&&i.setInfo(e.name,u),u==null?void 0:u.rect}static getRectFromLayer(t,e){const n=t.getElementsByName(e)[0];if(n){const i=n.getBoundingClientRect();return{x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width),h:Math.floor(i.height)}}}}function Vn(d){switch(d){case ht.Arrow:return jn;case ht.Pencil:return On;case ht.Straight:return Kn;case ht.Ellipse:return Un;case ht.Polygon:case ht.Triangle:return Gn;case ht.Star:case ht.Rhombus:return zn;case ht.Rectangle:return $n;case ht.SpeechBalloon:return Hn;case ht.Text:return be;case ht.LaserPen:return En;case ht.Eraser:return ae;case ht.Selector:return Nt;case ht.Image:return Le}}function yr(d,r){const{toolsType:t,...e}=d;switch(t){case ht.Arrow:return new jn(e);case ht.Pencil:return new On(e);case ht.Straight:return new Kn(e);case ht.Ellipse:return new Un(e);case ht.Polygon:case ht.Triangle:return new Gn(e);case ht.Star:case ht.Rhombus:return new zn(e);case ht.Rectangle:return new $n(e);case ht.SpeechBalloon:return new Hn(e);case ht.Text:return new be(e);case ht.LaserPen:return new En(e);case ht.Eraser:return new ae(e,r);case ht.Selector:return e.vNodes?new Nt({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case ht.Image:return new Le(e);default:return}}function Yn(d){const r=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE"];for(const e of d){if(e.tagName==="GROUP"&&e.children.length)return Yn(e.children);e.tagName&&t.includes(e.tagName)&&r.push(e)}return r}class l0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetColorNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s,textUpdateForWoker:o}=e,f=n.render||[],v=n.sp||[];if(a)for(const[l,p]of i.entries())o&&p.toolsType===ht.Text?v.push({...p,workId:l,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):v.push({...p,workId:l,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:f,sp:v}}}class c0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.ZIndexNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s}=e,o=n.render||[],f=n.sp||[];if(a&&f)for(const[v,l]of i.entries())f.push({...l,workId:v,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:o,sp:f}}}class f0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.TranslateNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var v,l;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,emitEventType:f}=t;e===Nt.selectorId&&n&&(n.workState===Rt.Done&&(n!=null&&n.translate)&&(n.translate[0]||n.translate[1])||n.workState!==Rt.Done?await((v=this.localWork)==null?void 0:v.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,isSync:!0,textUpdateForWoker:o,emitEventType:f,scene:this.scene,callback:this.updateSelectorCallback})):n.workState===Rt.Done&&((l=this.localWork)==null||l.vNodes.deleteLastTarget()))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v,textUpdateForWoker:l}=e,p=v.workState,y=n.render||[],O=n.sp||[];if(p===Rt.Start)return{sp:[],render:[]};const x=s==null?void 0:s.selectRect;if(o){p===Rt.Doing&&O.push({type:ct.Select,selectIds:a.selectIds,selectRect:x,willSyncService:!0,isSync:!0,points:a.getChildrenPoints(),textOpt:a.textOpt});for(const[m,T]of i.entries())l&&T.toolsType===ht.Text?O.push({...T,workId:m,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):O.push({...T,workId:m,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f})}return{render:y,sp:O}}}class u0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.DeleteNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.RemoveNode){if(n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0;if(n===Tt.Service&&i===this.emitEventType)return this.consumeForServiceWorker(t),!0}}consumeForLocalWorker(t){if(!this.localWork)return;const{removeIds:e,willRefresh:n,willSyncService:i,viewId:a}=t;if(!(e!=null&&e.length))return;let s;const o=[],f=[],v=[];for(const l of e){if(l===Nt.selectorId){const y=this.localWork.workShapes.get(Nt.selectorId);if(!y)return;const O=y.selectIds&&[...y.selectIds]||[];for(const m of O){if(this.localWork.vNodes.get(m)){const c=this.commandDeleteText(m);c&&o.push(c)}s=Ot(s,this.localWork.removeNode(m)),v.push(m)}const x=y==null?void 0:y.updateSelectIds([]);s=Ot(s,x.bgRect),this.localWork.clearWorkShapeNodeCache(Nt.selectorId),this.localWork.workShapes.delete(Nt.selectorId),o.push({type:ct.Select,selectIds:[],willSyncService:i});continue}const p=this.commandDeleteText(l);p&&o.push(p),s=Ot(s,this.localWork.removeNode(l)),v.push(l)}i&&o.push({type:ct.RemoveNode,removeIds:v}),s&&n&&f.push({rect:Bt(s),clearCanvas:Mt.Bg,isClear:!0,viewId:a},{rect:Bt(s),drawCanvas:Mt.Bg,viewId:a}),(f.length||o.length)&&this.localWork._post({render:f,sp:o})}consumeForServiceWorker(t){this.serviceWork&&this.serviceWork.removeSelectWork(t)}commandDeleteText(t){var n;const e=(n=this.localWork)==null?void 0:n.vNodes.get(t);if(e&&e.toolsType===ht.Text)return{type:ct.TextUpdate,toolsType:ht.Text,workId:t,dataType:Tt.Local}}}class h0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.ScaleNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var s;const{workId:e,updateNodeOpt:n,willSyncService:i,willSerializeData:a}=t;e===Nt.selectorId&&n&&await((s=this.localWork)==null?void 0:s.updateSelector({updateSelectorOpt:n,willSyncService:i,willSerializeData:a,isSync:!0,scene:this.scene,callback:this.updateSelectorCallback.bind(this)}))}updateSelectorCallback(t){const{param:e,postData:n,workShapeNode:i,res:a,newServiceStore:s}=t,{updateSelectorOpt:o,willSyncService:f,willSerializeData:v}=e,l=o.workState,p=n.render||[],y=n.sp||[],O=a==null?void 0:a.selectRect;if(l===Rt.Start)return{sp:[],render:[]};if(f){l===Rt.Doing&&y.push({type:ct.Select,selectIds:i.selectIds,selectRect:O,willSyncService:!0,isSync:!0,points:i.getChildrenPoints(),textOpt:i.textOpt}),v&&l===Rt.Done&&y.push({type:ct.Select,selectIds:i.selectIds,selectRect:O,willSyncService:!1,isSync:!0,points:i.getChildrenPoints(),textOpt:i.textOpt});for(const[x,m]of s.entries())m.toolsType===ht.Text?y.push({...m,workId:x,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):y.push({...m,workId:x,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:!0})}return{render:p,sp:y}}}class d0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.RotateNode)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,emitEventType:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,emitEventType:o,isSync:!0,scene:this.scene,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,workShapeNode:i,res:a,newServiceStore:s}=t,{updateSelectorOpt:o,willSyncService:f,willSerializeData:v,isSync:l}=e,p=o.workState,y=n.render||[],O=n.sp||[],x=a==null?void 0:a.selectRect;if(f){v&&p===Rt.Done&&O.push({type:ct.Select,selectIds:i.selectIds,selectRect:x,willSyncService:!0,isSync:l,points:i.getChildrenPoints(),textOpt:i.textOpt,selectorColor:i.selectorColor,strokeColor:i.strokeColor,fillColor:i.fillColor,canTextEdit:i.canTextEdit,canRotate:i.canRotate,scaleType:i.scaleType,opt:i.getWorkOptions()||void 0,canLock:i.canLock,isLocked:i.isLocked,toolsTypes:i.toolsTypes,shapeOpt:i.shapeOpt});for(const[m,T]of s.entries())O.push({...T,workId:m,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:l})}return{render:y,sp:O}}}class g0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetFontStyle)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v,textUpdateForWoker:l}=e,p=n.render||[],y=n.sp||[],O=s==null?void 0:s.selectRect;if(o&&y){v.fontSize&&y.push({type:ct.Select,selectIds:a.selectIds,selectRect:O,willSyncService:o,isSync:f,points:a.getChildrenPoints()});for(const[x,m]of i.entries())l&&m.toolsType===ht.Text?y.push({...m,workId:x,type:ct.TextUpdate,dataType:Tt.Local,willSyncService:!0}):y.push({...m,workId:x,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f})}return{render:p,sp:y}}}class p0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetPoint)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var f;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,textUpdateForWoker:o}=t;e===Nt.selectorId&&n&&await((f=this.localWork)==null?void 0:f.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,emitEventType:this.emitEventType,willSerializeData:s,isSync:!0,textUpdateForWoker:o,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f}=e,v=n.render||[],l=n.sp||[],p=s==null?void 0:s.selectRect;if(o&&l){for(const[y,O]of i.entries())l.push({...O,workId:y,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f});l.push({type:ct.Select,selectIds:a.selectIds,selectRect:p,willSyncService:o,isSync:f,points:a.getChildrenPoints()})}return{render:v,sp:l}}}class v0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetLock)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i,workShapeNode:a,res:s}=t,{willSyncService:o,isSync:f,updateSelectorOpt:v}=e,l=n.render||[],p=n.sp||[],y=s==null?void 0:s.selectRect;if(o&&p){for(const[O,x]of i.entries())p.push({...x,workId:O,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:f});p.push({isLocked:v.isLocked,selectorColor:a.selectorColor,scaleType:a.scaleType,canRotate:a.canRotate,type:ct.Select,selectIds:a.selectIds,selectRect:y,willSyncService:o,isSync:f})}return{render:l,sp:p}}}class m0 extends kt{constructor(){super(...arguments);nt(this,"emitEventType",Lt.SetShapeOpt)}consume(t){const{msgType:e,dataType:n,emitEventType:i}=t;if(e===ct.UpdateNode&&n===Tt.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var o;const{workId:e,updateNodeOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s}=t;e===Nt.selectorId&&n&&await((o=this.localWork)==null?void 0:o.updateSelector({updateSelectorOpt:n,willRefreshSelector:i,willSyncService:a,willSerializeData:s,callback:this.updateSelectorCallback}))}updateSelectorCallback(t){const{param:e,postData:n,newServiceStore:i}=t,{willSyncService:a,isSync:s}=e,o=n.render||[],f=n.sp||[];if(a&&f)for(const[v,l]of i.entries())f.push({...l,workId:v,type:ct.UpdateNode,updateNodeOpt:{useAnimation:!1},isSync:s});return{render:o,sp:f}}}class y0{constructor(r){nt(this,"builders",new Map);this.builders=new Map(r.map(t=>[t,this.build(t)]))}build(r){switch(r){case Lt.TranslateNode:return new f0;case Lt.ZIndexNode:return new c0;case Lt.CopyNode:return new Ch;case Lt.SetColorNode:return new l0;case Lt.DeleteNode:return new u0;case Lt.ScaleNode:return new h0;case Lt.RotateNode:return new d0;case Lt.SetFontStyle:return new g0;case Lt.SetPoint:return new p0;case Lt.SetLock:return new v0;case Lt.SetShapeOpt:return new m0}}registerForWorker(r,t,e){return this.builders.forEach(n=>{n&&n.registerForWorker(r,t,e)}),this}consumeForWorker(r){for(const t of this.builders.values())if(t!=null&&t.consume(r))return!0;return!1}}const Sr="cursorhover";class S0{constructor(r,t){nt(this,"viewId");nt(this,"scene");nt(this,"scenePath");nt(this,"fullLayer");nt(this,"curNodeMap",new Map);nt(this,"targetNodeMap",[]);this.viewId=r,this.scene=t}init(r){this.fullLayer=r}get(r){return this.curNodeMap.get(r)}hasRenderNodes(){let r=!1;for(const t of this.curNodeMap.values())Bh(t)&&(r=!0);return r}has(r){this.curNodeMap.has(r)}setInfo(r,t){const e=this.curNodeMap.get(r)||{name:r,rect:t.rect};t.rect&&(e.rect=Jt(t.rect)),t.op&&(e.op=Jt(t.op)),t.canRotate&&(e.canRotate=t.canRotate),t.scaleType&&(e.scaleType=t.scaleType),t.opt&&(e.opt=Jt(t.opt)),t.toolsType&&(e.toolsType=t.toolsType),t.centerPos&&(e.centerPos=Jt(t.centerPos)),ce(t.isSelected)&&(e.isSelected=t.isSelected),e.rect?this.curNodeMap.set(r,e):this.curNodeMap.delete(r)}selected(r){this.setInfo(r,{isSelected:!0})}unSelected(r){this.setInfo(r,{isSelected:!1})}delete(r){this.curNodeMap.delete(r)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}hasRectIntersectRange(r,t=!0){for(const e of this.curNodeMap.values())if(Ce(r,e.rect)){if(t&&e.toolsType===ht.Image&&e.opt.locked||t&&e.toolsType===ht.Text&&(e.opt.workState===Rt.Doing||e.opt.workState===Rt.Start))continue;return!0}return!1}getRectIntersectRange(r,t=!0){let e;const n=new Map;for(const[i,a]of this.curNodeMap.entries())if(Ce(r,a.rect)){if(t&&a.toolsType===ht.Image&&a.opt.locked||t&&a.toolsType===ht.Text&&(a.opt.workState===Rt.Doing||a.opt.workState===Rt.Start))continue;e=Ot(e,a.rect),n.set(i,a)}return{rectRange:e,nodeRange:n}}getNodeRectFormShape(r,t){const e=Vn(t.toolsType);return this.fullLayer&&(e==null?void 0:e.getRectFromLayer(this.fullLayer,r))}updateNodesRect(){this.curNodeMap.forEach((r,t)=>{const e=this.getNodeRectFormShape(t,r);e?(r.rect=e,this.curNodeMap.set(t,r)):this.curNodeMap.delete(t)})}combineIntersectRect(r){let t=r;return this.curNodeMap.forEach(e=>{Ce(t,e.rect)&&(t=Ot(t,e.rect))}),t}setTarget(){return this.targetNodeMap.push(Jt(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length=this.targetNodeMap.length-1}getTarget(r){return this.targetNodeMap[r]}deleteTarget(r){this.targetNodeMap.length=r}}class Xn{constructor(r,t){nt(this,"viewId");nt(this,"fullLayer");nt(this,"vNodes");nt(this,"dpr");nt(this,"opt");nt(this,"cameraOpt");nt(this,"scene");nt(this,"isSafari",!1);nt(this,"combinePostMsg",new Set);nt(this,"workerTaskId");this.viewId=r,this.opt=t,this.dpr=t.dpr,this.scene=this.createScene(t.offscreenCanvasOpt),this.fullLayer=this.createLayer("fullLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.vNodes=new S0(r,this.scene)}setIsSafari(r){this.isSafari=r}async on(r,t){const{msgType:e,toolsType:n,opt:i,workId:a,workState:s,dataType:o}=r;switch(Qt(t)&&this.post({workerTasksqueueCount:t}),e){case ct.Destroy:this.destroy();break;case ct.Clear:this.clearAll();break;case ct.UpdateTools:if(n&&i){const f={toolsType:n,toolsOpt:i};this.localWork.setToolsOpt(f)}break;case ct.CreateWork:a&&i&&(!this.localWork.getTmpWorkShapeNode()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:i}),this.setWorkOpt({workId:a,toolsOpt:i}));break;case ct.DrawWork:s===Rt.Done&&o===Tt.Local?this.consumeDrawAll(o,r):this.consumeDraw(o,r);break}}updateScene(r){this.scene.attr({...r});const{width:t,height:e}=r;this.scene.container.width=t,this.scene.container.height=e,this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(r){const{width:t,height:e}=r;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",t),this.fullLayer.parent.setAttribute("height",e),this.fullLayer.setAttribute("size",[t,e]),this.fullLayer.setAttribute("pos",[t*.5,e*.5]))}createScene(r){const{width:t,height:e}=r,n=new OffscreenCanvas(t,e);return new Kh({container:n,displayRatio:this.dpr,depth:!1,desynchronized:!0,...r})}createLayer(r,t,e){const{width:n,height:i}=e,a=`offscreen-${r}`,s=t.layer(a,e),o=new se({anchor:[.5,.5],pos:[n*.5,i*.5],size:[n,i],name:"viewport",id:r});return s.append(o),o}clearAll(){var r;this.fullLayer&&(this.fullLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.fullLayer.removeAllChildren()),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy()}setToolsOpt(r){this.localWork.setToolsOpt(r)}setWorkOpt(r){const{workId:t,toolsOpt:e}=r;t&&e&&this.localWork.setWorkOptions(t,e)}destroy(){var r;this.vNodes.clear(),this.fullLayer.remove(),this.scene.remove(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy()}post(r){this.combinePostMsg.add(r),this.runBatchPostData()}runBatchPostData(){this.workerTaskId||(this.workerTaskId=requestAnimationFrame(this.combinePost.bind(this)))}combinePostData(){var a,s;this.workerTaskId=void 0;const r=[],t=[];let e,n;const i=new Set;for(const o of this.combinePostMsg.values()){if((a=o.render)!=null&&a.length)for(const f of o.render){let v=!1;if(f.workId&&i.add(f.workId),f.isClearAll&&(f.rect=this.getSceneRect(),f.isClear=!0,delete f.isClearAll),f.drawCanvas){const l=this.getLayer(f.drawCanvas);if(!l)continue;if(l.parent.render(),f.isDrawAll){const p=this.getSceneRect(),{rectRange:y}=this.vNodes.getRectIntersectRange(p,!1);f.rect=y,delete f.isDrawAll}}for(const l of r)if(f.viewId===l.viewId){f.isClear&&l.clearCanvas&&l.isClear&&l.clearCanvas===f.clearCanvas&&(l.rect=Ot(l.rect,f.rect),v=!0),l.drawCanvas&&l.drawCanvas===f.drawCanvas&&(l.rect=Ot(l.rect,f.rect),v=!0);continue}if(!v)if(f.isClear&&!f.drawCanvas){const l=r.find(p=>p.drawCanvas===f.clearCanvas&&le(p.rect,f.rect));l!=null&&l.rect&&(l.rect=Bt(l.rect,2)),r.unshift(f)}else f.drawCanvas&&!f.clearCanvas&&f.rect&&r.find(l=>l.isClear&&l.clearCanvas===f.drawCanvas&&le(l.rect,f.rect))&&(f.rect=Bt(f.rect,2)),r.push(f)}if((s=o.sp)!=null&&s.length)for(const f of o.sp){let v=!1;for(const l of t)if(le(f,l)){v=!0;break}v||t.push(f)}Qt(o.drawCount)&&(e=o.drawCount),Qt(o.workerTasksqueueCount)&&(n=o.workerTasksqueueCount)}return this.combinePostMsg.clear(),{render:r,sp:t,drawCount:e,workerTasksqueueCount:n,workIds:i}}safariFixRect(r){if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;const t=this.scene.width,e=this.scene.height,n={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(t,r.w)),h:Math.floor(Math.min(e,r.h))};return n.x+n.w>t&&(n.w=Math.floor(t-n.x)),n.y+n.h>e&&(n.h=Math.floor(e-n.y)),n}getSceneRect(){const{width:r,height:t}=this.scene;return{x:0,y:0,w:Math.floor(r),h:Math.floor(t)}}}class Jn{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"thread");nt(this,"fullLayer");nt(this,"drawLayer");nt(this,"_post");nt(this,"tmpWorkShapeNode");nt(this,"tmpOpt");nt(this,"workShapes",new Map);nt(this,"workShapeState",new Map);nt(this,"effectWorkId");nt(this,"drawCount",0);this.thread=r.thread,this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this._post=this.thread.post.bind(r.thread)}destroy(){this.workShapeState.clear(),this.workShapes.clear()}getWorkShape(r){return this.workShapes.get(r)}getTmpWorkShapeNode(){return this.tmpWorkShapeNode}setTmpWorkId(r){if(r&&this.tmpWorkShapeNode){this.tmpWorkShapeNode.setWorkId(r),this.workShapes.set(r,this.tmpWorkShapeNode),this.tmpOpt&&this.setToolsOpt(this.tmpOpt);return}}setWorkOptions(r,t){var n;this.workShapes.get(r)||this.setTmpWorkId(r),(n=this.workShapes.get(r))==null||n.setWorkOptions(t)}createWorkShapeNode(r){var t;return yr({...r,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(t=this.thread)==null?void 0:t.serviceWork)}setToolsOpt(r){var t,e;((t=this.tmpOpt)==null?void 0:t.toolsType)!==r.toolsType&&(e=this.tmpOpt)!=null&&e.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=r,this.tmpWorkShapeNode=this.createWorkShapeNode(r)}clearWorkShapeNodeCache(r){var t;(t=this.getWorkShape(r))==null||t.clearTmpPoints(),this.workShapes.delete(r),this.workShapeState.delete(r)}clearAllWorkShapesCache(){this.workShapes.forEach(r=>r.clearTmpPoints()),this.workShapes.clear(),this.workShapeState.clear()}setFullWork(r){const{workId:t,opt:e,toolsType:n}=r;if(t&&e&&n){const i=t&&this.workShapes.get(t)||this.createWorkShapeNode({toolsOpt:e,toolsType:n,workId:t});return i?(i.setWorkId(t),this.workShapes.set(t,i),i):void 0}}}var x0=Zt,T0=function(){return x0.Date.now()},M0=T0,O0=/\s/;function E0(d){for(var r=d.length;r--&&O0.test(d.charAt(r)););return r}var P0=E0,A0=P0,C0=/^\s+/;function R0(d){return d&&d.slice(0,A0(d)+1).replace(C0,"")}var I0=R0,L0=ue,b0=ie,D0="[object Symbol]";function w0(d){return typeof d=="symbol"||b0(d)&&L0(d)==D0}var N0=w0,W0=I0,Qn=oe,B0=N0,Zn=NaN,F0=/^[-+]0x[0-9a-f]+$/i,j0=/^0b[01]+$/i,U0=/^0o[0-7]+$/i,$0=parseInt;function z0(d){if(typeof d=="number")return d;if(B0(d))return Zn;if(Qn(d)){var r=typeof d.valueOf=="function"?d.valueOf():d;d=Qn(r)?r+"":r}if(typeof d!="string")return d===0?d:+d;d=W0(d);var t=j0.test(d);return t||U0.test(d)?$0(d.slice(2),t?2:8):F0.test(d)?Zn:+d}var G0=z0,H0=oe,xr=M0,kn=G0,K0="Expected a function",V0=Math.max,Y0=Math.min;function X0(d,r,t){var e,n,i,a,s,o,f=0,v=!1,l=!1,p=!0;if(typeof d!="function")throw new TypeError(K0);r=kn(r)||0,H0(t)&&(v=!!t.leading,l="maxWait"in t,i=l?V0(kn(t.maxWait)||0,r):i,p="trailing"in t?!!t.trailing:p);function y(M){var A=e,I=n;return e=n=void 0,f=M,a=d.apply(I,A),a}function O(M){return f=M,s=setTimeout(T,r),v?y(M):a}function x(M){var A=M-o,I=M-f,b=r-A;return l?Y0(b,i-I):b}function m(M){var A=M-o,I=M-f;return o===void 0||A>=r||A<0||l&&I>=i}function T(){var M=xr();if(m(M))return c(M);s=setTimeout(T,x(M))}function c(M){return s=void 0,p&&e?y(M):(e=n=void 0,a)}function h(){s!==void 0&&clearTimeout(s),f=0,e=o=n=s=void 0}function u(){return s===void 0?a:c(xr())}function g(){var M=xr(),A=m(M);if(e=arguments,n=this,o=M,A){if(s===void 0)return O(o);if(l)return clearTimeout(s),s=setTimeout(T,r),y(o)}return s===void 0&&(s=setTimeout(T,r)),a}return g.cancel=h,g.flush=u,g}var J0=X0,Q0=J0,Z0=oe,k0="Expected a function";function q0(d,r,t){var e=!0,n=!0;if(typeof d!="function")throw new TypeError(k0);return Z0(t)&&(e="leading"in t?!!t.leading:e,n="trailing"in t?!!t.trailing:n),Q0(d,r,{leading:e,maxWait:r,trailing:n})}var _0=q0,tg=Xt(_0);class eg extends Jn{constructor(t){super(t);nt(this,"combineUnitTime",600);nt(this,"combineTimerId");nt(this,"effectSelectNodeData",new Set);nt(this,"batchEraserWorks",new Set);nt(this,"batchEraserRemoveNodes",new Set);nt(this,"batchEraserCombine",tg(()=>{const t=this.updateBatchEraserCombineNode(this.batchEraserWorks,this.batchEraserRemoveNodes);this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear(),t.length&&this._post({render:t})},100,{leading:!1}))}consumeDraw(t,e){const{op:n,workId:i}=t;if(n!=null&&n.length&&i){const a=this.workShapes.get(i);if(!a)return;const s=a.toolsType;if(s===ht.LaserPen)return;const o=a.consume({data:t,isFullWork:!0});switch(s){case ht.Selector:o.type===ct.Select&&(o.selectIds&&e.runReverseSelectWork(o.selectIds),this.drawSelector(o));break;case ht.Eraser:o!=null&&o.rect&&this.drawEraser(o);break;case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:o&&(this.drawCount++,this.drawPencil(o));break;case ht.Pencil:this.combineTimerId||(this.combineTimerId=setTimeout(()=>{this.combineTimerId=void 0,this.drawPencilCombine(i)},Math.floor(a.getWorkOptions().syncUnitTime||this.combineUnitTime/2))),o&&(this.drawCount++,this.drawPencil(o));break}}}consumeDrawAll(t,e){var a,s,o;this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0);const{workId:n,scenePath:i}=t;if(n){const f=this.workShapes.get(n);if(!f)return;const v=f.toolsType;if(v===ht.LaserPen)return;const l=this.workShapes.get(Sr),p=(a=l==null?void 0:l.selectIds)==null?void 0:a[0],y=f.consumeAll({data:t}),O=this.workShapeState.get(n);switch(v){case ht.Selector:y.selectIds&&p&&((s=y.selectIds)!=null&&s.includes(p))&&l.cursorBlur(),y.selectIds&&e.runReverseSelectWork(y.selectIds),this.drawSelector({...y,scenePath:i}),(o=f.selectIds)!=null&&o.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(n);break;case ht.Eraser:y!=null&&y.rect&&this.drawEraser({...y,scenePath:i}),f.clearTmpPoints();break;case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:this.drawPencilFull({...y,scenePath:i},f.getWorkOptions(),O),this.drawCount=0,this.clearWorkShapeNodeCache(n);break;case ht.Pencil:y!=null&&y.rect&&(this.drawPencilFull({...y,scenePath:i},f.getWorkOptions(),O),this.drawCount=0),this.clearWorkShapeNodeCache(n);break}}}async consumeFull(t,e){var a,s;const n=this.setFullWork(t),i=t.ops&&Ie(t.ops);if(n){const o=(a=t.workId)==null?void 0:a.toString();if(!o)return;const f=(s=this.vNodes.get(o))==null?void 0:s.rect;let v,l;n.toolsType===ht.Image&&e?(v=await n.consumeServiceAsync({scene:e,isFullWork:!0,replaceId:o}),l=(t==null?void 0:t.updateNodeOpt)&&n.updataOptService(t.updateNodeOpt)):n.toolsType===ht.Text?v=await n.consumeServiceAsync({isFullWork:!0,replaceId:o}):(v=n.consumeService({op:i,isFullWork:!0,replaceId:o}),l=(t==null?void 0:t.updateNodeOpt)&&n.updataOptService(t.updateNodeOpt)),v=Ot(v,l);const p=[],y=[];if(t.workId&&this.workShapes.delete(t.workId),n.toolsType===ht.Text&&console.log("text-render",n.getWorkOptions(),v,t.willRefresh,this.fullLayer.children),v&&t.willRefresh&&(f&&p.push({rect:v,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}),p.push({rect:v,drawCanvas:Mt.Bg,viewId:this.viewId})),t.willSyncService&&y.push({opt:t.opt,toolsType:t.toolsType,type:ct.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),p.length||y.length){const O={render:p,sp:y};this._post(O)}}}removeWork(t){const{workId:e}=t,n=e==null?void 0:e.toString();if(n){const i=this.removeNode(n);i&&this._post({render:[{rect:Bt(i),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(i),drawCanvas:Mt.Bg,viewId:this.viewId}]})}}removeNode(t){var i;this.workShapes.has(t)&&this.clearWorkShapeNodeCache(t);let e;const n=this.vNodes.get(t);return n&&(this.fullLayer.getElementsByName(t).concat(((i=this.drawLayer)==null?void 0:i.getElementsByName(t))||[]).forEach(a=>{a.remove()}),e=Ot(e,n.rect),this.vNodes.delete(t)),e}async checkTextActive(t){const{op:e,viewId:n,dataType:i}=t;if(e!=null&&e.length){let a;for(const s of this.vNodes.curNodeMap.values()){const{rect:o,name:f,toolsType:v,opt:l}=s,p=e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y=e[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];if(v===ht.Text&&Nh([p,y],o)&&l.workState===Rt.Done){a=f;break}}a&&(await this.blurSelector({viewId:n,msgType:ct.Select,dataType:i,isSync:!0}),this._post({sp:[{type:ct.GetTextActive,toolsType:ht.Text,workId:a}]}))}}async colloctEffectSelectWork(t){const e=this.workShapes.get(Nt.selectorId),{workId:n,msgType:i}=t;if(e&&n&&e.selectIds&&e.selectIds.includes(n.toString())){i===ct.RemoveNode?e.selectIds=e.selectIds.filter(a=>a!==n.toString()):this.effectSelectNodeData.add(t),await new Promise(a=>{setTimeout(()=>{a(!0)},0)}),await this.runEffectSelectWork(!0).then(()=>{var a;(a=this.effectSelectNodeData)==null||a.clear()});return}return t}async updateSelector(t){var O;const e=this.workShapes.get(Nt.selectorId);if(!((O=e==null?void 0:e.selectIds)!=null&&O.length))return;const{callback:n,...i}=t,{updateSelectorOpt:a,willSerializeData:s,scene:o}=i,f=await(e==null?void 0:e.updateSelector({updateSelectorOpt:a,selectIds:e.selectIds,vNodes:this.vNodes,willSerializeData:s,worker:this,scene:o})),v=new Map;e.selectIds.forEach(x=>{const m=this.vNodes.get(x);if(m){const{toolsType:T,op:c,opt:h}=m;v.set(x,{opt:h,toolsType:T,ops:(c==null?void 0:c.length)&&qt(c)||void 0})}});const l=[],p=[];f!=null&&f.rect&&l.push({rect:Bt(f.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(f.rect),drawCanvas:Mt.Bg,viewId:this.viewId});const y=n&&n({res:f,workShapeNode:e,param:i,postData:{render:l,sp:p},newServiceStore:v})||{render:l,sp:p};(y.render.length||y.sp.length)&&this._post(y)}async blurSelector(t){var i;const e=this.workShapes.get(Nt.selectorId),n=e==null?void 0:e.blurSelector();if(this.clearWorkShapeNodeCache(Nt.selectorId),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(a=>{a.name===Nt.selectorId&&a.remove()}),n){const a=[];a.push({...n,isSync:t==null?void 0:t.isSync}),this._post({render:(n==null?void 0:n.rect)&&[{rect:Bt(n.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(n.rect),drawCanvas:Mt.Bg,viewId:this.viewId}],sp:a})}}reRenderSelector(t=!1){var a;const e=this.workShapes.get(Nt.selectorId);if(!e)return;if(e&&!((a=e.selectIds)!=null&&a.length))return this.blurSelector();const n=e.oldSelectRect,i=e.reRenderSelector();if(i){const s=Ot(n,i)||i;this._post({render:[{rect:Bt(s),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(s),drawCanvas:Mt.Bg,viewId:this.viewId}],sp:[{type:ct.Select,selectIds:e.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:e.getChildrenPoints(),textOpt:e.textOpt,selectorColor:e.selectorColor,strokeColor:e.strokeColor,fillColor:e.fillColor,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,opt:e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt}]})}}updateFullSelectWork(t){var i,a,s,o,f,v,l;const e=this.workShapes.get(Nt.selectorId),{selectIds:n}=t;if(!(n!=null&&n.length)){this.blurSelector(t);return}if(!e){!this.setFullWork(t)&&t.workId&&((i=this.tmpWorkShapeNode)==null?void 0:i.toolsType)===ht.Selector&&this.setTmpWorkId(t.workId),this.updateFullSelectWork(t);return}if(e&&(n!=null&&n.length)){const{bgRect:p,selectRect:y}=e.updateSelectIds(n),O={render:[],sp:[]};p&&((a=O.render)==null||a.push({rect:Bt(p),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(p),drawCanvas:Mt.Bg,viewId:this.viewId})),(l=O.sp)==null||l.push({...t,selectorColor:((s=t.opt)==null?void 0:s.strokeColor)||e.selectorColor,strokeColor:((o=t.opt)==null?void 0:o.strokeColor)||e.strokeColor,fillColor:((f=t.opt)==null?void 0:f.fillColor)||e.fillColor,textOpt:((v=t.opt)==null?void 0:v.textOpt)||e.textOpt,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,type:ct.Select,selectRect:y,points:e.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt}),this._post(O)}}destroy(){super.destroy(),this.effectSelectNodeData.clear(),this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear()}drawPencilCombine(t){var n,i,a;const e=(n=this.workShapes.get(t))==null?void 0:n.combineConsume();if(e){const s={render:[],drawCount:this.drawCount};if(e!=null&&e.rect){const o=Bt(e.rect);(i=s.render)==null||i.push({rect:o,isClear:!0,clearCanvas:Mt.Float,viewId:this.viewId}),(a=s.render)==null||a.push({rect:o,drawCanvas:Mt.Float,viewId:this.viewId})}this._post(s)}}drawSelector(t){var n;const e={render:[],sp:[t]};t.rect&&((n=e.render)==null||n.push({rect:Bt(t.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(t.rect),drawCanvas:Mt.Bg,viewId:this.viewId})),this._post(e)}async drawEraser(t){var n,i;const e=[];if((n=t.newWorkDatas)!=null&&n.size){for(const a of t.newWorkDatas.values()){const s=a.workId.toString();this.batchEraserWorks.add(s),e.push({type:ct.FullWork,workId:s,ops:qt(a.op),opt:a.opt,toolsType:a.toolsType,updateNodeOpt:{useAnimation:!1}})}delete t.newWorkDatas}(i=t.removeIds)==null||i.forEach(a=>{this.batchEraserRemoveNodes.add(a)}),e.push(t),this._post({sp:e}),this.batchEraserCombine()}drawPencil(t){this._post({drawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]})}drawPencilFull(t,e,n){var s;let i=(n==null?void 0:n.willClear)||(e==null?void 0:e.isOpacity)||!1;!i&&t.rect&&(i=this.vNodes.hasRectIntersectRange(t.rect));const a={drawCount:1/0,render:[],sp:[t]};(s=a.render)==null||s.push({isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId},{rect:t.rect,isClear:i,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Mt.Bg,viewId:this.viewId}),this._post(a)}updateBatchEraserCombineNode(t,e){const n=[];let i;for(const a of e.keys())this.fullLayer.getElementsByName(a).forEach(s=>{const o=s.getBoundingClientRect();i=Ot(i,{x:o.x-ae.SafeBorderPadding,y:o.y-ae.SafeBorderPadding,w:o.width+ae.SafeBorderPadding*2,h:o.height+ae.SafeBorderPadding*2}),s.remove()});return t.forEach(a=>{const s=this.vNodes.get(a);if(s)if(this.fullLayer.getElementsByName(a)[0])i=Ot(i,s.rect);else{const f=this.setFullWork({...s,workId:a}),v=f&&f.consumeService({op:s.op,isFullWork:!0});v&&(s.rect=v,i=Ot(i,v))}}),i&&n.push({rect:i,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:i,drawCanvas:Mt.Bg,viewId:this.viewId}),n}async runEffectSelectWork(t){var e,n,i;for(const a of this.effectSelectNodeData.values()){const s=this.setFullWork(a);if(s){const o=(e=s.getWorkId())==null?void 0:e.toString();if(s.toolsType===ht.Image)await s.consumeServiceAsync({scene:(i=(n=this.drawLayer)==null?void 0:n.parent)==null?void 0:i.parent,isFullWork:!0,replaceId:o});else if(s.toolsType===ht.Text)await s.consumeServiceAsync({isFullWork:!0,replaceId:o});else{const f=a.ops&&Ie(a.ops);s.consumeService({op:f,isFullWork:!0,replaceId:o}),a!=null&&a.updateNodeOpt&&s.updataOptService(a.updateNodeOpt)}a.workId&&this.workShapes.delete(a.workId)}}this.reRenderSelector(t)}cursorHover(t){var s;const{opt:e,toolsType:n,point:i}=t,a=this.setFullWork({workId:Sr,toolsType:n,opt:e});if(a&&i){const o=a.cursorHover(i),f={render:[]};o&&o.type===ct.CursorHover&&o.rect&&((s=f.render)==null||s.push({rect:Bt(o.rect),clearCanvas:Mt.Bg,isClear:!0,viewId:this.viewId},{rect:Bt(o.rect),drawCanvas:Mt.Bg,viewId:this.viewId}),this._post(f))}}}class rg{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"fullLayer");nt(this,"drawLayer");nt(this,"workShapes",new Map);nt(this,"selectorWorkShapes",new Map);nt(this,"animationId");nt(this,"willRunEffectSelectorIds",new Set);nt(this,"runEffectId");nt(this,"noAnimationRect");nt(this,"post");this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this.post=r.thread.post.bind(r.thread)}destroy(){this.workShapes.clear(),this.selectorWorkShapes.clear(),this.willRunEffectSelectorIds.clear()}consumeDraw(r){this.activeWorkShape(r),this.runAnimation()}consumeFull(r){this.activeWorkShape(r),this.runAnimation()}clearAllWorkShapesCache(){this.workShapes.forEach((r,t)=>{r.toolsType===ht.LaserPen?setTimeout(()=>{this.workShapes.delete(t)},2e3):this.workShapes.delete(t)})}runSelectWork(r){this.activeSelectorShape(r);const{workId:t}=r,e=t==null?void 0:t.toString();e&&this.willRunEffectSelectorIds.add(e),this.runEffect()}setNodeKey(r,t,e){return r.toolsType=t,r.node=yr({toolsType:t,toolsOpt:e,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),r}runReverseSelectWork(r){r.forEach(t=>{this.selectorWorkShapes.forEach((e,n)=>{var i;if((i=e.selectIds)!=null&&i.length){const a=e.selectIds.indexOf(t);a>-1&&(e.selectIds.splice(a,1),this.willRunEffectSelectorIds.add(n))}})}),this.willRunEffectSelectorIds.size&&this.runEffect()}removeWork(r){const{workId:t}=r,e=t==null?void 0:t.toString();if(e){const n=this.workShapes.get(e);if(n){this.workShapes.delete(e),this.removeNode(e,r,n==null?void 0:n.totalRect,!1);return}this.removeNode(e,r)}}removeSelectWork(r){const{workId:t}=r,e=t==null?void 0:t.toString();e&&(this.activeSelectorShape(r),this.willRunEffectSelectorIds.add(e)),this.runEffect()}removeNode(r,t,e,n=!0){var s;r.indexOf(Nt.selectorId)>-1&&this.removeSelectWork(t);let i=e;const a=(s=this.vNodes.get(r))==null?void 0:s.rect;a&&(i=Ot(a,i)),this.fullLayer.getElementsByName(r).forEach(o=>{o.remove()}),this.drawLayer.getElementsByName(r).forEach(o=>{o.remove()}),this.vNodes.delete(r),i&&this.post({render:[{rect:Bt(i),isClear:!0,clearCanvas:n?Mt.Bg:Mt.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId},{rect:Bt(i),drawCanvas:n?Mt.Bg:Mt.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId}]})}activeWorkShape(r){var y,O,x,m;const{workId:t,opt:e,toolsType:n,type:i,updateNodeOpt:a,ops:s,op:o,useAnimation:f}=r;if(!t)return;const v=t.toString(),l=(y=this.vNodes.get(v))==null?void 0:y.rect;if(!((O=this.workShapes)!=null&&O.has(v))){let T={toolsType:n,animationWorkData:o||[],animationIndex:0,type:i,updateNodeOpt:a,ops:s,useAnimation:typeof f<"u"?f:typeof(a==null?void 0:a.useAnimation)<"u"?a==null?void 0:a.useAnimation:!0,oldRect:l,isDiff:!1};n&&e&&(T=this.setNodeKey(T,n,e)),(x=this.workShapes)==null||x.set(v,T)}const p=(m=this.workShapes)==null?void 0:m.get(v);i&&(p.type=i),s&&(p.animationWorkData=Ie(s),p.ops=s),a&&(p.updateNodeOpt=a),o&&(p.isDiff=this.hasDiffData(p.animationWorkData||[],o,p.toolsType),p.animationWorkData=o),p.node&&p.node.getWorkId()!==v&&p.node.setWorkId(v),l&&(p.oldRect=l),n&&e&&(p.toolsType!==n&&n&&e&&this.setNodeKey(p,n,e),p.node&&p.node.setWorkOptions(e))}hasDiffData(r,t,e){const n=r.length;if(t.length<n)return!0;switch(e){case ht.Pencil:{for(let i=0;i<n;i+=3)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break}case ht.LaserPen:{for(let i=0;i<n;i+=2)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break}}return!1}async animationDraw(){var n,i,a,s,o,f,v,l,p,y,O,x,m,T,c,h,u,g,M,A,I,b,E,L,D,R,C,W;this.animationId=void 0;let r=!1;const t={render:[]},e=new Map;for(const[z,H]of this.workShapes.entries())switch(H.toolsType){case ht.Image:{const X=H.oldRect;X&&((n=t.render)==null||n.push({rect:X,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}));const Z=await((a=H.node)==null?void 0:a.consumeServiceAsync({isFullWork:!0,scene:(i=this.fullLayer.parent)==null?void 0:i.parent}));this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.runEffect())}),this.workShapes.delete(z),(s=t.render)==null||s.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId});break}case ht.Text:{if(H.node){const X=H.oldRect,Z=await H.node.consumeServiceAsync({isFullWork:!0,replaceId:z});this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.runEffect())}),(o=H.node)==null||o.clearTmpPoints(),this.workShapes.delete(z),(f=t.render)==null||f.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId})}break}case ht.Arrow:case ht.Straight:case ht.Rectangle:case ht.Ellipse:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:{const X=!!H.ops;if((v=H.animationWorkData)!=null&&v.length){const Z=H.oldRect,j=H.node.oldRect;Z&&((l=t.render)==null||l.push({rect:Z,isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId}),(p=t.render)==null||p.push({rect:Z,drawCanvas:Mt.Bg,viewId:this.viewId})),j&&((y=t.render)==null||y.push({rect:j,isClear:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId}));const G=(O=H.node)==null?void 0:O.consumeService({op:H.animationWorkData,isFullWork:X});e.set(z,{workState:Z?H.ops?Rt.Done:Rt.Doing:Rt.Start,op:H.animationWorkData.filter((Q,tt)=>{if(tt%3!==2)return!0}).slice(-2)}),X?(this.selectorWorkShapes.forEach((Q,tt)=>{var et;(et=Q.selectIds)!=null&&et.includes(z)&&(this.willRunEffectSelectorIds.add(tt),this.noAnimationRect=Ot(this.noAnimationRect,Z),this.noAnimationRect=Ot(this.noAnimationRect,j),this.noAnimationRect=Ot(this.noAnimationRect,G),this.runEffect())}),(x=H.node)==null||x.clearTmpPoints(),this.workShapes.delete(z),(m=t.render)==null||m.push({rect:G,drawCanvas:Mt.Bg,viewId:this.viewId})):(T=t.render)==null||T.push({rect:G,drawCanvas:Mt.ServiceFloat,workerType:X?void 0:Tt.Service,viewId:this.viewId}),H.animationWorkData.length=0}break}case ht.Pencil:{if(!H.useAnimation&&H.ops){let X=(c=H.node)==null?void 0:c.consumeService({op:H.animationWorkData||[],isFullWork:!0,replaceId:z});const Z=(h=H.node)==null?void 0:h.updataOptService(H.updateNodeOpt);X=Ot(X,Z),(u=t.render)==null||u.push({isClear:!0,rect:Ot(H.oldRect,X),clearCanvas:Mt.Bg,viewId:this.viewId}),(g=t.render)==null||g.push({rect:Ot(H.oldRect,X),drawCanvas:Mt.Bg,viewId:this.viewId}),this.selectorWorkShapes.forEach((j,G)=>{var Q;(Q=j.selectIds)!=null&&Q.includes(z)&&(this.willRunEffectSelectorIds.add(G),this.noAnimationRect=Ot(this.noAnimationRect,X),this.runEffect())}),(M=H.node)==null||M.clearTmpPoints(),this.workShapes.delete(z)}else if(H.useAnimation){if(H.isDel){(A=H.node)==null||A.clearTmpPoints(),this.workShapes.delete(z);break}const X=3,Z=this.computNextAnimationIndex(H,X),j=H.isDiff?0:Math.max(0,(H.animationIndex||0)-X),G=(H.animationWorkData||[]).slice(j,Z),Q=(b=(I=H.node)==null?void 0:I.getWorkId())==null?void 0:b.toString();if((H.animationIndex||0)<Z||H.isDiff){const tt=(E=H.node)==null?void 0:E.consumeService({op:G,isFullWork:!1});if((L=t.render)==null||L.push({rect:tt,drawCanvas:Mt.ServiceFloat,viewId:this.viewId}),H.animationIndex=Z,H.isDiff&&(H.isDiff=!1),G.length){const et=G.filter((at,q)=>{if(q%X!==X-1)return!0}).slice(-2);e.set(z,{workState:j===0?Rt.Start:Z===((D=H.animationWorkData)==null?void 0:D.length)?Rt.Done:Rt.Doing,op:et})}}else if(H.ops){const tt=(R=H.node)==null?void 0:R.consumeService({op:H.animationWorkData||[],isFullWork:!0,replaceId:Q});H.isDel=!0,(C=t.render)==null||C.push({isClear:!0,rect:tt,clearCanvas:Mt.ServiceFloat,viewId:this.viewId},{rect:tt,drawCanvas:Mt.ServiceFloat,viewId:this.viewId},{isClear:!0,rect:tt,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:tt,drawCanvas:Mt.Bg,viewId:this.viewId}),e.set(z,{workState:Rt.Done,op:G.filter((et,at)=>{if(at%X!==X-1)return!0}).slice(-2)})}r=!0;break}break}}r&&this.runAnimation(),e.size&&(t.sp=[],e.forEach((z,H)=>{var X;(X=t.sp)==null||X.push({type:ct.Cursor,uid:H.split(pr)[0],op:z.op,workState:z.workState,viewId:this.viewId})})),(W=t.render)!=null&&W.length&&this.post(t)}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationDraw.bind(this)))}computNextAnimationIndex(r,t){var n;const e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/(((n=r.node)==null?void 0:n.syncUnitTime)||1e3))*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length)}runEffect(){this.runEffectId||(this.runEffectId=setTimeout(this.effectRunSelector.bind(this),0))}effectRunSelector(){this.runEffectId=void 0;let r=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(t=>{var i,a;const e=this.selectorWorkShapes.get(t),n=e&&e.selectIds&&((i=e.node)==null?void 0:i.selectServiceNode(t,e,!0));r=Ot(r,n),(a=e==null?void 0:e.selectIds)!=null&&a.length||this.selectorWorkShapes.delete(t)}),r&&this.post({render:[{rect:Bt(r),isClear:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{rect:Bt(r),drawCanvas:Mt.Bg,viewId:this.viewId}]}),this.willRunEffectSelectorIds.clear(),this.noAnimationRect=void 0}activeSelectorShape(r){var f,v,l;const{workId:t,opt:e,toolsType:n,type:i,selectIds:a}=r;if(!t)return;const s=t.toString();if(!((f=this.selectorWorkShapes)!=null&&f.has(s))){let p={toolsType:n,selectIds:a,type:i,opt:e};n&&e&&(p=this.setNodeKey(p,n,e)),(v=this.selectorWorkShapes)==null||v.set(s,p)}const o=(l=this.selectorWorkShapes)==null?void 0:l.get(s);i&&(o.type=i),o.node&&o.node.getWorkId()!==s&&o.node.setWorkId(s),o.selectIds=a||[]}}class ng extends Jn{constructor(t){super(t);nt(this,"combineDrawTimer")}async runFullWork(t){var i,a;const e=this.setFullWork(t),n=t.ops&&Ie(t.ops);if(e){let s,o;const f=(i=e.getWorkId())==null?void 0:i.toString();return e.toolsType===ht.Image?s=await e.consumeServiceAsync({isFullWork:!0,scene:(a=this.fullLayer.parent)==null?void 0:a.parent}):e.toolsType===ht.Text?s=await e.consumeServiceAsync({isFullWork:!0,replaceId:f,isDrawLabel:!0}):(s=e.consumeService({op:n,isFullWork:!0,replaceId:f}),o=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt)),t.workId&&this.workShapes.delete(t.workId),Ot(s,o)}}runSelectWork(t){var n;const e=this.setFullWork(t);e&&((n=t.selectIds)!=null&&n.length)&&t.workId&&e.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1)}consumeDraw(t){const{workId:e}=t,n=this.workShapes.get(e);if(!n)return;const i=n.toolsType,a=n.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0});switch(i){case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:{a&&(this.drawCount++,this.drawArrow(a));break}case ht.Pencil:{a&&(this.drawCount++,this.drawPencil(a,e==null?void 0:e.toString()));break}}}consumeDrawAll(t){const{workId:e}=t;if(e){const n=this.workShapes.get(e);if(!n)return;switch(n.toolsType){case ht.Arrow:case ht.Straight:case ht.Ellipse:case ht.Pencil:case ht.Rectangle:case ht.Star:case ht.Polygon:case ht.SpeechBalloon:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e);break}}}updateLabels(t,e){t.children.forEach(n=>{if(n.tagName==="LABEL"){const i=n.name,{width:a}=n.getBoundingClientRect(),[s]=t.worldScaling,{underline:o,lineThrough:f}=e.opt;o&&t.getElementsByName(`${i}_underline`)[0].attr({points:[0,0,a/s,0]}),f&&t.getElementsByName(`${i}_lineThrough`)[0].attr({points:[0,0,a/s,0]})}})}drawPencil(t,e){this._post({drawCount:this.drawCount,render:[{rect:t==null?void 0:t.rect,workId:e,drawCanvas:Mt.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]})}drawArrow(t){this._post({drawCount:this.drawCount,render:[{rect:(t==null?void 0:t.rect)&&Bt(t.rect),isClear:!0,clearCanvas:Mt.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&Bt(t.rect),drawCanvas:Mt.Float,viewId:this.viewId}]})}}class ig{constructor(r){nt(this,"viewId");nt(this,"vNodes");nt(this,"topLayer");nt(this,"post");nt(this,"serviceWorkShapes",new Map);nt(this,"localWorkShapes",new Map);nt(this,"tmpOpt");nt(this,"tmpWorkShapeNode");nt(this,"animationId");this.viewId=r.viewId,this.vNodes=r.vNodes,this.topLayer=r.topLayer,this.post=r.thread.post.bind(r.thread)}getWorkShape(r){return this.localWorkShapes.get(r)}getTmpWorkShapeNode(){return this.tmpWorkShapeNode}setTmpWorkId(r){if(r&&this.tmpWorkShapeNode){this.tmpWorkShapeNode.setWorkId(r),this.localWorkShapes.set(r,{node:this.tmpWorkShapeNode,toolsType:this.tmpWorkShapeNode.toolsType,workState:Rt.Start}),this.tmpOpt&&this.setToolsOpt(this.tmpOpt);return}}setWorkOptions(r,t){var n,i,a;((n=this.localWorkShapes.get(r))==null?void 0:n.node)||this.setTmpWorkId(r),(a=(i=this.localWorkShapes.get(r))==null?void 0:i.node)==null||a.setWorkOptions(t)}createWorkShapeNode(r){const{toolsType:t}=r;if(t===ht.LaserPen)return yr({...r,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(r=>{var t;return(t=r.node)==null?void 0:t.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(r){this.tmpOpt=r,this.tmpWorkShapeNode=this.createWorkShapeNode(r)}consumeDraw(r){const{workId:t,dataType:e}=r;if(e===Tt.Service)this.activeServiceWorkShape(r);else{const n=this.localWorkShapes.get(t);if(!n)return;const i=n.node.consume({data:r,isFullWork:!1,isSubWorker:!0});i.rect&&(n.totalRect=Ot(i.rect,n.totalRect),n.result=i,n.workState=Rt.Doing,t&&this.localWorkShapes.set(t,n))}this.runAnimation()}consumeDrawAll(r){const{workId:t,dataType:e}=r;if(e===Tt.Service)this.activeServiceWorkShape(r);else{const n=this.localWorkShapes.get(t);if(!n)return;const i=n.node.consumeAll({data:r});n.totalRect=Ot(i.rect,n.totalRect),n.result=i,n.workState=Rt.Done,t&&this.localWorkShapes.set(t,n)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(r,t,e){return r.toolsType=t,r.node=this.createWorkShapeNode({toolsType:t,toolsOpt:e}),r}activeServiceWorkShape(r){var p,y;const{workId:t,opt:e,toolsType:n,type:i,updateNodeOpt:a,ops:s,op:o}=r;if(!t)return;const f=t.toString(),v=(p=this.vNodes.get(f))==null?void 0:p.rect;if(!((y=this.serviceWorkShapes)!=null&&y.has(f))){let O={toolsType:n,animationWorkData:o||[],animationIndex:0,type:i,updateNodeOpt:a,ops:s,oldRect:v};n&&e&&(O=this.setNodeKey(O,n,e)),this.serviceWorkShapes.set(f,O)}const l=this.serviceWorkShapes.get(f);i&&(l.type=i),s&&(l.animationWorkData=Ie(s),l.ops=s),a&&(l.updateNodeOpt=a),o&&(l.animationWorkData=o),l.node&&l.node.getWorkId()!==f&&l.node.setWorkId(f),v&&(l.oldRect=v),n&&e&&(l.toolsType!==n&&n&&e&&this.setNodeKey(l,n,e),l.node&&l.node.setWorkOptions(e))}computNextAnimationIndex(r,t){var n;const e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/(((n=r.node)==null?void 0:n.syncUnitTime)||1e3))*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length)}async animationDraw(){var a,s,o,f;this.animationId=void 0;let r=!1;const t=new Map,e=[],n=[],i=[];for(const[v,l]of this.serviceWorkShapes.entries())switch(l.toolsType){case ht.LaserPen:{const y=this.computNextAnimationIndex(l,8),O=Math.max(0,l.animationIndex||0),x=(l.animationWorkData||[]).slice(O,y);if((l.animationIndex||0)<y){const m=(a=l.node)==null?void 0:a.consumeService({op:x,isFullWork:!1});l.totalRect=Ot(l.totalRect,m),l.animationIndex=y,x.length&&t.set(v,{workState:O===0?Rt.Start:y===((s=l.animationWorkData)==null?void 0:s.length)?Rt.Done:Rt.Doing,op:x.slice(-2)})}if(n.push({isClear:!0,rect:l.totalRect,clearCanvas:Mt.TopFloat,viewId:this.viewId}),e.push({rect:l.totalRect,drawCanvas:Mt.TopFloat,viewId:this.viewId}),l.isDel){(o=l.node)==null||o.clearTmpPoints(),this.serviceWorkShapes.delete(v);break}l.ops&&l.animationIndex===((f=l.animationWorkData)==null?void 0:f.length)&&!l.isDel&&(this.topLayer.getElementsByName(v.toString())[0]||(l.isDel=!0,this.serviceWorkShapes.set(v,l))),r=!0;break}}for(const[v,l]of this.localWorkShapes.entries()){const{result:p,toolsType:y,totalRect:O,isDel:x,workState:m}=l;switch(y){case ht.LaserPen:{if(O&&(n.push({isClear:!0,rect:O,clearCanvas:Mt.TopFloat,viewId:this.viewId}),e.push({rect:O,drawCanvas:Mt.TopFloat,viewId:this.viewId})),x){l.node.clearTmpPoints(),this.localWorkShapes.delete(v),i.push({removeIds:[v.toString()],viewId:this.viewId,type:ct.RemoveNode});break}p&&((p.op||p.ops)&&i.push(p),l.result=void 0),!this.topLayer.getElementsByName(v.toString())[0]&&m===Rt.Done&&(l.isDel=!0,this.localWorkShapes.set(v,l)),r=!0;break}}}r&&this.runAnimation(),t.size&&t.forEach((v,l)=>{i.push({type:ct.Cursor,uid:l.split(pr)[0],op:v.op,workState:v.workState,viewId:this.viewId})}),(e.length||n.length||i.length)&&this.post({render:[...n,...e],sp:i})}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationDraw.bind(this)))}}var qn=(d=>(d.Full="full",d.Sub="sub",d))(qn||{});class sg{constructor(r,t){nt(this,"_self");nt(this,"type");nt(this,"workThreadMap",new Map);this._self=r,this.type=t,this.register()}init(r){const{viewId:t,dpr:e,offscreenCanvasOpt:n,layerOpt:i,isSafari:a}=r;if(!e||!n||!i)return;let s;this.type==="full"&&(s=new og(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),this.type==="sub"&&(s=new ag(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),s&&a&&s.setIsSafari(a),s&&r.cameraOpt&&s.setCameraOpt(r.cameraOpt),s&&this.workThreadMap.set(t,s)}register(){onmessage=r=>{const t=r.data;if(t)for(const e of t.values()){const{msgType:n,viewId:i,tasksqueue:a,mainTasksqueueCount:s}=e;if(n===ct.Init){this.init(e);continue}if(n===ct.TasksQueue&&(a!=null&&a.size)&&s){for(const[f,v]of this.workThreadMap.entries()){const l=a.get(f);l&&v.on(l,s)}continue}if(i===Zh){for(const f of this.workThreadMap.values())f.on(e),n===ct.Destroy&&this.workThreadMap.delete(i);continue}const o=this.workThreadMap.get(i);o&&(o.on(e),n===ct.Destroy&&this.workThreadMap.delete(i))}}}post(r,t){t?this._self.postMessage(r,t):this._self.postMessage(r)}}class og extends Xn{constructor(t,e,n){super(t,e);nt(this,"serviceDrawLayer");nt(this,"localDrawLayer");nt(this,"snapshotFullLayer");nt(this,"methodBuilder");nt(this,"localWork");nt(this,"serviceWork");nt(this,"_post");this._post=n,this.serviceDrawLayer=this.createLayer("serviceDrawLayer",this.scene,{...e.layerOpt,bufferSize:1e3}),this.localDrawLayer=this.createLayer("localDrawLayer",this.scene,{...e.layerOpt,bufferSize:1e3});const i={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer};this.localWork=new eg({...i,drawLayer:this.localDrawLayer}),this.serviceWork=new rg({...i,drawLayer:this.serviceDrawLayer}),this.methodBuilder=new y0([Lt.CopyNode,Lt.SetColorNode,Lt.DeleteNode,Lt.RotateNode,Lt.ScaleNode,Lt.TranslateNode,Lt.ZIndexNode,Lt.SetFontStyle,Lt.SetPoint,Lt.SetLock,Lt.SetShapeOpt]).registerForWorker(this.localWork,this.serviceWork,this.scene),this.vNodes.init(this.fullLayer)}async combinePost(){var a,s,o,f;const{render:t,...e}=this.combinePostData();let n;if(t!=null&&t.length){const v=[];for(const l of t)if(l.rect){if(l.drawCanvas&&(l.rect=this.safariFixRect(Jt(l.rect))),!l.rect)continue;if(l.drawCanvas&&l.rect){const p=await this.getRectImageBitmap(l);l.imageBitmap=p,n||(n=[]),n.push(p)}v.push(l)}e.render=v}const i=(a=e.sp)==null?void 0:a.filter(v=>v.type!==ct.None||Object.keys(v).filter(l=>l==="type").length);i!=null&&i.length&&(e.sp=i.map(v=>({...v,viewId:this.viewId}))),((s=e.sp)==null?void 0:s.length)===0&&delete e.sp,e.drawCount===void 0&&delete e.drawCount,e.workerTasksqueueCount===void 0&&delete e.workerTasksqueueCount,(e!=null&&e.drawCount||e!=null&&e.workerTasksqueueCount||(o=e.sp)!=null&&o.length||(f=e.render)!=null&&f.length)&&this._post(e,n)}async on(t,e){if(this.methodBuilder.consumeForWorker(t))return;const{msgType:n,dataType:i,workId:a}=t;switch(n){case ct.UpdateCamera:await this.updateCamera(t),e&&this.post({workerTasksqueueCount:e});return;case ct.Select:i===Tt.Service&&(a===Nt.selectorId?this.localWork.updateFullSelectWork(t):this.serviceWork.runSelectWork(t));return;case ct.UpdateNode:case ct.FullWork:await this.consumeFull(i,t);return;case ct.RemoveNode:await this.removeNode(t);return;case ct.GetTextActive:this.checkTextActive(t);return;case ct.CursorHover:this.cursorHover(t);return}await super.on(t)}async removeNode(t){const{dataType:e,workId:n}=t;if(n===Nt.selectorId){this.localWork.blurSelector(t);return}e===Tt.Local&&(this.localWork.removeWork(t),await this.localWork.colloctEffectSelectWork(t)),e===Tt.Service&&(this.serviceWork.removeWork(t),await this.localWork.colloctEffectSelectWork(t))}checkTextActive(t){const{dataType:e}=t;e===Tt.Local&&this.localWork.checkTextActive(t)}clearAll(){this.vNodes.clear(),super.clearAll(),this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.localDrawLayer.removeAllChildren()),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.serviceDrawLayer.removeAllChildren()),this.post({render:[{isClearAll:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId}],sp:[{type:ct.Clear}]})}updateLayer(t){const{width:e,height:n}=t;super.updateLayer(t),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",e),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[e,n]),this.localDrawLayer.setAttribute("pos",[e*.5,n*.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",e),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[e,n]),this.serviceDrawLayer.setAttribute("pos",[e*.5,n*.5]))}setCameraOpt(t){this.cameraOpt=t;const{scale:e,centerX:n,centerY:i,width:a,height:s}=t;(a!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:a,height:s}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[e,e]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[e,e]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[e,e]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]))}getLayer(t){switch(t){case Mt.Bg:return this.fullLayer;case Mt.ServiceFloat:return this.serviceDrawLayer;case Mt.Float:return this.localDrawLayer}}getOffscreen(t){return this.getLayer(t).parent.canvas}async consumeFull(t,e){const n=await this.localWork.colloctEffectSelectWork(e);n&&t===Tt.Local&&await this.localWork.consumeFull(n,this.scene),n&&t===Tt.Service&&this.serviceWork.consumeFull(n)}consumeDraw(t,e){t===Tt.Local&&this.localWork.consumeDraw(e,this.serviceWork),t===Tt.Service&&this.serviceWork.consumeDraw(e)}consumeDrawAll(t,e){t===Tt.Local&&this.localWork.consumeDrawAll(e,this.serviceWork)}async updateCamera(t){var i;const e=[],{cameraOpt:n}=t;if(n&&!le(this.cameraOpt,n)){const a=this.localWork.getWorkShape(Sr);a&&((i=a.selectIds)!=null&&i.length)&&a.cursorBlur();const s=!!this.localDrawLayer.children.length,o=!!this.serviceDrawLayer.children.length;if(this.setCameraOpt(n),this.localWork.workShapes.forEach((f,v)=>{(f.toolsType===ht.Pencil||f.toolsType===ht.Arrow||f.toolsType===ht.Straight||f.toolsType===ht.Ellipse||f.toolsType===ht.Rectangle||f.toolsType===ht.Star||f.toolsType===ht.Polygon||f.toolsType===ht.SpeechBalloon||f.toolsType===ht.Text)&&this.localWork.workShapeState.set(v,{willClear:!0})}),this.vNodes.curNodeMap.size&&(this.vNodes.updateNodesRect(),await this.localWork.reRenderSelector(),this.serviceWork.selectorWorkShapes.size))for(const[f,v]of this.serviceWork.selectorWorkShapes.entries())this.serviceWork.runSelectWork({workId:f,selectIds:v.selectIds,msgType:ct.Select,dataType:Tt.Service,viewId:this.viewId});this.vNodes.hasRenderNodes()&&(s&&e.push({isClearAll:!0,clearCanvas:Mt.Float,viewId:this.viewId}),o&&e.push({isClearAll:!0,clearCanvas:Mt.ServiceFloat,viewId:this.viewId}),e.push({isClearAll:!0,clearCanvas:Mt.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Mt.Bg,viewId:this.viewId})),e.length&&(console.log("cameraOpt---2",e),this.post({render:e}))}}getRectImageBitmap(t){const{rect:e,drawCanvas:n}=t,i=e.x*this.dpr,a=e.y*this.dpr,s=e.w*this.dpr,o=e.h*this.dpr;return createImageBitmap(this.getOffscreen(n),i,a,s,o,{resizeQuality:"low"})}cursorHover(t){this.localWork.cursorHover(t)}}class ag extends Xn{constructor(t,e,n){super(t,e);nt(this,"_post");nt(this,"topLayer");nt(this,"snapshotFullLayer");nt(this,"serviceWork");nt(this,"localWork");nt(this,"topLayerWork");this._post=n,this.topLayer=this.createLayer("topLayer",this.scene,{...e.layerOpt,bufferSize:1500});const i={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new ng(i),this.topLayerWork=new ig(i),this.vNodes.init(this.fullLayer)}async combinePost(){var a,s,o,f,v;const{render:t,...e}=this.combinePostData();let n;if(t!=null&&t.length){const l=[];for(const p of t)if(p.rect){if(p.drawCanvas&&(p.rect=this.safariFixRect(Jt(p.rect))),!p.rect)continue;if(p.drawCanvas&&p.rect){const y=await this.getRectImageBitmap(p);p.imageBitmap=y,n||(n=[]),n.push(y)}l.push(p)}e.render=l}if((a=e.workIds)!=null&&a.size&&e.drawCount)for(const l of e.workIds.values())this.fullLayer.getElementsByName(l).forEach(p=>{p.id&&e.drawCount&&Number(p.id)<e.drawCount&&p.remove()});const i=(s=e.sp)==null?void 0:s.filter(l=>l.type!==ct.None||Object.keys(l).filter(p=>p==="type").length);i!=null&&i.length&&(e.sp=i.map(l=>({...l,viewId:this.viewId}))),((o=e.sp)==null?void 0:o.length)===0&&delete e.sp,e.drawCount===void 0&&delete e.drawCount,e.workerTasksqueueCount===void 0&&delete e.workerTasksqueueCount,((f=e.sp)!=null&&f.length||e.drawCount||(v=e==null?void 0:e.render)!=null&&v.length)&&(console.log("msg---layer--sub--000",this.fullLayer.children.map(l=>({name:l.name,id:l.id})),this.fullLayer),this._post(e,n))}getLayer(t,e){if(e&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case Mt.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(t){const{msgType:e,toolsType:n,opt:i,workId:a,dataType:s}=t;switch(e){case ct.UpdateCamera:await this.updateCamera(t);break;case ct.UpdateTools:if(n===ht.LaserPen&&i){const o={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(o);return}break;case ct.CreateWork:if(n===ht.LaserPen&&a&&i){this.topLayerWork.getTmpWorkShapeNode()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(a,i);return}break;case ct.FullWork:if(n===ht.LaserPen){this.consumeDrawAll(s,t);return}break;case ct.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.snapshotFullLayer&&(await this.getSnapshot(t),this.snapshotFullLayer=void 0);return;case ct.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId==="mainView"?6e3:3e3}),this.snapshotFullLayer&&(await this.getBoundingRect(t),this.snapshotFullLayer=void 0);return}await super.on(t)}getOffscreen(t,e){return this.getLayer(t,e).parent.canvas}consumeDraw(t,e){const{op:n,workId:i}=e;if(n!=null&&n.length&&i){if(this.localWork.workShapes.get(i)){this.localWork.consumeDraw(e);return}if(this.topLayerWork.localWorkShapes.get(i)){this.topLayerWork.consumeDraw(e);return}}}consumeDrawAll(t,e){const{ops:n,op:i,workId:a}=e;if((n||i!=null&&i.length)&&a){if(this.localWork.workShapes.get(a)){this.localWork.consumeDrawAll(e);return}if(this.topLayerWork.localWorkShapes.get(a)){this.topLayerWork.consumeDrawAll(e);return}}}clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(t=>{t.name!=="viewport"&&t.remove()}),this.topLayer.removeAllChildren()),this.post({render:[{isClearAll:!0,clearCanvas:Mt.TopFloat,viewId:this.viewId}],sp:[{type:ct.Clear}]})}getRectImageBitmap(t,e=!1,n){const{rect:i,drawCanvas:a}=t,s=i.x*this.dpr,o=i.y*this.dpr,f=i.w*this.dpr,v=i.h*this.dpr;return createImageBitmap(this.getOffscreen(a,e),s,o,f,v,n)}updateLayer(t){const{width:e,height:n}=t;super.updateLayer(t),this.topLayer&&(this.topLayer.parent.setAttribute("width",e),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[e,n]),this.topLayer.setAttribute("pos",[e*.5,n*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",e),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[e,n]),this.snapshotFullLayer.setAttribute("pos",[e*.5,n*.5]))}async updateCamera(t){const e=[],{cameraOpt:n}=t;if(n&&!le(this.cameraOpt,n)){const i=!!this.topLayerWork.localWorkShapes.size;if(this.setCameraOpt(n),i){e.push({isClearAll:!0,clearCanvas:Mt.TopFloat,viewId:this.viewId});for(const[a,s]of this.topLayerWork.localWorkShapes.entries())if(s.totalRect){let o;this.topLayer.getElementsByName(a.toString()).forEach(f=>{const v=f.getBoundingClientRect(),l=Bt({x:v.x,y:v.y,w:v.width,h:v.height});o=Ot(o,l)}),s.totalRect=o,this.topLayerWork.localWorkShapes.set(a,s)}}e.length&&this.post({render:e})}}setCameraOpt(t,e){this.cameraOpt=t;const{scale:n,centerX:i,centerY:a,width:s,height:o}=t;(s!==this.scene.width||o!==this.scene.height)&&this.updateScene({width:s,height:o}),e?(e.setAttribute("scale",[n,n]),e.setAttribute("translate",[-i,-a])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-a]),this.topLayer.setAttribute("scale",[n,n]),this.topLayer.setAttribute("translate",[-i,-a]))}async getSnapshot(t){const{scenePath:e,scenes:n,cameraOpt:i,w:a,h:s}=t;if(e&&n&&i&&this.snapshotFullLayer){const o=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let f;for(const[l,p]of Object.entries(n))if(p!=null&&p.type)switch(p==null?void 0:p.type){case ct.UpdateNode:case ct.FullWork:{const{opt:y}=p,O=await this.localWork.runFullWork({...p,opt:y,workId:l,msgType:ct.FullWork,dataType:Tt.Service,viewId:this.viewId});f=Ot(f,O);break}}let v;a&&s&&(v={resizeWidth:a,resizeHeight:s}),await new Promise(l=>{setTimeout(l,500)}),await this.getSnapshotRender({scenePath:e,curCameraOpt:o,options:v}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(t){var s,o;const{scenePath:e,curCameraOpt:n,options:i}=t;((s=this.snapshotFullLayer)==null?void 0:s.parent).render();const a=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:Mt.None},!0,i);a&&(this._post({sp:[{type:ct.Snapshot,scenePath:e,imageBitmap:a,viewId:this.viewId}]},[a]),a.close(),(o=this.snapshotFullLayer)==null||o.removeAllChildren(),this.setCameraOpt(n,this.fullLayer))}async getBoundingRect(t){const{scenePath:e,scenes:n,cameraOpt:i}=t;if(e&&n&&i&&this.snapshotFullLayer){const a=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=this.snapshotFullLayer;let s;for(const[o,f]of Object.entries(n))if(f!=null&&f.type)switch(f==null?void 0:f.type){case ct.UpdateNode:case ct.FullWork:{const v=await this.localWork.runFullWork({...f,workId:o,msgType:ct.FullWork,dataType:Tt.Service,viewId:this.viewId});s=Ot(s,v);break}}s&&this.post({sp:[{type:ct.BoundingBox,scenePath:e,rect:s}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,this.snapshotFullLayer.removeAllChildren(),this.setCameraOpt(a,this.fullLayer)}}}const lg=self;new sg(lg,qn.Sub)})();