@component-hook/pdf-canvas 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  (function(rt,Y){typeof exports=="object"&&typeof module<"u"?Y(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Y):(rt=typeof globalThis<"u"?globalThis:rt||self,Y(rt["pdf-canvas"]={},rt.Vue))})(this,function(rt,Y){"use strict";var jS=Object.defineProperty;var nb=rt=>{throw TypeError(rt)};var NS=(rt,Y,Ct)=>Y in rt?jS(rt,Y,{enumerable:!0,configurable:!0,writable:!0,value:Ct}):rt[Y]=Ct;var q=(rt,Y,Ct)=>NS(rt,typeof Y!="symbol"?Y+"":Y,Ct),sf=(rt,Y,Ct)=>Y.has(rt)||nb("Cannot "+Ct);var c=(rt,Y,Ct)=>(sf(rt,Y,"read from private field"),Ct?Ct.call(rt):Y.get(rt)),w=(rt,Y,Ct)=>Y.has(rt)?nb("Cannot add the same private member more than once"):Y instanceof WeakSet?Y.add(rt):Y.set(rt,Ct),b=(rt,Y,Ct,A)=>(sf(rt,Y,"write to private field"),A?A.call(rt,Ct):Y.set(rt,Ct),Ct),v=(rt,Y,Ct)=>(sf(rt,Y,"access private method"),Ct);var Fe=(rt,Y,Ct,A)=>({set _(Zl){b(rt,Y,Zl,Ct)},get _(){return c(rt,Y,A)}});var Di,Bd,nf,Sh,yn,mr,ks,br,Ch,Ah,wd,rb,Me,ob,ab,Hd,hb,rf,Th,vr,yr,_n,lb,cb,db,xd,Wo,Eh,me,zo,Wd,Zt,wn,kh,te,Sd,ub,Xo,qe,Yt,ne,Vo,Fi,Go,Ms,xn,Yo,_r,Ks,Os,wr,Mh,Oh,Uo,Dh,Qs,Sn,qo,Cn,Js,Ad,An,Ph,Tn,xr,Fh,Rh,ee,ft,Ri,Sr,Lh,Ih,En,Zs,Li,jh,cs,I,zd,of,gb,fb,Xd,pb,mb,bb,af,vb,hf,lf,yb,Re,qn,_b,wb,cf,xb,Bl,df,se,ti,Ds,Ko,ei,$e,Qo,si,Be,Ii,Cr,ii,kn,Ps,Hl,Vd,Ar,Fs,Et,Jo,Tr,re,Er,Mn,Nh,kr,On,Bh,Mr,ji,ni,Zo,ta,ds,Hh,Td,et,uf,Wh,gf,ff,Sb,Cb,pf,mf,bf,Ab,vf,Tb,Eb,kb,yf,Wl,Or,Dr,ie,Ed,Mb,zh,ea,Xh,Pr,Fr,ri,Ni,be,kd,Rr,j,_e,Ha,Wa,Gd,za,Ob,_f,Xa,zl,Xl,wf,Vl,Dn,xf,Sf,Vh,Gh,sa,us,Db,Pb,Fb,Yd,Lr,Yh,Uh,qh,$h,ia,Pn,pt,na,ra,Kh,Cf,ib,Fn,He,Qh,Jh,Ir,Bi,Zh,tl,jr,oa,aa,Rn,ha,el,la,Nr,sl,il,Br,Hr,nl,Ln,ca,Hi,Rb,Lb,Af,Ke,Ud,Tf,Ib,jb,Od,In,Wi,gs,Va,qd,zi,Pd,Fd,Wr,zr,da,$d,ua,Kd,Xi,oi,ga,fa,ai,Xr,Gl,Rs,rl,Ef,jn,Nn,Vr,Yr,pa,ma,ol,kf,Qe,vo,Nb,Bb,ba,Rd,Ld,va,Ur,Dt,Vi,ya,al,hl,_a,Gi,Ls,Yi,ll,Ui,cl,qr,$r,mt,Qd,Mf,Hb,Wb,zb,Xb,Jd,Zd,Of,dl,ul,gl,fl,pl,ml,bl,Df,vl,Kr,Qr,yl,Jr,Vb,Pf,Is,Je,_l,Zr,Ze,Ht,Gb,Yb,Ub,tu,qi,eu,su,qb,Ff,$b,ts,js,wa,xa,hi,it,to,eo,wl,xl,Sa,Ca,Bn,Sl,Id,jd,qt,Yl,Kb,Qb,Jb,Zb,tv,ev,Aa,so,Ki,Cl,es,Al,It,We,Ul,ql,sv,Tl,Hn,Ns,De,iv,iu,nv,rv,Rf,El,Ta,Bs,io,Ea,$t,kl,ka,Ml,Ol,Wn,Hs,Ma,Dl,bt,Lf,If,jf,yo,ov,$n,Oa,Pl,Qi,no,Da,fs,Fl,Rl,ro,Ws,ve,Xe,Pa,Ji,Kt,Fa,ps,Ll,J,Nf,nu,av,hv,lv,Bf,_o,ms,Ga,cv,ru,$l,dv,uv,gv,fv,pv,oo,ao,li,Zi,bs,ho,lo,co,tn,Ra,uo,go,zn,L,mv,bv,vv,yv,Hf,_v,Wf,wv,xv,Sv,Cv,Av,wo,zf,Xf,Vf,ou,au,Ya,Gf,hu,en,Tv,Yf,Ev,kv,Uf,lu,Kl,Mt,oe,Xn,sn,Vn,La,ci,nn,di,ss,Ia,nt,Ql,Jl,cu,qf,Mv,du,$f,uu,Ov,Dv,fo,ja,ui,Gn,rn,is,Yn,Na,Ba,ye,on,G,Un,ae,Pv,Kf,Qf,Jf,gu,gi,jl,Wt,an,Nl,Zf,po,tp,Fv;var Ct=typeof document<"u"?document.currentScript:null;function A(a,t,e){return(t=function(s){var i=function(n,r){if(typeof n!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var h=o.call(n,r||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(n)}(s,"string");return typeof i=="symbol"?i:i+""}(t))in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function Zl(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(a);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),e.push.apply(e,s)}return e}function T(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Zl(Object(e),!0).forEach(function(s){A(a,s,e[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):Zl(Object(e)).forEach(function(s){Object.defineProperty(a,s,Object.getOwnPropertyDescriptor(e,s))})}return a}function wt(a,t){if(a==null)return{};var e,s,i=function(r,o){if(r==null)return{};var h={};for(var l in r)if({}.hasOwnProperty.call(r,l)){if(o.indexOf(l)>=0)continue;h[l]=r[l]}return h}(a,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(a);for(s=0;s<n.length;s++)e=n[s],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(a,e)&&(i[e]=a[e])}return i}function hn(a,t){return t||(t=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(t)}}))}class ep{constructor(){A(this,"browserShadowBlurConstant",1),A(this,"DPI",96),A(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),A(this,"perfLimitSizeTotal",2097152),A(this,"maxCacheSideLimit",4096),A(this,"minCacheSideLimit",256),A(this,"disableStyleCopyPaste",!1),A(this,"enableGLFiltering",!0),A(this,"textureSize",4096),A(this,"forceGLPutImageData",!1),A(this,"cachesBoundsOfCurve",!1),A(this,"fontPaths",{}),A(this,"NUM_FRACTION_DIGITS",4)}}const at=new class extends ep{constructor(a){super(),this.configure(a)}configure(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,a)}addFonts(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=T(T({},this.fontPaths),a)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(a=>{delete this.fontPaths[a]})}clearFonts(){this.fontPaths={}}restoreDefaults(a){const t=new ep,e=(a==null?void 0:a.reduce((s,i)=>(s[i]=t[i],s),{}))||t;this.configure(e)}},mi=function(a){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];return console[a]("fabric",...e)};class Xs extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class fu extends Xs{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Rv{}class Lv extends Rv{testPrecision(t,e){const s="precision ".concat(e,` float;
2
- void main(){}`),i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,s),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(s=>this.testPrecision(e,s)),e.getExtension("WEBGL_lose_context").loseContext(),mi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Iv={};let sp;const Vs=()=>sp||(sp={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Lv,dispose(){},copyPasteData:Iv}),xo=()=>Vs().document,tc=()=>Vs().window,ip=()=>{var a;return Math.max((a=at.devicePixelRatio)!==null&&a!==void 0?a:tc().devicePixelRatio,1)},Ua=new class{constructor(){A(this,"charWidthsCache",{}),A(this,"boundsOfCurveCache",{})}getFontCache(a){let{fontFamily:t,fontStyle:e,fontWeight:s}=a;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const i=this.charWidthsCache[t],n="".concat(e.toLowerCase(),"_").concat((s+"").toLowerCase());return i[n]||(i[n]={}),i[n]}clearFontCache(a){(a=(a||"").toLowerCase())?this.charWidthsCache[a]&&delete this.charWidthsCache[a]:this.charWidthsCache={}}limitDimsByArea(a){const{perfLimitSizeTotal:t}=at,e=Math.sqrt(t*a);return[Math.floor(e),Math.floor(t/e)]}},pu="6.5.0";function Kn(){}const ln=Math.PI/2,bi=2*Math.PI,mu=Math.PI/180,we=Object.freeze([1,0,0,1,0,0]),bu=16,cn=.4477152502,Q="center",lt="left",Le="top",vu="bottom",Ft="right",xe="none",yu=/\r?\n/,np="moving",ec="scaling",rp="rotating",_u="rotate",op="skewing",qa="resizing",jv="modifyPoly",Nv="modifyPath",sc="changed",ic="scale",Se="scaleX",Ve="scaleY",So="skewX",Co="skewY",jt="fill",Ce="stroke",nc="modified",Ao="json",wu="svg",N=new class{constructor(){this[Ao]=new Map,this[wu]=new Map}has(a){return this[Ao].has(a)}getClass(a){const t=this[Ao].get(a);if(!t)throw new Xs("No class registered for ".concat(a));return t}setClass(a,t){t?this[Ao].set(t,a):(this[Ao].set(a.type,a),this[Ao].set(a.type.toLowerCase(),a))}getSVGClass(a){return this[wu].get(a)}setSVGClass(a,t){this[wu].set(t??a.type.toLowerCase(),a)}},rc=new class extends Array{remove(a){const t=this.indexOf(a);t>-1&&this.splice(t,1)}cancelAll(){const a=this.splice(0);return a.forEach(t=>t.abort()),a}cancelByCanvas(a){if(!a)return[];const t=this.filter(e=>{var s;return e.target===a||typeof e.target=="object"&&((s=e.target)===null||s===void 0?void 0:s.canvas)===a});return t.forEach(e=>e.abort()),t}cancelByTarget(a){if(!a)return[];const t=this.filter(e=>e.target===a);return t.forEach(e=>e.abort()),t}};class Bv{constructor(){A(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(s=>{let[i,n]=s;this.on(i,n)}),()=>this.off(t);if(e){const s=t;return this.__eventListeners[s]||(this.__eventListeners[s]=[]),this.__eventListeners[s].push(e),()=>this.off(s,e)}return()=>!1}once(t,e){if(typeof t=="object"){const s=[];return Object.entries(t).forEach(i=>{let[n,r]=i;s.push(this.once(n,r))}),()=>s.forEach(i=>i())}if(e){const s=this.on(t,function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];e.call(this,...n),s()});return s}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const s=this.__eventListeners[t],i=s.indexOf(e);i>-1&&s.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const s in this.__eventListeners)this._removeEventListener(s);else typeof t=="object"?Object.entries(t).forEach(s=>{let[i,n]=s;this._removeEventListener(i,n)}):this._removeEventListener(t,e)}fire(t,e){var s;if(!this.__eventListeners)return;const i=(s=this.__eventListeners[t])===null||s===void 0?void 0:s.concat();if(i)for(let n=0;n<i.length;n++)i[n].call(this,e||{})}}const Qn=(a,t)=>{const e=a.indexOf(t);return e!==-1&&a.splice(e,1),a},vs=a=>{if(a===0)return 1;switch(Math.abs(a)/ln){case 1:case 3:return 0;case 2:return-1}return Math.cos(a)},ys=a=>{if(a===0)return 0;const t=a/ln,e=Math.sign(a);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(a)};class D{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new D(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new D(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new D(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new D(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new D(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new D(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new D(this.x/t.x,this.y/t.y)}scalarDivide(t){return new D(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new D(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}midPointFrom(t){return this.lerp(t)}min(t){return new D(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new D(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,s=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=s}clone(){return new D(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xu;const s=ys(t),i=vs(t),n=this.subtract(e);return new D(n.x*i-n.y*s,n.x*s+n.y*i).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new D(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const xu=new D(0,0),oc=a=>!!a&&Array.isArray(a._objects);function ap(a){class t extends a{constructor(){super(...arguments),A(this,"_objects",[])}_onObjectAdded(s){}_onObjectRemoved(s){}_onStackOrderChanged(s){}add(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];const r=this._objects.push(...i);return i.forEach(o=>this._onObjectAdded(o)),r}insertAt(s){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return this._objects.splice(s,0,...n),n.forEach(o=>this._onObjectAdded(o)),this._objects.length}remove(){const s=this._objects,i=[];for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return r.forEach(h=>{const l=s.indexOf(h);l!==-1&&(s.splice(l,1),i.push(h),this._onObjectRemoved(h))}),i}forEachObject(s){this.getObjects().forEach((i,n,r)=>s(i,n,r))}getObjects(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return i.length===0?[...this._objects]:this._objects.filter(r=>r.isType(...i))}item(s){return this._objects[s]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(s,i){return!!this._objects.includes(s)||!!i&&this._objects.some(n=>n instanceof t&&n.contains(s,!0))}complexity(){return this._objects.reduce((s,i)=>s+=i.complexity?i.complexity():0,0)}sendObjectToBack(s){return!(!s||s===this._objects[0])&&(Qn(this._objects,s),this._objects.unshift(s),this._onStackOrderChanged(s),!0)}bringObjectToFront(s){return!(!s||s===this._objects[this._objects.length-1])&&(Qn(this._objects,s),this._objects.push(s),this._onStackOrderChanged(s),!0)}sendObjectBackwards(s,i){if(!s)return!1;const n=this._objects.indexOf(s);if(n!==0){const r=this.findNewLowerIndex(s,n,i);return Qn(this._objects,s),this._objects.splice(r,0,s),this._onStackOrderChanged(s),!0}return!1}bringObjectForward(s,i){if(!s)return!1;const n=this._objects.indexOf(s);if(n!==this._objects.length-1){const r=this.findNewUpperIndex(s,n,i);return Qn(this._objects,s),this._objects.splice(r,0,s),this._onStackOrderChanged(s),!0}return!1}moveObjectTo(s,i){return s!==this._objects[i]&&(Qn(this._objects,s),this._objects.splice(i,0,s),this._onStackOrderChanged(s),!0)}findNewLowerIndex(s,i,n){let r;if(n){r=i;for(let o=i-1;o>=0;--o)if(s.isOverlapping(this._objects[o])){r=o;break}}else r=i-1;return r}findNewUpperIndex(s,i,n){let r;if(n){r=i;for(let o=i+1;o<this._objects.length;++o)if(s.isOverlapping(this._objects[o])){r=o;break}}else r=i+1;return r}collectObjects(s){let{left:i,top:n,width:r,height:o}=s,{includeIntersecting:h=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const l=[],d=new D(i,n),u=d.add(new D(r,o));for(let g=this._objects.length-1;g>=0;g--){const f=this._objects[g];f.selectable&&f.visible&&(h&&f.intersectsWithRect(d,u)||f.isContainedWithinRect(d,u)||h&&f.containsPoint(d)||h&&f.containsPoint(u))&&l.push(f)}return l}}return t}class hp extends Bv{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function $a(a){return tc().requestAnimationFrame(a)}function lp(a){return tc().cancelAnimationFrame(a)}let Hv=0;const dn=()=>Hv++,ns=()=>{const a=xo().createElement("canvas");if(!a||a.getContext===void 0)throw new Xs("Failed to create `canvas` element");return a},cp=()=>xo().createElement("img"),_s=a=>{const t=ns();return t.width=a.width,t.height=a.height,t},Su=(a,t,e)=>a.toDataURL("image/".concat(t),e),Ot=a=>a*mu,un=a=>a/mu,dp=a=>a.every((t,e)=>t===we[e]),ce=(a,t,e)=>new D(a).transform(t,e),Ie=a=>{const t=1/(a[0]*a[3]-a[1]*a[2]),e=[t*a[3],-t*a[1],-t*a[2],t*a[0],0,0],{x:s,y:i}=new D(a[4],a[5]).transform(e,!0);return e[4]=-s,e[5]=-i,e},Rt=(a,t,e)=>[a[0]*t[0]+a[2]*t[1],a[1]*t[0]+a[3]*t[1],a[0]*t[2]+a[2]*t[3],a[1]*t[2]+a[3]*t[3],e?0:a[0]*t[4]+a[2]*t[5]+a[4],e?0:a[1]*t[4]+a[3]*t[5]+a[5]],ac=(a,t)=>a.reduceRight((e,s)=>s&&e?Rt(s,e,t):s||e,void 0)||we.concat(),up=a=>{let[t,e]=a;return Math.atan2(e,t)},Jn=a=>{const t=up(a),e=Math.pow(a[0],2)+Math.pow(a[1],2),s=Math.sqrt(e),i=(a[0]*a[3]-a[2]*a[1])/s,n=Math.atan2(a[0]*a[2]+a[1]*a[3],e);return{angle:un(t),scaleX:s,scaleY:i,skewX:un(n),skewY:0,translateX:a[4]||0,translateY:a[5]||0}},To=function(a){return[1,0,0,1,a,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Eo(){let{angle:a=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=Ot(a),i=vs(s),n=ys(s);return[i,n,-n,i,t?t-(i*t-n*e):0,e?e-(n*t+i*e):0]}const hc=function(a){return[a,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,0,0]},gp=a=>Math.tan(Ot(a)),Cu=a=>[1,0,gp(a),1,0,0],Au=a=>[1,gp(a),0,1,0,0],Ka=a=>{let{scaleX:t=1,scaleY:e=1,flipX:s=!1,flipY:i=!1,skewX:n=0,skewY:r=0}=a,o=hc(s?-t:t,i?-e:e);return n&&(o=Rt(o,Cu(n),!0)),r&&(o=Rt(o,Au(r),!0)),o},fp=a=>{const{translateX:t=0,translateY:e=0,angle:s=0}=a;let i=To(t,e);s&&(i=Rt(i,Eo({angle:s})));const n=Ka(a);return dp(n)||(i=Rt(i,n)),i},Qa=function(a){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(s,i){if(t&&t.aborted)return i(new fu("loadImage"));const n=cp();let r;t&&(r=function(h){n.src="",i(h)},t.addEventListener("abort",r,{once:!0}));const o=function(){n.onload=n.onerror=null,r&&(t==null||t.removeEventListener("abort",r)),s(n)};a?(n.onload=o,n.onerror=function(){r&&(t==null||t.removeEventListener("abort",r)),i(new Xs("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=a):o()})},ko=function(a){let{signal:t,reviver:e=Kn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((s,i)=>{const n=[];t&&t.addEventListener("abort",i,{once:!0}),Promise.all(a.map(r=>N.getClass(r.type).fromObject(r,{signal:t}).then(o=>(e(r,o),n.push(o),o)))).then(s).catch(r=>{n.forEach(o=>{o.dispose&&o.dispose()}),i(r)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},Ja=function(a){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,s)=>{const i=[];t&&t.addEventListener("abort",s,{once:!0});const n=Object.values(a).map(o=>o&&o.type&&N.has(o.type)?ko([o],{signal:t}).then(h=>{let[l]=h;return i.push(l),l}):o),r=Object.keys(a);Promise.all(n).then(o=>o.reduce((h,l,d)=>(h[r[d]]=l,h),{})).then(e).catch(o=>{i.forEach(h=>{h.dispose&&h.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},Zn=function(a){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in a&&(t[e]=a[e]),t),{})},Tu=(a,t)=>Object.keys(a).reduce((e,s)=>(t(a[s],s,a)&&(e[s]=a[s]),e),{}),pp={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},Eu=(a,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?a+6*(t-a)*e:e<.5?t:e<2/3?a+(t-a)*(2/3-e)*6:a),mp=(a,t,e,s)=>{a/=255,t/=255,e/=255;const i=Math.max(a,t,e),n=Math.min(a,t,e);let r,o;const h=(i+n)/2;if(i===n)r=o=0;else{const l=i-n;switch(o=h>.5?l/(2-i-n):l/(i+n),i){case a:r=(t-e)/l+(t<e?6:0);break;case t:r=(e-a)/l+2;break;case e:r=(a-t)/l+4}r/=6}return[Math.round(360*r),Math.round(100*o),Math.round(100*h),s]},bp=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(a)/(a.endsWith("%")?100:1)},lc=a=>Math.min(Math.round(a),255).toString(16).toUpperCase().padStart(2,"0"),vp=a=>{let[t,e,s,i=1]=a;const n=Math.round(.3*t+.59*e+.11*s);return[n,n,n,i]};class ut{constructor(t){if(A(this,"isUnrecognised",!1),t)if(t instanceof ut)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,s,i,n=1]=t;this.setSource([e,s,i,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return t in pp&&(t=pp[t]),t==="transparent"?[255,255,255,0]:ut.sourceFromHex(t)||ut.sourceFromRgb(t)||ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=mp(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=mp(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(s,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,s,i]=this.getSource();return"".concat(lc(t)).concat(lc(e)).concat(lc(s)).concat(lc(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(vp(this.getSource())),this}toBlackWhite(t){const[e,,,s]=vp(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof ut||(t=new ut(t));const e=this.getSource(),s=t.getSource(),[i,n,r]=e.map((o,h)=>Math.round(.5*o+.5*s[h]));return this.setSource([i,n,r,e[3]]),this}static fromRgb(t){return ut.fromRgba(t)}static fromRgba(t){return new ut(ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[s,i,n]=e.slice(1,4).map(r=>{const o=parseFloat(r);return r.endsWith("%")?Math.round(2.55*o):o});return[s,i,n,bp(e[4])]}}static fromHsl(t){return ut.fromHsla(t)}static fromHsla(t){return new ut(ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let r,o,h;if(i===0)r=o=h=n;else{const l=n<=.5?n*(i+1):n+i-n*i,d=2*n-l;r=Eu(d,l,s+1/3),o=Eu(d,l,s),h=Eu(d,l,s-1/3)}return[Math.round(255*r),Math.round(255*o),Math.round(255*h),bp(e[4])]}static fromHex(t){return new ut(ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map(h=>h+h):e.match(/.{2}/g);const[i,n,r,o=255]=s.map(h=>parseInt(h,16));return[i,n,r,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),s=parseFloat(e);return e.includes("rad")?un(s):e.includes("turn")?360*s:s}}const xt=(a,t)=>parseFloat(Number(a).toFixed(t)),Ae=function(a){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:bu;const e=/\D{0,2}$/.exec(a),s=parseFloat(a),i=at.DPI;switch(e==null?void 0:e[0]){case"mm":return s*i/25.4;case"cm":return s*i/2.54;case"in":return s*i;case"pt":return s*i/72;case"pc":return s*i/72*12;case"em":return s*t;default:return s}},ku=a=>{const[t,e]=a.trim().split(" "),[s,i]=(n=t)&&n!==xe?[n.slice(1,4),n.slice(5,8)]:n===xe?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:s,alignY:i}},Za=a=>"matrix("+a.map(t=>xt(t,at.NUM_FRACTION_DIGITS)).join(" ")+")",th=function(a,t){let e,s,i=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new ut(t),r=n.getAlpha();e=n.toRgb(),r!==1&&(s=r.toString())}else e="none";return i?"".concat(a,": ").concat(e,"; ").concat(s?"".concat(a,"-opacity: ").concat(s,"; "):""):"".concat(a,'="').concat(e,'" ').concat(s?"".concat(a,'-opacity="').concat(s,'" '):"")},rs=a=>!!a&&a.toLive!==void 0,yp=a=>!!a&&typeof a.toObject=="function",_p=a=>!!a&&a.offsetX!==void 0&&"source"in a,wp=a=>!!a&&typeof a._renderText=="function",tr=a=>!!a&&"multiSelectionStacking"in a;function xp(a){const t=a&&ws(a);let e=0,s=0;if(!a||!t)return{left:e,top:s};let i=a;const n=t.documentElement,r=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(e=r.scrollLeft||n.scrollLeft||0,s=r.scrollTop||n.scrollTop||0):(e+=i.scrollLeft||0,s+=i.scrollTop||0),i.nodeType!==1||i.style.position!=="fixed"););return{left:e,top:s}}const ws=a=>a.ownerDocument||null,Sp=a=>{var t;return((t=a.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Cp=function(a,t,e){let{width:s,height:i}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;a.width=s,a.height=i,n>1&&(a.setAttribute("width",(s*n).toString()),a.setAttribute("height",(i*n).toString()),t.scale(n,n))},Mu=(a,t)=>{let{width:e,height:s}=t;e&&(a.style.width=typeof e=="number"?"".concat(e,"px"):e),s&&(a.style.height=typeof s=="number"?"".concat(s,"px"):s)};function Ap(a){return a.onselectstart!==void 0&&(a.onselectstart=()=>!1),a.style.userSelect=xe,a}class Tp{constructor(t){A(this,"_originalCanvasStyle",void 0),A(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&s.getContext!==void 0?t:t&&xo().getElementById(t)||ns();var s;if(e.hasAttribute("data-fabric"))throw new Xs("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:s}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(s)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:s,ctx:i}=this.lower;Cp(s,i,t,e)}setCSSDimensions(t){Mu(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&ws(t),i={left:0,top:0};if(!s)return i;const n=((e=Sp(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(n.borderLeftWidth,10)||0,i.top+=parseInt(n.borderTopWidth,10)||0,i.left+=parseInt(n.paddingLeft,10)||0,i.top+=parseInt(n.paddingTop,10)||0;let r={left:0,top:0};const o=s.documentElement;t.getBoundingClientRect!==void 0&&(r=t.getBoundingClientRect());const h=xp(t);return{left:r.left+h.left-(o.clientLeft||0)+i.left,top:r.top+h.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){Vs().dispose(this.lower.el),delete this.lower}}const Wv={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...we]};class eh extends ap(hp){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return eh.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Tp(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const n=super.insertAt(t,...s);return s.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(mi("warn",`Canvas is trying to add an object that belongs to a different canvas.
2
+ void main(){}`),i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,s),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(s=>this.testPrecision(e,s)),e.getExtension("WEBGL_lose_context").loseContext(),mi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Iv={};let sp;const Vs=()=>sp||(sp={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Lv,dispose(){},copyPasteData:Iv}),xo=()=>Vs().document,tc=()=>Vs().window,ip=()=>{var a;return Math.max((a=at.devicePixelRatio)!==null&&a!==void 0?a:tc().devicePixelRatio,1)},Ua=new class{constructor(){A(this,"charWidthsCache",{}),A(this,"boundsOfCurveCache",{})}getFontCache(a){let{fontFamily:t,fontStyle:e,fontWeight:s}=a;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const i=this.charWidthsCache[t],n="".concat(e.toLowerCase(),"_").concat((s+"").toLowerCase());return i[n]||(i[n]={}),i[n]}clearFontCache(a){(a=(a||"").toLowerCase())?this.charWidthsCache[a]&&delete this.charWidthsCache[a]:this.charWidthsCache={}}limitDimsByArea(a){const{perfLimitSizeTotal:t}=at,e=Math.sqrt(t*a);return[Math.floor(e),Math.floor(t/e)]}},pu="6.5.1";function Kn(){}const ln=Math.PI/2,bi=2*Math.PI,mu=Math.PI/180,we=Object.freeze([1,0,0,1,0,0]),bu=16,cn=.4477152502,Q="center",lt="left",Le="top",vu="bottom",Ft="right",xe="none",yu=/\r?\n/,np="moving",ec="scaling",rp="rotating",_u="rotate",op="skewing",qa="resizing",jv="modifyPoly",Nv="modifyPath",sc="changed",ic="scale",Se="scaleX",Ve="scaleY",So="skewX",Co="skewY",jt="fill",Ce="stroke",nc="modified",Ao="json",wu="svg",N=new class{constructor(){this[Ao]=new Map,this[wu]=new Map}has(a){return this[Ao].has(a)}getClass(a){const t=this[Ao].get(a);if(!t)throw new Xs("No class registered for ".concat(a));return t}setClass(a,t){t?this[Ao].set(t,a):(this[Ao].set(a.type,a),this[Ao].set(a.type.toLowerCase(),a))}getSVGClass(a){return this[wu].get(a)}setSVGClass(a,t){this[wu].set(t??a.type.toLowerCase(),a)}},rc=new class extends Array{remove(a){const t=this.indexOf(a);t>-1&&this.splice(t,1)}cancelAll(){const a=this.splice(0);return a.forEach(t=>t.abort()),a}cancelByCanvas(a){if(!a)return[];const t=this.filter(e=>{var s;return e.target===a||typeof e.target=="object"&&((s=e.target)===null||s===void 0?void 0:s.canvas)===a});return t.forEach(e=>e.abort()),t}cancelByTarget(a){if(!a)return[];const t=this.filter(e=>e.target===a);return t.forEach(e=>e.abort()),t}};class Bv{constructor(){A(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(s=>{let[i,n]=s;this.on(i,n)}),()=>this.off(t);if(e){const s=t;return this.__eventListeners[s]||(this.__eventListeners[s]=[]),this.__eventListeners[s].push(e),()=>this.off(s,e)}return()=>!1}once(t,e){if(typeof t=="object"){const s=[];return Object.entries(t).forEach(i=>{let[n,r]=i;s.push(this.once(n,r))}),()=>s.forEach(i=>i())}if(e){const s=this.on(t,function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];e.call(this,...n),s()});return s}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const s=this.__eventListeners[t],i=s.indexOf(e);i>-1&&s.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const s in this.__eventListeners)this._removeEventListener(s);else typeof t=="object"?Object.entries(t).forEach(s=>{let[i,n]=s;this._removeEventListener(i,n)}):this._removeEventListener(t,e)}fire(t,e){var s;if(!this.__eventListeners)return;const i=(s=this.__eventListeners[t])===null||s===void 0?void 0:s.concat();if(i)for(let n=0;n<i.length;n++)i[n].call(this,e||{})}}const Qn=(a,t)=>{const e=a.indexOf(t);return e!==-1&&a.splice(e,1),a},vs=a=>{if(a===0)return 1;switch(Math.abs(a)/ln){case 1:case 3:return 0;case 2:return-1}return Math.cos(a)},ys=a=>{if(a===0)return 0;const t=a/ln,e=Math.sign(a);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(a)};class D{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new D(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new D(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new D(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new D(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new D(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new D(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new D(this.x/t.x,this.y/t.y)}scalarDivide(t){return new D(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new D(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}midPointFrom(t){return this.lerp(t)}min(t){return new D(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new D(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,s=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=s}clone(){return new D(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xu;const s=ys(t),i=vs(t),n=this.subtract(e);return new D(n.x*i-n.y*s,n.x*s+n.y*i).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new D(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const xu=new D(0,0),oc=a=>!!a&&Array.isArray(a._objects);function ap(a){class t extends a{constructor(){super(...arguments),A(this,"_objects",[])}_onObjectAdded(s){}_onObjectRemoved(s){}_onStackOrderChanged(s){}add(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];const r=this._objects.push(...i);return i.forEach(o=>this._onObjectAdded(o)),r}insertAt(s){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return this._objects.splice(s,0,...n),n.forEach(o=>this._onObjectAdded(o)),this._objects.length}remove(){const s=this._objects,i=[];for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return r.forEach(h=>{const l=s.indexOf(h);l!==-1&&(s.splice(l,1),i.push(h),this._onObjectRemoved(h))}),i}forEachObject(s){this.getObjects().forEach((i,n,r)=>s(i,n,r))}getObjects(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return i.length===0?[...this._objects]:this._objects.filter(r=>r.isType(...i))}item(s){return this._objects[s]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(s,i){return!!this._objects.includes(s)||!!i&&this._objects.some(n=>n instanceof t&&n.contains(s,!0))}complexity(){return this._objects.reduce((s,i)=>s+=i.complexity?i.complexity():0,0)}sendObjectToBack(s){return!(!s||s===this._objects[0])&&(Qn(this._objects,s),this._objects.unshift(s),this._onStackOrderChanged(s),!0)}bringObjectToFront(s){return!(!s||s===this._objects[this._objects.length-1])&&(Qn(this._objects,s),this._objects.push(s),this._onStackOrderChanged(s),!0)}sendObjectBackwards(s,i){if(!s)return!1;const n=this._objects.indexOf(s);if(n!==0){const r=this.findNewLowerIndex(s,n,i);return Qn(this._objects,s),this._objects.splice(r,0,s),this._onStackOrderChanged(s),!0}return!1}bringObjectForward(s,i){if(!s)return!1;const n=this._objects.indexOf(s);if(n!==this._objects.length-1){const r=this.findNewUpperIndex(s,n,i);return Qn(this._objects,s),this._objects.splice(r,0,s),this._onStackOrderChanged(s),!0}return!1}moveObjectTo(s,i){return s!==this._objects[i]&&(Qn(this._objects,s),this._objects.splice(i,0,s),this._onStackOrderChanged(s),!0)}findNewLowerIndex(s,i,n){let r;if(n){r=i;for(let o=i-1;o>=0;--o)if(s.isOverlapping(this._objects[o])){r=o;break}}else r=i-1;return r}findNewUpperIndex(s,i,n){let r;if(n){r=i;for(let o=i+1;o<this._objects.length;++o)if(s.isOverlapping(this._objects[o])){r=o;break}}else r=i+1;return r}collectObjects(s){let{left:i,top:n,width:r,height:o}=s,{includeIntersecting:h=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const l=[],d=new D(i,n),u=d.add(new D(r,o));for(let g=this._objects.length-1;g>=0;g--){const f=this._objects[g];f.selectable&&f.visible&&(h&&f.intersectsWithRect(d,u)||f.isContainedWithinRect(d,u)||h&&f.containsPoint(d)||h&&f.containsPoint(u))&&l.push(f)}return l}}return t}class hp extends Bv{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function $a(a){return tc().requestAnimationFrame(a)}function lp(a){return tc().cancelAnimationFrame(a)}let Hv=0;const dn=()=>Hv++,ns=()=>{const a=xo().createElement("canvas");if(!a||a.getContext===void 0)throw new Xs("Failed to create `canvas` element");return a},cp=()=>xo().createElement("img"),_s=a=>{const t=ns();return t.width=a.width,t.height=a.height,t},Su=(a,t,e)=>a.toDataURL("image/".concat(t),e),Ot=a=>a*mu,un=a=>a/mu,dp=a=>a.every((t,e)=>t===we[e]),ce=(a,t,e)=>new D(a).transform(t,e),Ie=a=>{const t=1/(a[0]*a[3]-a[1]*a[2]),e=[t*a[3],-t*a[1],-t*a[2],t*a[0],0,0],{x:s,y:i}=new D(a[4],a[5]).transform(e,!0);return e[4]=-s,e[5]=-i,e},Rt=(a,t,e)=>[a[0]*t[0]+a[2]*t[1],a[1]*t[0]+a[3]*t[1],a[0]*t[2]+a[2]*t[3],a[1]*t[2]+a[3]*t[3],e?0:a[0]*t[4]+a[2]*t[5]+a[4],e?0:a[1]*t[4]+a[3]*t[5]+a[5]],ac=(a,t)=>a.reduceRight((e,s)=>s&&e?Rt(s,e,t):s||e,void 0)||we.concat(),up=a=>{let[t,e]=a;return Math.atan2(e,t)},Jn=a=>{const t=up(a),e=Math.pow(a[0],2)+Math.pow(a[1],2),s=Math.sqrt(e),i=(a[0]*a[3]-a[2]*a[1])/s,n=Math.atan2(a[0]*a[2]+a[1]*a[3],e);return{angle:un(t),scaleX:s,scaleY:i,skewX:un(n),skewY:0,translateX:a[4]||0,translateY:a[5]||0}},To=function(a){return[1,0,0,1,a,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Eo(){let{angle:a=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=Ot(a),i=vs(s),n=ys(s);return[i,n,-n,i,t?t-(i*t-n*e):0,e?e-(n*t+i*e):0]}const hc=function(a){return[a,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,0,0]},gp=a=>Math.tan(Ot(a)),Cu=a=>[1,0,gp(a),1,0,0],Au=a=>[1,gp(a),0,1,0,0],Ka=a=>{let{scaleX:t=1,scaleY:e=1,flipX:s=!1,flipY:i=!1,skewX:n=0,skewY:r=0}=a,o=hc(s?-t:t,i?-e:e);return n&&(o=Rt(o,Cu(n),!0)),r&&(o=Rt(o,Au(r),!0)),o},fp=a=>{const{translateX:t=0,translateY:e=0,angle:s=0}=a;let i=To(t,e);s&&(i=Rt(i,Eo({angle:s})));const n=Ka(a);return dp(n)||(i=Rt(i,n)),i},Qa=function(a){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(s,i){if(t&&t.aborted)return i(new fu("loadImage"));const n=cp();let r;t&&(r=function(h){n.src="",i(h)},t.addEventListener("abort",r,{once:!0}));const o=function(){n.onload=n.onerror=null,r&&(t==null||t.removeEventListener("abort",r)),s(n)};a?(n.onload=o,n.onerror=function(){r&&(t==null||t.removeEventListener("abort",r)),i(new Xs("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=a):o()})},ko=function(a){let{signal:t,reviver:e=Kn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((s,i)=>{const n=[];t&&t.addEventListener("abort",i,{once:!0}),Promise.all(a.map(r=>N.getClass(r.type).fromObject(r,{signal:t}).then(o=>(e(r,o),n.push(o),o)))).then(s).catch(r=>{n.forEach(o=>{o.dispose&&o.dispose()}),i(r)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},Ja=function(a){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,s)=>{const i=[];t&&t.addEventListener("abort",s,{once:!0});const n=Object.values(a).map(o=>o&&o.type&&N.has(o.type)?ko([o],{signal:t}).then(h=>{let[l]=h;return i.push(l),l}):o),r=Object.keys(a);Promise.all(n).then(o=>o.reduce((h,l,d)=>(h[r[d]]=l,h),{})).then(e).catch(o=>{i.forEach(h=>{h.dispose&&h.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},Zn=function(a){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in a&&(t[e]=a[e]),t),{})},Tu=(a,t)=>Object.keys(a).reduce((e,s)=>(t(a[s],s,a)&&(e[s]=a[s]),e),{}),pp={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},Eu=(a,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?a+6*(t-a)*e:e<.5?t:e<2/3?a+(t-a)*(2/3-e)*6:a),mp=(a,t,e,s)=>{a/=255,t/=255,e/=255;const i=Math.max(a,t,e),n=Math.min(a,t,e);let r,o;const h=(i+n)/2;if(i===n)r=o=0;else{const l=i-n;switch(o=h>.5?l/(2-i-n):l/(i+n),i){case a:r=(t-e)/l+(t<e?6:0);break;case t:r=(e-a)/l+2;break;case e:r=(a-t)/l+4}r/=6}return[Math.round(360*r),Math.round(100*o),Math.round(100*h),s]},bp=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(a)/(a.endsWith("%")?100:1)},lc=a=>Math.min(Math.round(a),255).toString(16).toUpperCase().padStart(2,"0"),vp=a=>{let[t,e,s,i=1]=a;const n=Math.round(.3*t+.59*e+.11*s);return[n,n,n,i]};class ut{constructor(t){if(A(this,"isUnrecognised",!1),t)if(t instanceof ut)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,s,i,n=1]=t;this.setSource([e,s,i,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return t in pp&&(t=pp[t]),t==="transparent"?[255,255,255,0]:ut.sourceFromHex(t)||ut.sourceFromRgb(t)||ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=mp(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=mp(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(s,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,s,i]=this.getSource();return"".concat(lc(t)).concat(lc(e)).concat(lc(s)).concat(lc(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(vp(this.getSource())),this}toBlackWhite(t){const[e,,,s]=vp(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof ut||(t=new ut(t));const e=this.getSource(),s=t.getSource(),[i,n,r]=e.map((o,h)=>Math.round(.5*o+.5*s[h]));return this.setSource([i,n,r,e[3]]),this}static fromRgb(t){return ut.fromRgba(t)}static fromRgba(t){return new ut(ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[s,i,n]=e.slice(1,4).map(r=>{const o=parseFloat(r);return r.endsWith("%")?Math.round(2.55*o):o});return[s,i,n,bp(e[4])]}}static fromHsl(t){return ut.fromHsla(t)}static fromHsla(t){return new ut(ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let r,o,h;if(i===0)r=o=h=n;else{const l=n<=.5?n*(i+1):n+i-n*i,d=2*n-l;r=Eu(d,l,s+1/3),o=Eu(d,l,s),h=Eu(d,l,s-1/3)}return[Math.round(255*r),Math.round(255*o),Math.round(255*h),bp(e[4])]}static fromHex(t){return new ut(ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map(h=>h+h):e.match(/.{2}/g);const[i,n,r,o=255]=s.map(h=>parseInt(h,16));return[i,n,r,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),s=parseFloat(e);return e.includes("rad")?un(s):e.includes("turn")?360*s:s}}const xt=(a,t)=>parseFloat(Number(a).toFixed(t)),Ae=function(a){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:bu;const e=/\D{0,2}$/.exec(a),s=parseFloat(a),i=at.DPI;switch(e==null?void 0:e[0]){case"mm":return s*i/25.4;case"cm":return s*i/2.54;case"in":return s*i;case"pt":return s*i/72;case"pc":return s*i/72*12;case"em":return s*t;default:return s}},ku=a=>{const[t,e]=a.trim().split(" "),[s,i]=(n=t)&&n!==xe?[n.slice(1,4),n.slice(5,8)]:n===xe?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:s,alignY:i}},Za=a=>"matrix("+a.map(t=>xt(t,at.NUM_FRACTION_DIGITS)).join(" ")+")",th=function(a,t){let e,s,i=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new ut(t),r=n.getAlpha();e=n.toRgb(),r!==1&&(s=r.toString())}else e="none";return i?"".concat(a,": ").concat(e,"; ").concat(s?"".concat(a,"-opacity: ").concat(s,"; "):""):"".concat(a,'="').concat(e,'" ').concat(s?"".concat(a,'-opacity="').concat(s,'" '):"")},rs=a=>!!a&&a.toLive!==void 0,yp=a=>!!a&&typeof a.toObject=="function",_p=a=>!!a&&a.offsetX!==void 0&&"source"in a,wp=a=>!!a&&typeof a._renderText=="function",tr=a=>!!a&&"multiSelectionStacking"in a;function xp(a){const t=a&&ws(a);let e=0,s=0;if(!a||!t)return{left:e,top:s};let i=a;const n=t.documentElement,r=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(e=r.scrollLeft||n.scrollLeft||0,s=r.scrollTop||n.scrollTop||0):(e+=i.scrollLeft||0,s+=i.scrollTop||0),i.nodeType!==1||i.style.position!=="fixed"););return{left:e,top:s}}const ws=a=>a.ownerDocument||null,Sp=a=>{var t;return((t=a.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Cp=function(a,t,e){let{width:s,height:i}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;a.width=s,a.height=i,n>1&&(a.setAttribute("width",(s*n).toString()),a.setAttribute("height",(i*n).toString()),t.scale(n,n))},Mu=(a,t)=>{let{width:e,height:s}=t;e&&(a.style.width=typeof e=="number"?"".concat(e,"px"):e),s&&(a.style.height=typeof s=="number"?"".concat(s,"px"):s)};function Ap(a){return a.onselectstart!==void 0&&(a.onselectstart=()=>!1),a.style.userSelect=xe,a}class Tp{constructor(t){A(this,"_originalCanvasStyle",void 0),A(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&s.getContext!==void 0?t:t&&xo().getElementById(t)||ns();var s;if(e.hasAttribute("data-fabric"))throw new Xs("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:s}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(s)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:s,ctx:i}=this.lower;Cp(s,i,t,e)}setCSSDimensions(t){Mu(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&ws(t),i={left:0,top:0};if(!s)return i;const n=((e=Sp(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(n.borderLeftWidth,10)||0,i.top+=parseInt(n.borderTopWidth,10)||0,i.left+=parseInt(n.paddingLeft,10)||0,i.top+=parseInt(n.paddingTop,10)||0;let r={left:0,top:0};const o=s.documentElement;t.getBoundingClientRect!==void 0&&(r=t.getBoundingClientRect());const h=xp(t);return{left:r.left+h.left-(o.clientLeft||0)+i.left,top:r.top+h.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){Vs().dispose(this.lower.el),delete this.lower}}const Wv={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...we]};class eh extends ap(hp){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return eh.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Tp(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const n=super.insertAt(t,...s);return s.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(mi("warn",`Canvas is trying to add an object that belongs to a different canvas.
3
3
  Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?ip():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:s=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const i=T({width:this.width,height:this.height},t);this.elements.setDimensions(i,this.getRetinaScaling()),this.hasLostContext=!0,this.width=i.width,this.height=i.height}s||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const s=t,i=[...this.viewportTransform],n=ce(t,Ie(i));i[0]=e,i[3]=e;const r=ce(n,i);i[4]+=s.x-r.x,i[5]+=s.y-r.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new D(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new D(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=$a(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,s=Ie(this.viewportTransform),i=ce({x:0,y:0},s),n=ce({x:t,y:e},s),r=i.min(n),o=i.max(n);return this.vptCoords={tl:r,tr:new D(o.x,r.y),bl:new D(r.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(lp(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const s=this.viewportTransform;t.save(),t.transform(...s),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let s=0,i=e.length;s<i;++s)e[s]&&e[s].render(t)}_renderBackgroundOrOverlay(t,e){const s=this["".concat(e,"Color")],i=this["".concat(e,"Image")],n=this.viewportTransform,r=this["".concat(e,"Vpt")];if(!s&&!i)return;const o=rs(s);if(s){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=o?s.toLive(t):s,r&&t.transform(...n),o){t.transform(1,0,0,1,s.offsetX||0,s.offsetY||0);const h=s.gradientTransform||s.patternTransform;h&&t.transform(...h)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:h}=this;this.skipOffscreen=r,r&&t.transform(...n),i.render(t),this.skipOffscreen=h,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new D(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new D(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new D(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new D(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new D(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ce(this.getCenterPoint(),Ie(this.viewportTransform))}_centerObject(t,e){t.setXY(e,Q,Q),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const s=this.clipPath,i=s&&!s.excludeFromExport?this._toObject(s,t,e):null;return T(T(T({version:pu},Zn(this,e)),{},{objects:this._objects.filter(n=>!n.excludeFromExport).map(n=>this._toObject(n,t,e))},this.__serializeBgOverlay(t,e)),i?{clipPath:i}:null)}_toObject(t,e,s){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](s);return this.includeDefaultValues||(t.includeDefaultValues=!!i),n}__serializeBgOverlay(t,e){const s={},i=this.backgroundImage,n=this.overlayImage,r=this.backgroundColor,o=this.overlayColor;return rs(r)?r.excludeFromExport||(s.background=r.toObject(e)):r&&(s.background=r),rs(o)?o.excludeFromExport||(s.overlay=o.toObject(e)):o&&(s.overlay=o),i&&!i.excludeFromExport&&(s.backgroundImage=this._toObject(i,t,e)),n&&!n.excludeFromExport&&(s.overlayImage=this._toObject(n,t,e)),s}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const s=[];return this._setSVGPreamble(s,t),this._setSVGHeader(s,t),this.clipPath&&s.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
4
4
  `)),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push(`</g>
5
5
  `),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push("</svg>"),s.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
@@ -34,7 +34,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
34
34
  <feMergeNode in="SourceGraphic"></feMergeNode>
35
35
  </feMerge>
36
36
  </filter>
37
- `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=vi.ownDefaults;return this.includeDefaultValues?t:Tu(t,(s,i)=>s!==e[i])}static async fromObject(t){return new this(t)}}A(vi,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),A(vi,"type","shadow"),N.setClass(vi,"shadow");const sr=(a,t,e)=>Math.max(a,Math.min(t,e)),Qv=[Le,lt,Se,Ve,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",So,Co],yi=[jt,Ce,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Jv={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:lt,originY:Le,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:jt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},Hu=(a,t,e,s)=>(a<Math.abs(t)?(a=t,s=e/4):s=t===0&&a===0?e/bi*Math.asin(1):e/bi*Math.asin(t/a),{a,c:t,p:e,s}),Gp=(a,t,e,s,i)=>a*Math.pow(2,10*(s-=1))*Math.sin((s*i-t)*bi/e),Yp=(a,t,e,s)=>-e*Math.cos(a/s*ln)+e+t,Wu=(a,t,e,s)=>(a/=s)<1/2.75?e*(7.5625*a*a)+t:a<2/2.75?e*(7.5625*(a-=1.5/2.75)*a+.75)+t:a<2.5/2.75?e*(7.5625*(a-=2.25/2.75)*a+.9375)+t:e*(7.5625*(a-=2.625/2.75)*a+.984375)+t,Up=(a,t,e,s)=>e-Wu(s-a,0,e,s)+t;var Zv=Object.freeze({__proto__:null,defaultEasing:Yp,easeInBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return e*(a/=s)*a*((i+1)*a-i)+t},easeInBounce:Up,easeInCirc:(a,t,e,s)=>-e*(Math.sqrt(1-(a/=s)*a)-1)+t,easeInCubic:(a,t,e,s)=>e*(a/s)**3+t,easeInElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s)===1)return t+e;n||(n=.3*s);const{a:r,s:o,p:h}=Hu(i,e,n,1.70158);return-Gp(r,o,h,a,s)+t},easeInExpo:(a,t,e,s)=>a===0?t:e*2**(10*(a/s-1))+t,easeInOutBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return(a/=s/2)<1?e/2*(a*a*((1+(i*=1.525))*a-i))+t:e/2*((a-=2)*a*((1+(i*=1.525))*a+i)+2)+t},easeInOutBounce:(a,t,e,s)=>a<s/2?.5*Up(2*a,0,e,s)+t:.5*Wu(2*a-s,0,e,s)+.5*e+t,easeInOutCirc:(a,t,e,s)=>(a/=s/2)<1?-e/2*(Math.sqrt(1-a**2)-1)+t:e/2*(Math.sqrt(1-(a-=2)*a)+1)+t,easeInOutCubic:(a,t,e,s)=>(a/=s/2)<1?e/2*a**3+t:e/2*((a-2)**3+2)+t,easeInOutElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s/2)===2)return t+e;n||(n=s*(.3*1.5));const{a:r,s:o,p:h,c:l}=Hu(i,e,n,1.70158);return a<1?-.5*Gp(r,o,h,a,s)+t:r*Math.pow(2,-10*(a-=1))*Math.sin((a*s-o)*bi/h)*.5+l+t},easeInOutExpo:(a,t,e,s)=>a===0?t:a===s?t+e:(a/=s/2)<1?e/2*2**(10*(a-1))+t:e/2*-(2**(-10*--a)+2)+t,easeInOutQuad:(a,t,e,s)=>(a/=s/2)<1?e/2*a**2+t:-e/2*(--a*(a-2)-1)+t,easeInOutQuart:(a,t,e,s)=>(a/=s/2)<1?e/2*a**4+t:-e/2*((a-=2)*a**3-2)+t,easeInOutQuint:(a,t,e,s)=>(a/=s/2)<1?e/2*a**5+t:e/2*((a-2)**5+2)+t,easeInOutSine:(a,t,e,s)=>-e/2*(Math.cos(Math.PI*a/s)-1)+t,easeInQuad:(a,t,e,s)=>e*(a/=s)*a+t,easeInQuart:(a,t,e,s)=>e*(a/=s)*a**3+t,easeInQuint:(a,t,e,s)=>e*(a/s)**5+t,easeInSine:(a,t,e,s)=>-e*Math.cos(a/s*ln)+e+t,easeOutBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return e*((a=a/s-1)*a*((i+1)*a+i)+1)+t},easeOutBounce:Wu,easeOutCirc:(a,t,e,s)=>e*Math.sqrt(1-(a=a/s-1)*a)+t,easeOutCubic:(a,t,e,s)=>e*((a/s-1)**3+1)+t,easeOutElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s)===1)return t+e;n||(n=.3*s);const{a:r,s:o,p:h,c:l}=Hu(i,e,n,1.70158);return r*2**(-10*a)*Math.sin((a*s-o)*bi/h)+l+t},easeOutExpo:(a,t,e,s)=>a===s?t+e:e*-(2**(-10*a/s)+1)+t,easeOutQuad:(a,t,e,s)=>-e*(a/=s)*(a-2)+t,easeOutQuart:(a,t,e,s)=>-e*((a=a/s-1)*a**3-1)+t,easeOutQuint:(a,t,e,s)=>e*((a/s-1)**5+1)+t,easeOutSine:(a,t,e,s)=>e*Math.sin(a/s*ln)+t});const ty=()=>!1;class zu{constructor(t){let{startValue:e,byValue:s,duration:i=500,delay:n=0,easing:r=Yp,onStart:o=Kn,onChange:h=Kn,onComplete:l=Kn,abort:d=ty,target:u}=t;A(this,"_state","pending"),A(this,"durationProgress",0),A(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=n,this.easing=r,this._onStart=o,this._onChange=h,this._onComplete=l,this._abort=d,this.target=u,this.startValue=e,this.byValue=s,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>$a(t),this.delay):$a(t)}tick(t){const e=(t||+new Date)-this.startTime,s=Math.min(e,this.duration);this.durationProgress=s/this.duration;const{value:i,valueProgress:n}=this.calculate(s);this.value=Object.freeze(i),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),$a(this.tick)))}register(){rc.push(this)}unregister(){rc.remove(this)}abort(){this._state="aborted",this.unregister()}}const ey=["startValue","endValue"];class sy extends zu{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(T(T({},wt(t,ey)),{},{startValue:e,byValue:s-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const iy=["startValue","endValue"];class ny extends zu{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(T(T({},wt(t,iy)),{},{startValue:e,byValue:s.map((i,n)=>i-e[n])}))}calculate(t){const e=this.startValue.map((s,i)=>this.easing(t,s,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const ry=["startValue","endValue","easing","onChange","onComplete","abort"],oy=(a,t,e,s)=>t+e*(1-Math.cos(a/s*ln)),Xu=a=>a&&((t,e,s)=>a(new ut(t).toRgba(),e,s));class ay extends zu{constructor(t){let{startValue:e,endValue:s,easing:i=oy,onChange:n,onComplete:r,abort:o}=t,h=wt(t,ry);const l=new ut(e).getSource(),d=new ut(s).getSource();super(T(T({},h),{},{startValue:l,byValue:d.map((u,g)=>u-l[g]),easing:i,onChange:Xu(n),onComplete:Xu(r),abort:Xu(o)}))}calculate(t){const[e,s,i,n]=this.startValue.map((o,h)=>this.easing(t,o,this.byValue[h],this.duration,h)),r=[...[e,s,i].map(Math.round),sr(0,n,1)];return{value:r,valueProgress:r.map((o,h)=>this.byValue[h]!==0?Math.abs((o-this.startValue[h])/this.byValue[h]):0).find(o=>o!==0)||0}}}function Vu(a){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(a)?new ny(a):new sy(a);return t.start(),t}function qp(a){const t=new ay(a);return t.start(),t}class At{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return this.points=this.points.concat(e.filter(i=>!this.includes(i))),this}static isPointContained(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(s))return t.eq(e);if(e.x===s.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,s.y)&&t.y<=Math.max(e.y,s.y));if(e.y===s.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,s.x)&&t.x<=Math.max(e.x,s.x));{const n=fc(e,s),r=fc(e,t).divide(n);return i?Math.abs(r.x)===Math.abs(r.y):r.x===r.y&&r.x>=0&&r.x<=1}}static isPointInPolygon(t,e){const s=new D(t).setX(Math.min(t.x-1,...e.map(n=>n.x)));let i=0;for(let n=0;n<e.length;n++){const r=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,s);if(r.includes(t))return!0;i+=+(r.status==="Intersection")}return i%2==1}static intersectLineLine(t,e,s,i){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],r=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const o=e.x-t.x,h=e.y-t.y,l=i.x-s.x,d=i.y-s.y,u=t.x-s.x,g=t.y-s.y,f=l*g-d*u,p=o*g-h*u,m=d*o-l*h;if(m!==0){const _=f/m,y=p/m;return(n||0<=_&&_<=1)&&(r||0<=y&&y<=1)?new At("Intersection").append(new D(t.x+_*o,t.y+_*h)):new At}if(f===0||p===0){const _=n||r||At.isPointContained(t,s,i)||At.isPointContained(e,s,i)||At.isPointContained(s,t,e)||At.isPointContained(i,t,e);return new At(_?"Coincident":void 0)}return new At("Parallel")}static intersectSegmentLine(t,e,s,i){return At.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return At.intersectLineLine(t,e,s,i,!1,!1)}static intersectLinePolygon(t,e,s){let i=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new At,r=s.length;for(let o,h,l,d=0;d<r;d++){if(o=s[d],h=s[(d+1)%r],l=At.intersectLineLine(t,e,o,h,i,!1),l.status==="Coincident")return l;n.append(...l.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,s){return At.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new At,i=t.length,n=[];for(let r=0;r<i;r++){const o=t[r],h=t[(r+1)%i],l=At.intersectSegmentPolygon(o,h,e);l.status==="Coincident"?(n.push(l),s.append(o,h)):s.append(...l.points)}return n.length>0&&n.length===t.length?new At("Coincident"):(s.points.length>0&&(s.status="Intersection"),s)}static intersectPolygonRectangle(t,e,s){const i=e.min(s),n=e.max(s),r=new D(n.x,i.y),o=new D(i.x,n.y);return At.intersectPolygonPolygon(t,[i,r,n,o])}}class hy extends hp{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?ce(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=ce(t,Ie(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new D(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,s)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:s,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,s,i];if(this.group){const r=this.group.calcTransformMatrix();return n.map(o=>ce(o,r))}return n}intersectsWithRect(t,e){return At.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=At.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:s,top:i,width:n,height:r}=this.getBoundingRect();return s>=t.x&&s+n<=e.x&&i>=t.y&&i+r<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return At.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(s=>s.x<=e.x&&s.x>=t.x&&s.y<=e.y&&s.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(s=>(s.x>=e.x||s.x<=t.x)&&(s.y>=e.y||s.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Gs(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Se,t),this._set(Ve,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?un(up(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||we.concat()}calcACoords(){const t=Eo({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=To(e,s),n=Rt(i,t),r=this._getTransformedDimensions(),o=r.x/2,h=r.y/2;return{tl:ce({x:-o,y:-h},n),tr:ce({x:o,y:-h},n),bl:ce({x:-o,y:h},n),br:ce({x:o,y:h},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Nt(this.originX),Nt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const s=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((n,r)=>n===s[r])?i.value:(this.group&&(e=Rt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:s,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const s=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:s.x,translateY:s.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=fp(i);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new D(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=T({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),s=e.strokeWidth;let i=s,n=0;this.strokeUniform&&(i=0,n=s);const r=e.width+i,o=e.height+i;let h;return h=e.skewX===0&&e.skewY===0?new D(r*e.scaleX,o*e.scaleY):dc(r,o,Ka(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,n){let r=t.x,o=t.y;const h=Nt(i)-Nt(e),l=Nt(n)-Nt(s);if(h||l){const d=this._getTransformedDimensions();r+=h*d.x,o+=l*d.y}return new D(r,o)}translateToCenterPoint(t,e,s){if(e===Q&&s===Q)return t;const i=this.translateToGivenOrigin(t,e,s,Q,Q);return this.angle?i.rotate(Ot(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,Q,Q,e,s);return this.angle?i.rotate(Ot(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ce(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new D(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,s){const i=this.translateToCenterPoint(t,e,s),n=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),lt,Le)}}const ly=["type"],cy=["extraParam"];let _i=class Nd extends hy{static getDefaults(){return Nd.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){super(),A(this,"_cacheContext",null),Object.assign(this,Nd.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ns(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=at.maxCacheSideLimit,n=at.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=at.perfLimitSizeTotal)return e<n&&(t.width=n),s<n&&(t.height=n),t;const r=e/s,[o,h]=Ua.limitDimsByArea(r),l=sr(n,o,i),d=sr(n,h,i);return e>l&&(t.zoomX/=e/l,t.width=l,t.capped=!0),s>d&&(t.zoomY/=s/d,t.height=d,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),s=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:s+2,height:i+2,zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=at.minCacheSideLimit,n=s.width,r=s.height,o=s.zoomX,h=s.zoomY,l=n!==t.width||r!==t.height,d=this.zoomX!==o||this.zoomY!==h;if(!t||!e)return!1;let u,g,f=l||d,p=0,m=0,_=!1;if(l){const y=this._cacheCanvas.width,x=this._cacheCanvas.height,S=n>y||r>x;_=S||(n<.9*y||r<.9*x)&&y>i&&x>i,S&&!s.capped&&(n>i||r>i)&&(p=.1*n,m=.1*r)}return wp(this)&&this.path&&(f=!0,_=!0,p+=this.getHeightOfLine(0)*this.zoomX,m+=this.getHeightOfLine(0)*this.zoomY),!!f&&(_?(t.width=Math.ceil(n+p),t.height=Math.ceil(r+m)):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height)),u=s.x/2,g=s.y/2,this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-g)+g,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(o,h),this.zoomX=o,this.zoomY=h,!0)}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,s=this.calcTransformMatrix(!e);t.transform(s[0],s[1],s[2],s[3],s[4],s[5])}getObjectScaling(){if(!this.group)return new D(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Jn(this.calcTransformMatrix());return new D(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),s=this.getCanvasRetinaScaling();return t.scalarMultiply(e*s)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==Se&&t!==Ve||(e=this._constrainScale(e)),t===Se&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof vi||(e=new vi(e));const s=this[t]!==e;return this[t]=e,s&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||s&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:n}=this,{width:r,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:n,width:r,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===Ce&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.parent||!this.parent.isOnACache()),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,s){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0),t.restore()}drawObject(t,e,s){const i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,s),this.fill=i,this.stroke=n}createClipPathLayer(t,e){const s=_s(e),i=s.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=s,e.parentClipPaths.forEach(n=>{n.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ie(this.calcTransformMatrix());i.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(i),t.drawObject(i,!0,e),s}_drawClipPath(t,e,s){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,s);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,s=this._cacheContext;return!(!e||!s||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&s&&!t&&(s.save(),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),s.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const s=e.stroke;s&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,rs(s)?s.gradientUnits==="percentage"||s.gradientTransform||s.patternTransform?this._applyPatternForTransformedGradient(t,s):(t.strokeStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:s}=e;s&&(rs(s)?(t.fillStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.fillStyle=s)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&(1&e.length&&e.push(...e),t.setLineDash(e))}_setShadow(t){if(!this.shadow)return;const e=this.shadow,s=this.canvas,i=this.getCanvasRetinaScaling(),[n,,,r]=(s==null?void 0:s.viewportTransform)||we,o=n*i,h=r*i,l=e.nonScaling?new D(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*at.browserShadowBlurConstant*(o+h)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*o*l.x,t.shadowOffsetY=e.offsetY*h*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!rs(e))return{offsetX:0,offsetY:0};const s=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,i,n):t.transform(1,0,0,1,i,n),s&&t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),{offsetX:i,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===Ce?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var s;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),r=i.x/this.scaleX/n,o=i.y/this.scaleY/n,h=_s({width:Math.ceil(r),height:Math.ceil(o)}),l=h.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(r,0),l.lineTo(r,o),l.lineTo(0,o),l.closePath(),l.translate(r/2,o/2),l.scale(i.zoomX/this.scaleX/n,i.zoomY/this.scaleY/n),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/i.zoomX,n*this.scaleY/i.zoomY),t.strokeStyle=(s=l.createPattern(h,"no-repeat"))!==null&&s!==void 0?s:"")}_findCenterFromElement(){return new D(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(N.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Du(this),s=this.group,i=this.shadow,n=Math.abs,r=t.enableRetinaScaling?ip():1,o=(t.multiplier||1)*r,h=t.canvasProvider||(x=>new eh(x,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Mp(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Pu(this,this.getViewportTransform()),this.setCoords();const l=ns(),d=this.getBoundingRect(),u=this.shadow,g=new D;if(u){const x=u.blur,S=u.nonScaling?new D(1,1):this.getObjectScaling();g.x=2*Math.round(n(u.offsetX)+x)*n(S.x),g.y=2*Math.round(n(u.offsetY)+x)*n(S.y)}const f=d.width+g.x,p=d.height+g.y;l.width=Math.ceil(f),l.height=Math.ceil(p);const m=h(l);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new D(m.width/2,m.height/2),Q,Q);const _=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const y=m.toCanvasElement(o||1,t);return this.set("canvas",_),this.shadow=i,s&&(this.group=s),this.set(e),this.setCoords(),m._objects=[],m.destroy(),y}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Su(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:s,originY:i}=this;if(e){const{x:n,y:r}=this.getRelativeCenterPoint();this.originX=Q,this.originY=Q,this.left=n,this.top=r}if(this.set("angle",t),e){const{x:n,y:r}=this.translateToOriginPoint(this.getRelativeCenterPoint(),s,i);this.left=n,this.top=r,this.originX=s,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){rc.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Vs().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((s,i)=>{let[n,r]=i;return s[n]=this._animate(n,r,e),s},{})}_animate(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=t.split("."),n=this.constructor.colorProperties.includes(i[i.length-1]),{abort:r,startValue:o,onChange:h,onComplete:l}=s,d=T(T({},s),{},{target:this,startValue:o??i.reduce((u,g)=>u[g],this),endValue:e,abort:r==null?void 0:r.bind(this),onChange:(u,g,f)=>{i.reduce((p,m,_)=>(_===i.length-1&&(p[m]=u),p[m]),this),h&&h(u,g,f)},onComplete:(u,g,f)=>{this.setCoords(),l&&l(u,g,f)}});return n?qp(d):Vu(d)}isDescendantOf(t){const{parent:e,group:s}=this;return e===t||s===t||!!e&&e.isDescendantOf(t)||!!s&&s!==e&&s.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),s=t.getAncestors();if(e.length===0&&s.length>0&&this===s[s.length-1])return{fork:[],otherFork:[t,...s.slice(0,s.length-1)],common:[this]};for(let i,n=0;n<e.length;n++){if(i=e[n],i===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let r=0;r<s.length;r++){if(this===s[r])return{fork:[],otherFork:[t,...s.slice(0,r)],common:[this,...e]};if(i===s[r])return{fork:[this,...e.slice(0,n)],otherFork:[t,...s.slice(0,r)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...s],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const s=e.common[0]||this.canvas;if(!s)return;const i=e.fork.pop(),n=e.otherFork.pop(),r=s._objects.indexOf(i),o=s._objects.indexOf(n);return r>-1&&r>o}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Nd.customProperties,this.constructor.customProperties||[]);let e;const s=at.NUM_FRACTION_DIGITS,{clipPath:i,fill:n,stroke:r,shadow:o,strokeDashArray:h,left:l,top:d,originX:u,originY:g,width:f,height:p,strokeWidth:m,strokeLineCap:_,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:S,strokeMiterLimit:C,scaleX:E,scaleY:M,angle:k,flipX:O,flipY:P,opacity:F,visible:R,backgroundColor:W,fillRule:B,paintFirst:X,globalCompositeOperation:K,skewX:tt,skewY:V}=this;i&&!i.excludeFromExport&&(e=i.toObject(t.concat("inverted","absolutePositioned")));const H=Jt=>xt(Jt,s),Qt=T(T({},Zn(this,t)),{},{type:this.constructor.type,version:pu,originX:u,originY:g,left:H(l),top:H(d),width:H(f),height:H(p),fill:yp(n)?n.toObject():n,stroke:yp(r)?r.toObject():r,strokeWidth:H(m),strokeDashArray:h&&h.concat(),strokeLineCap:_,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:S,strokeMiterLimit:H(C),scaleX:H(E),scaleY:H(M),angle:H(k),flipX:O,flipY:P,opacity:H(F),shadow:o&&o.toObject(),visible:R,backgroundColor:W,fillRule:B,paintFirst:X,globalCompositeOperation:K,skewX:H(tt),skewY:H(V)},e?{clipPath:e}:null);return this.includeDefaultValues?Qt:this._removeDefaultValues(Qt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Tu(t,(i,n)=>{if(n===lt||n===Le||n==="type")return!0;const r=s[n];return i!==r&&!(Array.isArray(i)&&Array.isArray(r)&&i.length===0&&r.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=wt(t,ly),s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:i}=s,n=wt(s,cy);return Ja(e,n).then(r=>i?(delete r[i],new this(e[i],r)):new this(r))}static fromObject(t,e){return this._fromObject(t,e)}};A(_i,"stateProperties",Qv),A(_i,"cacheProperties",yi),A(_i,"ownDefaults",Jv),A(_i,"type","FabricObject"),A(_i,"colorProperties",[jt,Ce,"backgroundColor"]),A(_i,"customProperties",[]),N.setClass(_i),N.setClass(_i,"object");const Do=(a,t,e)=>(s,i,n,r)=>{const o=t(s,i,n,r);return o&&Dp(a,T(T({},Rp(s,i,n,r)),e)),o};function Po(a){return(t,e,s,i)=>{const{target:n,originX:r,originY:o}=e,h=n.getRelativeCenterPoint(),l=n.translateToOriginPoint(h,r,o),d=a(t,e,s,i);return n.setPositionByOrigin(l,e.originX,e.originY),d}}const $p=Do(qa,Po((a,t,e,s)=>{const i=Fu(t,t.originX,t.originY,e,s);if(Nt(t.originX)===Nt(Q)||Nt(t.originX)===Nt(Ft)&&i.x<0||Nt(t.originX)===Nt(lt)&&i.x>0){const{target:n}=t,r=n.strokeWidth/(n.strokeUniform?n.scaleX:1),o=Pp(t)?2:1,h=n.width,l=Math.abs(i.x*o/n.scaleX)-r;return n.set("width",Math.max(l,1)),h!==n.width}return!1}));function dy(a,t,e,s,i){s=s||{};const n=this.sizeX||s.cornerSize||i.cornerSize,r=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?Ce:jt,l=!o&&(s.cornerStrokeColor||i.cornerStrokeColor);let d,u=t,g=e;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",n>r?(d=n,a.scale(1,r/n),g=e*n/r):r>n?(d=r,a.scale(n/r,1),u=t*r/n):d=n,a.lineWidth=1,a.beginPath(),a.arc(u,g,d/2,0,bi,!1),a[h](),l&&a.stroke(),a.restore()}function uy(a,t,e,s,i){s=s||{};const n=this.sizeX||s.cornerSize||i.cornerSize,r=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?Ce:jt,l=!o&&(s.cornerStrokeColor||i.cornerStrokeColor),d=n/2,u=r/2;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",a.lineWidth=1,a.translate(t,e);const g=i.getTotalAngle();a.rotate(Ot(g)),a["".concat(h,"Rect")](-d,-u,n,r),l&&a.strokeRect(-d,-u,n,r),a.restore()}class Cs{constructor(t){A(this,"visible",!0),A(this,"actionName",ic),A(this,"angle",0),A(this,"x",0),A(this,"y",0),A(this,"offsetX",0),A(this,"offsetY",0),A(this,"sizeX",0),A(this,"sizeY",0),A(this,"touchSizeX",0),A(this,"touchSizeY",0),A(this,"cursorStyle","crosshair"),A(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,s,i){var n;let{tl:r,tr:o,br:h,bl:l}=i;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&At.isPointInPolygon(s,[r,o,h,l])}getActionHandler(t,e,s){return this.actionHandler}getMouseDownHandler(t,e,s){return this.mouseDownHandler}getMouseUpHandler(t,e,s){return this.mouseUpHandler}cursorStyleHandler(t,e,s){return e.cursorStyle}getActionName(t,e,s){return e.actionName}getVisibility(t,e){var s,i;return(s=(i=t._controlsVisibility)===null||i===void 0?void 0:i[e])!==null&&s!==void 0?s:this.visible}setVisibility(t,e,s){this.visible=t}positionHandler(t,e,s,i){return new D(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,n,r){const o=ac([To(s,i),Eo({angle:t}),hc((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new D(-.5,-.5).transform(o),tr:new D(.5,-.5).transform(o),br:new D(.5,.5).transform(o),bl:new D(-.5,.5).transform(o)}}render(t,e,s,i,n){((i=i||{}).cornerStyle||n.cornerStyle)==="circle"?dy.call(this,t,e,s,i,n):uy.call(this,t,e,s,i,n)}}const gy=(a,t,e)=>e.lockRotation?uc:t.cursorStyle,fy=Do(rp,Po((a,t,e,s)=>{let{target:i,ex:n,ey:r,theta:o,originX:h,originY:l}=t;const d=i.translateToOriginPoint(i.getRelativeCenterPoint(),h,l);if(xs(i,"lockRotation"))return!1;const u=Math.atan2(r-d.y,n-d.x),g=Math.atan2(s-d.y,e-d.x);let f=un(g-u+o);if(i.snapAngle&&i.snapAngle>0){const m=i.snapAngle,_=i.snapThreshold||m,y=Math.ceil(f/m)*m,x=Math.floor(f/m)*m;Math.abs(f-x)<_?f=x:Math.abs(f-y)<_&&(f=y)}f<0&&(f=360+f),f%=360;const p=i.angle!==f;return i.angle=f,p}));function Kp(a,t){const e=t.canvas,s=a[e.uniScaleKey];return e.uniformScaling&&!s||!e.uniformScaling&&s}function Qp(a,t,e){const s=xs(a,"lockScalingX"),i=xs(a,"lockScalingY");if(s&&i||!t&&(s||i)&&e||s&&t==="x"||i&&t==="y")return!0;const{width:n,height:r,strokeWidth:o}=a;return n===0&&o===0&&t!=="y"||r===0&&o===0&&t!=="x"}const py=["e","se","s","sw","w","nw","n","ne","e"],ih=(a,t,e)=>{const s=Kp(a,e);if(Qp(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return uc;const i=Lp(e,t);return"".concat(py[i],"-resize")};function Gu(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,r=i.by,o=Kp(a,n);let h,l,d,u,g,f;if(Qp(n,r,o))return!1;if(t.gestureScale)l=t.scaleX*t.gestureScale,d=t.scaleY*t.gestureScale;else{if(h=Fu(t,t.originX,t.originY,e,s),g=r!=="y"?Math.sign(h.x||t.signX||1):1,f=r!=="x"?Math.sign(h.y||t.signY||1):1,t.signX||(t.signX=g),t.signY||(t.signY=f),xs(n,"lockScalingFlip")&&(t.signX!==g||t.signY!==f))return!1;if(u=n._getTransformedDimensions(),o&&!r){const _=Math.abs(h.x)+Math.abs(h.y),{original:y}=t,x=_/(Math.abs(u.x*y.scaleX/n.scaleX)+Math.abs(u.y*y.scaleY/n.scaleY));l=y.scaleX*x,d=y.scaleY*x}else l=Math.abs(h.x*n.scaleX/u.x),d=Math.abs(h.y*n.scaleY/u.y);Pp(t)&&(l*=2,d*=2),t.signX!==g&&r!=="y"&&(t.originX=Fp(t.originX),l*=-1,t.signX=g),t.signY!==f&&r!=="x"&&(t.originY=Fp(t.originY),d*=-1,t.signY=f)}const p=n.scaleX,m=n.scaleY;return r?(r==="x"&&n.set(Se,l),r==="y"&&n.set(Ve,d)):(!xs(n,"lockScalingX")&&n.set(Se,l),!xs(n,"lockScalingY")&&n.set(Ve,d)),p!==n.scaleX||m!==n.scaleY}const vc=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s))),my=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s,{by:"x"}))),by=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s,{by:"y"}))),vy=["target","ex","ey","skewingSide"],Yu={x:{counterAxis:"y",scale:Se,skew:So,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Ve,skew:Co,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},yy=["ns","nesw","ew","nwse"],_y=(a,t,e)=>{if(t.x!==0&&xs(e,"lockSkewingY")||t.y!==0&&xs(e,"lockSkewingX"))return uc;const s=Lp(e,t)%4;return"".concat(yy[s],"-resize")};function Jp(a,t,e,s,i){const{target:n}=e,{counterAxis:r,origin:o,lockSkewing:h,skew:l,flip:d}=Yu[a];if(xs(n,h))return!1;const{origin:u,flip:g}=Yu[r],f=Nt(e[u])*(n[g]?-1:1),p=-Math.sign(f)*(n[d]?-1:1),m=.5*-((n[l]===0&&Fu(e,Q,Q,s,i)[a]>0||n[l]>0?1:-1)*p)+.5;return Do(op,Po((y,x,S,C)=>function(E,M,k){let{target:O,ex:P,ey:F,skewingSide:R}=M,W=wt(M,vy);const{skew:B}=Yu[E],X=k.subtract(new D(P,F)).divide(new D(O.scaleX,O.scaleY))[E],K=O[B],tt=W[B],V=Math.tan(Ot(tt)),H=E==="y"?O._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:O._getTransformedDimensions({scaleX:1,scaleY:1}).y,Qt=2*X*R/Math.max(H,1)+V,Jt=un(Math.atan(Qt));O.set(B,Jt);const le=K!==O[B];if(le&&E==="y"){const{skewX:zt,scaleX:_t}=O,Pe=O._getTransformedDimensions({skewY:K}),fi=O._getTransformedDimensions(),Pt=zt!==0?Pe.x/fi.x:1;Pt!==1&&O.set(Se,Pt*_t)}return le}(a,x,new D(S,C))))(t,T(T({},e),{},{[o]:m,skewingSide:p}),s,i)}const wy=(a,t,e,s)=>Jp("x",a,t,e,s),xy=(a,t,e,s)=>Jp("y",a,t,e,s);function yc(a,t){return a[t.canvas.altActionKey]}const _c=(a,t,e)=>{const s=yc(a,e);return t.x===0?s?So:Ve:t.y===0?s?Co:Se:""},Fo=(a,t,e)=>yc(a,e)?_y(0,t,e):ih(a,t,e),Zp=(a,t,e,s)=>yc(a,t.target)?xy(a,t,e,s):my(a,t,e,s),tm=(a,t,e,s)=>yc(a,t.target)?wy(a,t,e,s):by(a,t,e,s),em=()=>({ml:new Cs({x:-.5,y:0,cursorStyleHandler:Fo,actionHandler:Zp,getActionName:_c}),mr:new Cs({x:.5,y:0,cursorStyleHandler:Fo,actionHandler:Zp,getActionName:_c}),mb:new Cs({x:0,y:.5,cursorStyleHandler:Fo,actionHandler:tm,getActionName:_c}),mt:new Cs({x:0,y:-.5,cursorStyleHandler:Fo,actionHandler:tm,getActionName:_c}),tl:new Cs({x:-.5,y:-.5,cursorStyleHandler:ih,actionHandler:vc}),tr:new Cs({x:.5,y:-.5,cursorStyleHandler:ih,actionHandler:vc}),bl:new Cs({x:-.5,y:.5,cursorStyleHandler:ih,actionHandler:vc}),br:new Cs({x:.5,y:.5,cursorStyleHandler:ih,actionHandler:vc}),mtr:new Cs({x:0,y:-.5,actionHandler:fy,cursorStyleHandler:gy,offsetY:-40,withConnection:!0,actionName:_u})}),Sy=()=>({mr:new Cs({x:.5,y:0,actionHandler:$p,cursorStyleHandler:Fo,actionName:qa}),ml:new Cs({x:-.5,y:0,actionHandler:$p,cursorStyleHandler:Fo,actionName:qa})}),Cy=()=>T(T({},em()),Sy());class nh extends _i{static getDefaults(){return T(T({},super.getDefaults()),nh.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),nh.ownDefaults),this.setOptions(t)}static createControls(){return{controls:em()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,s=e.target,i=e.action;if(this===s&&i&&i.startsWith(ic))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const s=Object.entries(this.oCoords);for(let i=s.length-1;i>=0;i--){const[n,r]=s[i],o=this.controls[n];if(o.shouldActivate(n,this,t,e?r.touchCorner:r.corner))return this.__corner=n,{key:n,control:o,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),s=To(e.x,e.y),i=Eo({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Rt(s,i),r=Rt(t,n),o=Rt(r,[1/t[0],0,0,1/t[3],0,0]),h=this.group?Jn(this.calcTransformMatrix()):void 0;h&&(h.scaleX=Math.abs(h.scaleX),h.scaleY=Math.abs(h.scaleY));const l=this._calculateCurrentDimensions(h),d={};return this.forEachControl((u,g)=>{const f=u.positionHandler(l,o,this,u);d[g]=Object.assign(f,this._calcCornerCoords(u,f))}),d}_calcCornerCoords(t,e){const s=this.getTotalAngle();return{corner:t.calcCornerCoords(s,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(s,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(Ot(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-s.x/2,-s.y/2,s.x,s.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=T({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},s);t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:s,hasControls:i}=this,n=T({hasBorders:s,hasControls:i},e),r=this.getViewportTransform(),o=n.hasBorders,h=n.hasControls,l=Rt(r,this.calcTransformMatrix()),d=Jn(l);t.save(),t.translate(d.translateX,d.translateY),t.lineWidth=1*this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(d.angle-=180),t.rotate(Ot(this.group?d.angle:this.angle)),o&&this.drawBorders(t,d,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const n=dc(this.width,this.height,Ka(e)),r=this.isStrokeAccountedForInDimensions()?xu:(this.strokeUniform?new D().scalarAdd(this.canvas?this.canvas.getZoom():1):new D(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=n.add(r).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,s)}drawControlsConnectingLines(t,e){let s=!1;t.beginPath(),this.forEachControl((i,n)=>{i.withConnection&&i.getVisibility(this,n)&&(s=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),s&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const s=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:n,cornerColor:r}=this,o=T({cornerStrokeColor:i,cornerDashArray:n,cornerColor:r},e);t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((h,l)=>{if(h.getVisibility(this,l)){const d=this.oCoords[l];h.render(t,d.x,d.y,o,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[s,i]=e;return this.setControlVisible(s,i)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const s=this.canvas.viewportTransform;e.save(),e.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this.transform(e);const i=this.width+4,n=this.height+4;return e.clearRect(-i/2,-n/2,i,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function sm(a,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{s!=="constructor"&&Object.defineProperty(a.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),a}A(nh,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class de extends nh{}sm(de,[Ip]),N.setClass(de),N.setClass(de,"object");const im=(a,t,e,s)=>{const i=2*(s=Math.round(s))+1,{data:n}=a.getImageData(t-s,e-s,i,i);for(let r=3;r<n.length;r+=4)if(n[r]>0)return!1;return!0};class nm{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new D(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new D(1/this.options.scaleX,1/this.options.scaleY):new D(1,1)}createSideVector(t,e){const s=fc(t,e);return this.options.strokeUniform?s.multiply(this.scale):s}projectOrthogonally(t,e,s){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,s)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new D(t);return e.y+=e.x*Math.tan(Ot(this.options.skewY)),e.x+=e.y*Math.tan(Ot(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ay=new D;class Ro extends nm{static getOrthogonalRotationFactor(t,e){const s=e?mc(t,e):Wp(t);return Math.abs(s)<ln?-1:1}constructor(t,e,s,i){super(i),A(this,"AB",void 0),A(this,"AC",void 0),A(this,"alpha",void 0),A(this,"bisector",void 0),this.A=new D(t),this.B=new D(e),this.C=new D(s),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=mc(this.AB,this.AC),this.bisector=bc(ju(this.AB.eq(Ay)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),n=Nu(i),r=Ro.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,s*r)}projectBevel(){const t=[];return(this.alpha%bi==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),s=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*s),n=this.options.strokeUniform?pc(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return pc(i)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new D(Ro.getOrthogonalRotationFactor(this.bisector),Ro.getOrthogonalRotationFactor(new D(this.bisector.y,this.bisector.x)));return[new D(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new D(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(n=>{Bu(n,t,e)&&s.push(this.A.add(n))}),s}projectRoundWithSkew(t,e){const s=[],{skewX:i,skewY:n,scaleX:r,scaleY:o,strokeUniform:h}=this.options,l=new D(Math.tan(Ot(i)),Math.tan(Ot(n))),d=this.strokeProjectionMagnitude,u=h?d/o/Math.sqrt(1/o**2+1/r**2*l.y**2):d/Math.sqrt(1+l.y**2),g=new D(Math.sqrt(Math.max(d**2-u**2,0)),u),f=h?d/Math.sqrt(1+l.x**2*(1/o)**2/(1/r+1/r*l.x*l.y)**2):d/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),p=new D(f,Math.sqrt(Math.max(d**2-f**2,0)));return[p,p.scalarMultiply(-1),g,g.scalarMultiply(-1)].map(m=>this.applySkew(h?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{Bu(m,t,e)&&s.push(this.applySkew(this.A).add(m))}),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%bi==0,s=this.applySkew(this.A),i=t[e?0:2].subtract(s),n=t[e?1:0].subtract(s),r=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=Oo(i,r)>0,h=o?i:n,l=o?n:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(h,l)):t.push(...this.projectRoundNoSkew(h,l)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class rm extends nm{constructor(t,e,s){super(s),this.A=new D(t),this.T=new D(e)}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(Nu(i),s)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new D(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Ro(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new D(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),s=this.scaleUnitVector(bc(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(s);t.push(i.add(e),i.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const om=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const s=[];if(a.length===0)return s;const i=a.reduce((n,r)=>(n[n.length-1].eq(r)||n.push(new D(r)),n),[new D(a[0])]);if(i.length===1)e=!0;else if(!e){const n=i[0],r=((o,h)=>{for(let l=o.length-1;l>=0;l--)if(h(o[l],l,o))return l;return-1})(i,o=>!o.eq(n));i.splice(r+1)}return i.forEach((n,r,o)=>{let h,l;r===0?(l=o[1],h=e?n:o[o.length-1]):r===o.length-1?(h=o[r-1],l=e?n:o[0]):(h=o[r-1],l=o[r+1]),e&&o.length===1?s.push(...new rm(n,n,t).project()):!e||r!==0&&r!==o.length-1?s.push(...new Ro(n,h,l,t).project()):s.push(...new rm(n,r===0?l:h,t).project())}),s},Uu=a=>{const t={};return Object.keys(a).forEach(e=>{t[e]={},Object.keys(a[e]).forEach(s=>{t[e][s]=T({},a[e][s])})}),t},am=a=>a.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),wc=a=>{const t=[];for(let e,s=0;s<a.length;s++)(e=Ty(a,s))!==!1&&t.push(e);return t},Ty=(a,t)=>{const e=a.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return a.charAt(t);if(55296<=e&&e<=56319){if(a.length<=t+1)throw"High surrogate without following low surrogate";const i=a.charCodeAt(t+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return a.charAt(t)+a.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const s=a.charCodeAt(t-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1};var Ey=Object.freeze({__proto__:null,capitalize:function(a){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return"".concat(a.charAt(0).toUpperCase()).concat(t?a.slice(1):a.slice(1).toLowerCase())},escapeXml:am,graphemeSplit:wc});const xc=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return a.fill!==t.fill||a.stroke!==t.stroke||a.strokeWidth!==t.strokeWidth||a.fontSize!==t.fontSize||a.fontFamily!==t.fontFamily||a.fontWeight!==t.fontWeight||a.fontStyle!==t.fontStyle||a.textBackgroundColor!==t.textBackgroundColor||a.deltaY!==t.deltaY||e&&(a.overline!==t.overline||a.underline!==t.underline||a.linethrough!==t.linethrough)},hm=(a,t)=>{const e=t.split(`
37
+ `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=vi.ownDefaults;return this.includeDefaultValues?t:Tu(t,(s,i)=>s!==e[i])}static async fromObject(t){return new this(t)}}A(vi,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),A(vi,"type","shadow"),N.setClass(vi,"shadow");const sr=(a,t,e)=>Math.max(a,Math.min(t,e)),Qv=[Le,lt,Se,Ve,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",So,Co],yi=[jt,Ce,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Jv={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:lt,originY:Le,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:jt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},Hu=(a,t,e,s)=>(a<Math.abs(t)?(a=t,s=e/4):s=t===0&&a===0?e/bi*Math.asin(1):e/bi*Math.asin(t/a),{a,c:t,p:e,s}),Gp=(a,t,e,s,i)=>a*Math.pow(2,10*(s-=1))*Math.sin((s*i-t)*bi/e),Yp=(a,t,e,s)=>-e*Math.cos(a/s*ln)+e+t,Wu=(a,t,e,s)=>(a/=s)<1/2.75?e*(7.5625*a*a)+t:a<2/2.75?e*(7.5625*(a-=1.5/2.75)*a+.75)+t:a<2.5/2.75?e*(7.5625*(a-=2.25/2.75)*a+.9375)+t:e*(7.5625*(a-=2.625/2.75)*a+.984375)+t,Up=(a,t,e,s)=>e-Wu(s-a,0,e,s)+t;var Zv=Object.freeze({__proto__:null,defaultEasing:Yp,easeInBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return e*(a/=s)*a*((i+1)*a-i)+t},easeInBounce:Up,easeInCirc:(a,t,e,s)=>-e*(Math.sqrt(1-(a/=s)*a)-1)+t,easeInCubic:(a,t,e,s)=>e*(a/s)**3+t,easeInElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s)===1)return t+e;n||(n=.3*s);const{a:r,s:o,p:h}=Hu(i,e,n,1.70158);return-Gp(r,o,h,a,s)+t},easeInExpo:(a,t,e,s)=>a===0?t:e*2**(10*(a/s-1))+t,easeInOutBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return(a/=s/2)<1?e/2*(a*a*((1+(i*=1.525))*a-i))+t:e/2*((a-=2)*a*((1+(i*=1.525))*a+i)+2)+t},easeInOutBounce:(a,t,e,s)=>a<s/2?.5*Up(2*a,0,e,s)+t:.5*Wu(2*a-s,0,e,s)+.5*e+t,easeInOutCirc:(a,t,e,s)=>(a/=s/2)<1?-e/2*(Math.sqrt(1-a**2)-1)+t:e/2*(Math.sqrt(1-(a-=2)*a)+1)+t,easeInOutCubic:(a,t,e,s)=>(a/=s/2)<1?e/2*a**3+t:e/2*((a-2)**3+2)+t,easeInOutElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s/2)===2)return t+e;n||(n=s*(.3*1.5));const{a:r,s:o,p:h,c:l}=Hu(i,e,n,1.70158);return a<1?-.5*Gp(r,o,h,a,s)+t:r*Math.pow(2,-10*(a-=1))*Math.sin((a*s-o)*bi/h)*.5+l+t},easeInOutExpo:(a,t,e,s)=>a===0?t:a===s?t+e:(a/=s/2)<1?e/2*2**(10*(a-1))+t:e/2*-(2**(-10*--a)+2)+t,easeInOutQuad:(a,t,e,s)=>(a/=s/2)<1?e/2*a**2+t:-e/2*(--a*(a-2)-1)+t,easeInOutQuart:(a,t,e,s)=>(a/=s/2)<1?e/2*a**4+t:-e/2*((a-=2)*a**3-2)+t,easeInOutQuint:(a,t,e,s)=>(a/=s/2)<1?e/2*a**5+t:e/2*((a-2)**5+2)+t,easeInOutSine:(a,t,e,s)=>-e/2*(Math.cos(Math.PI*a/s)-1)+t,easeInQuad:(a,t,e,s)=>e*(a/=s)*a+t,easeInQuart:(a,t,e,s)=>e*(a/=s)*a**3+t,easeInQuint:(a,t,e,s)=>e*(a/s)**5+t,easeInSine:(a,t,e,s)=>-e*Math.cos(a/s*ln)+e+t,easeOutBack:function(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1.70158;return e*((a=a/s-1)*a*((i+1)*a+i)+1)+t},easeOutBounce:Wu,easeOutCirc:(a,t,e,s)=>e*Math.sqrt(1-(a=a/s-1)*a)+t,easeOutCubic:(a,t,e,s)=>e*((a/s-1)**3+1)+t,easeOutElastic:(a,t,e,s)=>{const i=e;let n=0;if(a===0)return t;if((a/=s)===1)return t+e;n||(n=.3*s);const{a:r,s:o,p:h,c:l}=Hu(i,e,n,1.70158);return r*2**(-10*a)*Math.sin((a*s-o)*bi/h)+l+t},easeOutExpo:(a,t,e,s)=>a===s?t+e:e*-(2**(-10*a/s)+1)+t,easeOutQuad:(a,t,e,s)=>-e*(a/=s)*(a-2)+t,easeOutQuart:(a,t,e,s)=>-e*((a=a/s-1)*a**3-1)+t,easeOutQuint:(a,t,e,s)=>e*((a/s-1)**5+1)+t,easeOutSine:(a,t,e,s)=>e*Math.sin(a/s*ln)+t});const ty=()=>!1;class zu{constructor(t){let{startValue:e,byValue:s,duration:i=500,delay:n=0,easing:r=Yp,onStart:o=Kn,onChange:h=Kn,onComplete:l=Kn,abort:d=ty,target:u}=t;A(this,"_state","pending"),A(this,"durationProgress",0),A(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=n,this.easing=r,this._onStart=o,this._onChange=h,this._onComplete=l,this._abort=d,this.target=u,this.startValue=e,this.byValue=s,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>$a(t),this.delay):$a(t)}tick(t){const e=(t||+new Date)-this.startTime,s=Math.min(e,this.duration);this.durationProgress=s/this.duration;const{value:i,valueProgress:n}=this.calculate(s);this.value=Object.freeze(i),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),$a(this.tick)))}register(){rc.push(this)}unregister(){rc.remove(this)}abort(){this._state="aborted",this.unregister()}}const ey=["startValue","endValue"];class sy extends zu{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(T(T({},wt(t,ey)),{},{startValue:e,byValue:s-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const iy=["startValue","endValue"];class ny extends zu{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(T(T({},wt(t,iy)),{},{startValue:e,byValue:s.map((i,n)=>i-e[n])}))}calculate(t){const e=this.startValue.map((s,i)=>this.easing(t,s,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const ry=["startValue","endValue","easing","onChange","onComplete","abort"],oy=(a,t,e,s)=>t+e*(1-Math.cos(a/s*ln)),Xu=a=>a&&((t,e,s)=>a(new ut(t).toRgba(),e,s));class ay extends zu{constructor(t){let{startValue:e,endValue:s,easing:i=oy,onChange:n,onComplete:r,abort:o}=t,h=wt(t,ry);const l=new ut(e).getSource(),d=new ut(s).getSource();super(T(T({},h),{},{startValue:l,byValue:d.map((u,g)=>u-l[g]),easing:i,onChange:Xu(n),onComplete:Xu(r),abort:Xu(o)}))}calculate(t){const[e,s,i,n]=this.startValue.map((o,h)=>this.easing(t,o,this.byValue[h],this.duration,h)),r=[...[e,s,i].map(Math.round),sr(0,n,1)];return{value:r,valueProgress:r.map((o,h)=>this.byValue[h]!==0?Math.abs((o-this.startValue[h])/this.byValue[h]):0).find(o=>o!==0)||0}}}function Vu(a){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(a)?new ny(a):new sy(a);return t.start(),t}function qp(a){const t=new ay(a);return t.start(),t}class At{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return this.points=this.points.concat(e.filter(i=>!this.includes(i))),this}static isPointContained(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(s))return t.eq(e);if(e.x===s.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,s.y)&&t.y<=Math.max(e.y,s.y));if(e.y===s.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,s.x)&&t.x<=Math.max(e.x,s.x));{const n=fc(e,s),r=fc(e,t).divide(n);return i?Math.abs(r.x)===Math.abs(r.y):r.x===r.y&&r.x>=0&&r.x<=1}}static isPointInPolygon(t,e){const s=new D(t).setX(Math.min(t.x-1,...e.map(n=>n.x)));let i=0;for(let n=0;n<e.length;n++){const r=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,s);if(r.includes(t))return!0;i+=+(r.status==="Intersection")}return i%2==1}static intersectLineLine(t,e,s,i){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],r=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const o=e.x-t.x,h=e.y-t.y,l=i.x-s.x,d=i.y-s.y,u=t.x-s.x,g=t.y-s.y,f=l*g-d*u,p=o*g-h*u,m=d*o-l*h;if(m!==0){const _=f/m,y=p/m;return(n||0<=_&&_<=1)&&(r||0<=y&&y<=1)?new At("Intersection").append(new D(t.x+_*o,t.y+_*h)):new At}if(f===0||p===0){const _=n||r||At.isPointContained(t,s,i)||At.isPointContained(e,s,i)||At.isPointContained(s,t,e)||At.isPointContained(i,t,e);return new At(_?"Coincident":void 0)}return new At("Parallel")}static intersectSegmentLine(t,e,s,i){return At.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return At.intersectLineLine(t,e,s,i,!1,!1)}static intersectLinePolygon(t,e,s){let i=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new At,r=s.length;for(let o,h,l,d=0;d<r;d++){if(o=s[d],h=s[(d+1)%r],l=At.intersectLineLine(t,e,o,h,i,!1),l.status==="Coincident")return l;n.append(...l.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,s){return At.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new At,i=t.length,n=[];for(let r=0;r<i;r++){const o=t[r],h=t[(r+1)%i],l=At.intersectSegmentPolygon(o,h,e);l.status==="Coincident"?(n.push(l),s.append(o,h)):s.append(...l.points)}return n.length>0&&n.length===t.length?new At("Coincident"):(s.points.length>0&&(s.status="Intersection"),s)}static intersectPolygonRectangle(t,e,s){const i=e.min(s),n=e.max(s),r=new D(n.x,i.y),o=new D(i.x,n.y);return At.intersectPolygonPolygon(t,[i,r,n,o])}}class hy extends hp{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?ce(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=ce(t,Ie(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new D(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,s)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:s,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,s,i];if(this.group){const r=this.group.calcTransformMatrix();return n.map(o=>ce(o,r))}return n}intersectsWithRect(t,e){return At.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=At.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:s,top:i,width:n,height:r}=this.getBoundingRect();return s>=t.x&&s+n<=e.x&&i>=t.y&&i+r<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return At.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(s=>s.x<=e.x&&s.x>=t.x&&s.y<=e.y&&s.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(s=>(s.x>=e.x||s.x<=t.x)&&(s.y>=e.y||s.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Gs(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Se,t),this._set(Ve,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?un(up(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||we.concat()}calcACoords(){const t=Eo({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=To(e,s),n=Rt(i,t),r=this._getTransformedDimensions(),o=r.x/2,h=r.y/2;return{tl:ce({x:-o,y:-h},n),tr:ce({x:o,y:-h},n),bl:ce({x:-o,y:h},n),br:ce({x:o,y:h},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Nt(this.originX),Nt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const s=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((n,r)=>n===s[r])?i.value:(this.group&&(e=Rt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:s,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const s=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:s.x,translateY:s.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=fp(i);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new D(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=T({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),s=e.strokeWidth;let i=s,n=0;this.strokeUniform&&(i=0,n=s);const r=e.width+i,o=e.height+i;let h;return h=e.skewX===0&&e.skewY===0?new D(r*e.scaleX,o*e.scaleY):dc(r,o,Ka(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,n){let r=t.x,o=t.y;const h=Nt(i)-Nt(e),l=Nt(n)-Nt(s);if(h||l){const d=this._getTransformedDimensions();r+=h*d.x,o+=l*d.y}return new D(r,o)}translateToCenterPoint(t,e,s){if(e===Q&&s===Q)return t;const i=this.translateToGivenOrigin(t,e,s,Q,Q);return this.angle?i.rotate(Ot(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,Q,Q,e,s);return this.angle?i.rotate(Ot(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ce(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new D(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,s){const i=this.translateToCenterPoint(t,e,s),n=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),lt,Le)}}const ly=["type"],cy=["extraParam"];let _i=class Nd extends hy{static getDefaults(){return Nd.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){super(),A(this,"_cacheContext",null),Object.assign(this,Nd.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ns(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=at.maxCacheSideLimit,n=at.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=at.perfLimitSizeTotal)return e<n&&(t.width=n),s<n&&(t.height=n),t;const r=e/s,[o,h]=Ua.limitDimsByArea(r),l=sr(n,o,i),d=sr(n,h,i);return e>l&&(t.zoomX/=e/l,t.width=l,t.capped=!0),s>d&&(t.zoomY/=s/d,t.height=d,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),s=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:s+2,height:i+2,zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=at.minCacheSideLimit,n=s.width,r=s.height,o=s.zoomX,h=s.zoomY,l=n!==t.width||r!==t.height,d=this.zoomX!==o||this.zoomY!==h;if(!t||!e)return!1;let u,g,f=l||d,p=0,m=0,_=!1;if(l){const y=this._cacheCanvas.width,x=this._cacheCanvas.height,S=n>y||r>x;_=S||(n<.9*y||r<.9*x)&&y>i&&x>i,S&&!s.capped&&(n>i||r>i)&&(p=.1*n,m=.1*r)}return wp(this)&&this.path&&(f=!0,_=!0,p+=this.getHeightOfLine(0)*this.zoomX,m+=this.getHeightOfLine(0)*this.zoomY),!!f&&(_?(t.width=Math.ceil(n+p),t.height=Math.ceil(r+m)):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height)),u=s.x/2,g=s.y/2,this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-g)+g,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(o,h),this.zoomX=o,this.zoomY=h,!0)}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,s=this.calcTransformMatrix(!e);t.transform(s[0],s[1],s[2],s[3],s[4],s[5])}getObjectScaling(){if(!this.group)return new D(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Jn(this.calcTransformMatrix());return new D(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),s=this.getCanvasRetinaScaling();return t.scalarMultiply(e*s)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==Se&&t!==Ve||(e=this._constrainScale(e)),t===Se&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof vi||(e=new vi(e));const s=this[t]!==e;return this[t]=e,s&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||s&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:n}=this,{width:r,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:n,width:r,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===Ce&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.parent||!this.parent.isOnACache()),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,s){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0),t.restore()}drawObject(t,e,s){const i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,s),this.fill=i,this.stroke=n}createClipPathLayer(t,e){const s=_s(e),i=s.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=s,e.parentClipPaths.forEach(n=>{n.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ie(this.calcTransformMatrix());i.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(i),t.drawObject(i,!0,e),s}_drawClipPath(t,e,s){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,s);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,s=this._cacheContext;return!(!e||!s||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&s&&!t&&(s.save(),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),s.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const s=e.stroke;s&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,rs(s)?s.gradientUnits==="percentage"||s.gradientTransform||s.patternTransform?this._applyPatternForTransformedGradient(t,s):(t.strokeStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:s}=e;s&&(rs(s)?(t.fillStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.fillStyle=s)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&(1&e.length&&e.push(...e),t.setLineDash(e))}_setShadow(t){if(!this.shadow)return;const e=this.shadow,s=this.canvas,i=this.getCanvasRetinaScaling(),[n,,,r]=(s==null?void 0:s.viewportTransform)||we,o=n*i,h=r*i,l=e.nonScaling?new D(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*at.browserShadowBlurConstant*(o+h)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*o*l.x,t.shadowOffsetY=e.offsetY*h*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!rs(e))return{offsetX:0,offsetY:0};const s=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,i,n):t.transform(1,0,0,1,i,n),s&&t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),{offsetX:i,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===Ce?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var s;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),r=i.x/this.scaleX/n,o=i.y/this.scaleY/n,h=_s({width:Math.ceil(r),height:Math.ceil(o)}),l=h.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(r,0),l.lineTo(r,o),l.lineTo(0,o),l.closePath(),l.translate(r/2,o/2),l.scale(i.zoomX/this.scaleX/n,i.zoomY/this.scaleY/n),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/i.zoomX,n*this.scaleY/i.zoomY),t.strokeStyle=(s=l.createPattern(h,"no-repeat"))!==null&&s!==void 0?s:"")}_findCenterFromElement(){return new D(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(N.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Du(this),s=this.group,i=this.shadow,n=Math.abs,r=t.enableRetinaScaling?ip():1,o=(t.multiplier||1)*r,h=t.canvasProvider||(x=>new eh(x,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Mp(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Pu(this,this.getViewportTransform()),this.setCoords();const l=ns(),d=this.getBoundingRect(),u=this.shadow,g=new D;if(u){const x=u.blur,S=u.nonScaling?new D(1,1):this.getObjectScaling();g.x=2*Math.round(n(u.offsetX)+x)*n(S.x),g.y=2*Math.round(n(u.offsetY)+x)*n(S.y)}const f=d.width+g.x,p=d.height+g.y;l.width=Math.ceil(f),l.height=Math.ceil(p);const m=h(l);t.format==="jpeg"&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new D(m.width/2,m.height/2),Q,Q);const _=this.canvas;m._objects=[this],this.set("canvas",m),this.setCoords();const y=m.toCanvasElement(o||1,t);return this.set("canvas",_),this.shadow=i,s&&(this.group=s),this.set(e),this.setCoords(),m._objects=[],m.destroy(),y}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Su(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:s,originY:i}=this;if(e){const{x:n,y:r}=this.getRelativeCenterPoint();this.originX=Q,this.originY=Q,this.left=n,this.top=r}if(this.set("angle",t),e){const{x:n,y:r}=this.translateToOriginPoint(this.getRelativeCenterPoint(),s,i);this.left=n,this.top=r,this.originX=s,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){rc.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Vs().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((s,i)=>{let[n,r]=i;return s[n]=this._animate(n,r,e),s},{})}_animate(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=t.split("."),n=this.constructor.colorProperties.includes(i[i.length-1]),{abort:r,startValue:o,onChange:h,onComplete:l}=s,d=T(T({},s),{},{target:this,startValue:o??i.reduce((u,g)=>u[g],this),endValue:e,abort:r==null?void 0:r.bind(this),onChange:(u,g,f)=>{i.reduce((p,m,_)=>(_===i.length-1&&(p[m]=u),p[m]),this),h&&h(u,g,f)},onComplete:(u,g,f)=>{this.setCoords(),l&&l(u,g,f)}});return n?qp(d):Vu(d)}isDescendantOf(t){const{parent:e,group:s}=this;return e===t||s===t||!!e&&e.isDescendantOf(t)||!!s&&s!==e&&s.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),s=t.getAncestors();if(e.length===0&&s.length>0&&this===s[s.length-1])return{fork:[],otherFork:[t,...s.slice(0,s.length-1)],common:[this]};for(let i,n=0;n<e.length;n++){if(i=e[n],i===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let r=0;r<s.length;r++){if(this===s[r])return{fork:[],otherFork:[t,...s.slice(0,r)],common:[this,...e]};if(i===s[r])return{fork:[this,...e.slice(0,n)],otherFork:[t,...s.slice(0,r)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...s],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const s=e.common[0]||this.canvas;if(!s)return;const i=e.fork.pop(),n=e.otherFork.pop(),r=s._objects.indexOf(i),o=s._objects.indexOf(n);return r>-1&&r>o}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Nd.customProperties,this.constructor.customProperties||[]);let e;const s=at.NUM_FRACTION_DIGITS,{clipPath:i,fill:n,stroke:r,shadow:o,strokeDashArray:h,left:l,top:d,originX:u,originY:g,width:f,height:p,strokeWidth:m,strokeLineCap:_,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:S,strokeMiterLimit:C,scaleX:E,scaleY:M,angle:k,flipX:O,flipY:P,opacity:F,visible:R,backgroundColor:W,fillRule:B,paintFirst:X,globalCompositeOperation:K,skewX:tt,skewY:V}=this;i&&!i.excludeFromExport&&(e=i.toObject(t.concat("inverted","absolutePositioned")));const H=Jt=>xt(Jt,s),Qt=T(T({},Zn(this,t)),{},{type:this.constructor.type,version:pu,originX:u,originY:g,left:H(l),top:H(d),width:H(f),height:H(p),fill:yp(n)?n.toObject():n,stroke:yp(r)?r.toObject():r,strokeWidth:H(m),strokeDashArray:h&&h.concat(),strokeLineCap:_,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:S,strokeMiterLimit:H(C),scaleX:H(E),scaleY:H(M),angle:H(k),flipX:O,flipY:P,opacity:H(F),shadow:o&&o.toObject(),visible:R,backgroundColor:W,fillRule:B,paintFirst:X,globalCompositeOperation:K,skewX:H(tt),skewY:H(V)},e?{clipPath:e}:null);return this.includeDefaultValues?Qt:this._removeDefaultValues(Qt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Tu(t,(i,n)=>{if(n===lt||n===Le||n==="type")return!0;const r=s[n];return i!==r&&!(Array.isArray(i)&&Array.isArray(r)&&i.length===0&&r.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=wt(t,ly),s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:i}=s,n=wt(s,cy);return Ja(e,n).then(r=>i?(delete r[i],new this(e[i],r)):new this(r))}static fromObject(t,e){return this._fromObject(t,e)}};A(_i,"stateProperties",Qv),A(_i,"cacheProperties",yi),A(_i,"ownDefaults",Jv),A(_i,"type","FabricObject"),A(_i,"colorProperties",[jt,Ce,"backgroundColor"]),A(_i,"customProperties",[]),N.setClass(_i),N.setClass(_i,"object");const Do=(a,t,e)=>(s,i,n,r)=>{const o=t(s,i,n,r);return o&&Dp(a,T(T({},Rp(s,i,n,r)),e)),o};function Po(a){return(t,e,s,i)=>{const{target:n,originX:r,originY:o}=e,h=n.getRelativeCenterPoint(),l=n.translateToOriginPoint(h,r,o),d=a(t,e,s,i);return n.setPositionByOrigin(l,e.originX,e.originY),d}}const $p=Do(qa,Po((a,t,e,s)=>{const i=Fu(t,t.originX,t.originY,e,s);if(Nt(t.originX)===Nt(Q)||Nt(t.originX)===Nt(Ft)&&i.x<0||Nt(t.originX)===Nt(lt)&&i.x>0){const{target:n}=t,r=n.strokeWidth/(n.strokeUniform?n.scaleX:1),o=Pp(t)?2:1,h=n.width,l=Math.abs(i.x*o/n.scaleX)-r;return n.set("width",Math.max(l,1)),h!==n.width}return!1}));function dy(a,t,e,s,i){s=s||{};const n=this.sizeX||s.cornerSize||i.cornerSize,r=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?Ce:jt,l=!o&&(s.cornerStrokeColor||i.cornerStrokeColor);let d,u=t,g=e;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",n>r?(d=n,a.scale(1,r/n),g=e*n/r):r>n?(d=r,a.scale(n/r,1),u=t*r/n):d=n,a.beginPath(),a.arc(u,g,d/2,0,bi,!1),a[h](),l&&a.stroke(),a.restore()}function uy(a,t,e,s,i){s=s||{};const n=this.sizeX||s.cornerSize||i.cornerSize,r=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?Ce:jt,l=!o&&(s.cornerStrokeColor||i.cornerStrokeColor),d=n/2,u=r/2;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",a.translate(t,e);const g=i.getTotalAngle();a.rotate(Ot(g)),a["".concat(h,"Rect")](-d,-u,n,r),l&&a.strokeRect(-d,-u,n,r),a.restore()}class Cs{constructor(t){A(this,"visible",!0),A(this,"actionName",ic),A(this,"angle",0),A(this,"x",0),A(this,"y",0),A(this,"offsetX",0),A(this,"offsetY",0),A(this,"sizeX",0),A(this,"sizeY",0),A(this,"touchSizeX",0),A(this,"touchSizeY",0),A(this,"cursorStyle","crosshair"),A(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,s,i){var n;let{tl:r,tr:o,br:h,bl:l}=i;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&At.isPointInPolygon(s,[r,o,h,l])}getActionHandler(t,e,s){return this.actionHandler}getMouseDownHandler(t,e,s){return this.mouseDownHandler}getMouseUpHandler(t,e,s){return this.mouseUpHandler}cursorStyleHandler(t,e,s){return e.cursorStyle}getActionName(t,e,s){return e.actionName}getVisibility(t,e){var s,i;return(s=(i=t._controlsVisibility)===null||i===void 0?void 0:i[e])!==null&&s!==void 0?s:this.visible}setVisibility(t,e,s){this.visible=t}positionHandler(t,e,s,i){return new D(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,n,r){const o=ac([To(s,i),Eo({angle:t}),hc((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new D(-.5,-.5).transform(o),tr:new D(.5,-.5).transform(o),br:new D(.5,.5).transform(o),bl:new D(-.5,.5).transform(o)}}render(t,e,s,i,n){((i=i||{}).cornerStyle||n.cornerStyle)==="circle"?dy.call(this,t,e,s,i,n):uy.call(this,t,e,s,i,n)}}const gy=(a,t,e)=>e.lockRotation?uc:t.cursorStyle,fy=Do(rp,Po((a,t,e,s)=>{let{target:i,ex:n,ey:r,theta:o,originX:h,originY:l}=t;const d=i.translateToOriginPoint(i.getRelativeCenterPoint(),h,l);if(xs(i,"lockRotation"))return!1;const u=Math.atan2(r-d.y,n-d.x),g=Math.atan2(s-d.y,e-d.x);let f=un(g-u+o);if(i.snapAngle&&i.snapAngle>0){const m=i.snapAngle,_=i.snapThreshold||m,y=Math.ceil(f/m)*m,x=Math.floor(f/m)*m;Math.abs(f-x)<_?f=x:Math.abs(f-y)<_&&(f=y)}f<0&&(f=360+f),f%=360;const p=i.angle!==f;return i.angle=f,p}));function Kp(a,t){const e=t.canvas,s=a[e.uniScaleKey];return e.uniformScaling&&!s||!e.uniformScaling&&s}function Qp(a,t,e){const s=xs(a,"lockScalingX"),i=xs(a,"lockScalingY");if(s&&i||!t&&(s||i)&&e||s&&t==="x"||i&&t==="y")return!0;const{width:n,height:r,strokeWidth:o}=a;return n===0&&o===0&&t!=="y"||r===0&&o===0&&t!=="x"}const py=["e","se","s","sw","w","nw","n","ne","e"],ih=(a,t,e)=>{const s=Kp(a,e);if(Qp(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return uc;const i=Lp(e,t);return"".concat(py[i],"-resize")};function Gu(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,r=i.by,o=Kp(a,n);let h,l,d,u,g,f;if(Qp(n,r,o))return!1;if(t.gestureScale)l=t.scaleX*t.gestureScale,d=t.scaleY*t.gestureScale;else{if(h=Fu(t,t.originX,t.originY,e,s),g=r!=="y"?Math.sign(h.x||t.signX||1):1,f=r!=="x"?Math.sign(h.y||t.signY||1):1,t.signX||(t.signX=g),t.signY||(t.signY=f),xs(n,"lockScalingFlip")&&(t.signX!==g||t.signY!==f))return!1;if(u=n._getTransformedDimensions(),o&&!r){const _=Math.abs(h.x)+Math.abs(h.y),{original:y}=t,x=_/(Math.abs(u.x*y.scaleX/n.scaleX)+Math.abs(u.y*y.scaleY/n.scaleY));l=y.scaleX*x,d=y.scaleY*x}else l=Math.abs(h.x*n.scaleX/u.x),d=Math.abs(h.y*n.scaleY/u.y);Pp(t)&&(l*=2,d*=2),t.signX!==g&&r!=="y"&&(t.originX=Fp(t.originX),l*=-1,t.signX=g),t.signY!==f&&r!=="x"&&(t.originY=Fp(t.originY),d*=-1,t.signY=f)}const p=n.scaleX,m=n.scaleY;return r?(r==="x"&&n.set(Se,l),r==="y"&&n.set(Ve,d)):(!xs(n,"lockScalingX")&&n.set(Se,l),!xs(n,"lockScalingY")&&n.set(Ve,d)),p!==n.scaleX||m!==n.scaleY}const vc=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s))),my=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s,{by:"x"}))),by=Do(ec,Po((a,t,e,s)=>Gu(a,t,e,s,{by:"y"}))),vy=["target","ex","ey","skewingSide"],Yu={x:{counterAxis:"y",scale:Se,skew:So,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Ve,skew:Co,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},yy=["ns","nesw","ew","nwse"],_y=(a,t,e)=>{if(t.x!==0&&xs(e,"lockSkewingY")||t.y!==0&&xs(e,"lockSkewingX"))return uc;const s=Lp(e,t)%4;return"".concat(yy[s],"-resize")};function Jp(a,t,e,s,i){const{target:n}=e,{counterAxis:r,origin:o,lockSkewing:h,skew:l,flip:d}=Yu[a];if(xs(n,h))return!1;const{origin:u,flip:g}=Yu[r],f=Nt(e[u])*(n[g]?-1:1),p=-Math.sign(f)*(n[d]?-1:1),m=.5*-((n[l]===0&&Fu(e,Q,Q,s,i)[a]>0||n[l]>0?1:-1)*p)+.5;return Do(op,Po((y,x,S,C)=>function(E,M,k){let{target:O,ex:P,ey:F,skewingSide:R}=M,W=wt(M,vy);const{skew:B}=Yu[E],X=k.subtract(new D(P,F)).divide(new D(O.scaleX,O.scaleY))[E],K=O[B],tt=W[B],V=Math.tan(Ot(tt)),H=E==="y"?O._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:O._getTransformedDimensions({scaleX:1,scaleY:1}).y,Qt=2*X*R/Math.max(H,1)+V,Jt=un(Math.atan(Qt));O.set(B,Jt);const le=K!==O[B];if(le&&E==="y"){const{skewX:zt,scaleX:_t}=O,Pe=O._getTransformedDimensions({skewY:K}),fi=O._getTransformedDimensions(),Pt=zt!==0?Pe.x/fi.x:1;Pt!==1&&O.set(Se,Pt*_t)}return le}(a,x,new D(S,C))))(t,T(T({},e),{},{[o]:m,skewingSide:p}),s,i)}const wy=(a,t,e,s)=>Jp("x",a,t,e,s),xy=(a,t,e,s)=>Jp("y",a,t,e,s);function yc(a,t){return a[t.canvas.altActionKey]}const _c=(a,t,e)=>{const s=yc(a,e);return t.x===0?s?So:Ve:t.y===0?s?Co:Se:""},Fo=(a,t,e)=>yc(a,e)?_y(0,t,e):ih(a,t,e),Zp=(a,t,e,s)=>yc(a,t.target)?xy(a,t,e,s):my(a,t,e,s),tm=(a,t,e,s)=>yc(a,t.target)?wy(a,t,e,s):by(a,t,e,s),em=()=>({ml:new Cs({x:-.5,y:0,cursorStyleHandler:Fo,actionHandler:Zp,getActionName:_c}),mr:new Cs({x:.5,y:0,cursorStyleHandler:Fo,actionHandler:Zp,getActionName:_c}),mb:new Cs({x:0,y:.5,cursorStyleHandler:Fo,actionHandler:tm,getActionName:_c}),mt:new Cs({x:0,y:-.5,cursorStyleHandler:Fo,actionHandler:tm,getActionName:_c}),tl:new Cs({x:-.5,y:-.5,cursorStyleHandler:ih,actionHandler:vc}),tr:new Cs({x:.5,y:-.5,cursorStyleHandler:ih,actionHandler:vc}),bl:new Cs({x:-.5,y:.5,cursorStyleHandler:ih,actionHandler:vc}),br:new Cs({x:.5,y:.5,cursorStyleHandler:ih,actionHandler:vc}),mtr:new Cs({x:0,y:-.5,actionHandler:fy,cursorStyleHandler:gy,offsetY:-40,withConnection:!0,actionName:_u})}),Sy=()=>({mr:new Cs({x:.5,y:0,actionHandler:$p,cursorStyleHandler:Fo,actionName:qa}),ml:new Cs({x:-.5,y:0,actionHandler:$p,cursorStyleHandler:Fo,actionName:qa})}),Cy=()=>T(T({},em()),Sy());class nh extends _i{static getDefaults(){return T(T({},super.getDefaults()),nh.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),nh.ownDefaults),this.setOptions(t)}static createControls(){return{controls:em()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,s=e.target,i=e.action;if(this===s&&i&&i.startsWith(ic))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const s=Object.entries(this.oCoords);for(let i=s.length-1;i>=0;i--){const[n,r]=s[i],o=this.controls[n];if(o.shouldActivate(n,this,t,e?r.touchCorner:r.corner))return this.__corner=n,{key:n,control:o,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),s=To(e.x,e.y),i=Eo({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Rt(s,i),r=Rt(t,n),o=Rt(r,[1/t[0],0,0,1/t[3],0,0]),h=this.group?Jn(this.calcTransformMatrix()):void 0;h&&(h.scaleX=Math.abs(h.scaleX),h.scaleY=Math.abs(h.scaleY));const l=this._calculateCurrentDimensions(h),d={};return this.forEachControl((u,g)=>{const f=u.positionHandler(l,o,this,u);d[g]=Object.assign(f,this._calcCornerCoords(u,f))}),d}_calcCornerCoords(t,e){const s=this.getTotalAngle();return{corner:t.calcCornerCoords(s,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(s,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(Ot(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-s.x/2,-s.y/2,s.x,s.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=T({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},s);t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:s,hasControls:i}=this,n=T({hasBorders:s,hasControls:i},e),r=this.getViewportTransform(),o=n.hasBorders,h=n.hasControls,l=Rt(r,this.calcTransformMatrix()),d=Jn(l);t.save(),t.translate(d.translateX,d.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(d.angle-=180),t.rotate(Ot(this.group?d.angle:this.angle)),o&&this.drawBorders(t,d,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const n=dc(this.width,this.height,Ka(e)),r=this.isStrokeAccountedForInDimensions()?xu:(this.strokeUniform?new D().scalarAdd(this.canvas?this.canvas.getZoom():1):new D(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=n.add(r).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,s)}drawControlsConnectingLines(t,e){let s=!1;t.beginPath(),this.forEachControl((i,n)=>{i.withConnection&&i.getVisibility(this,n)&&(s=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),s&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const s=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:n,cornerColor:r}=this,o=T({cornerStrokeColor:i,cornerDashArray:n,cornerColor:r},e);t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((h,l)=>{if(h.getVisibility(this,l)){const d=this.oCoords[l];h.render(t,d.x,d.y,o,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[s,i]=e;return this.setControlVisible(s,i)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const s=this.canvas.viewportTransform;e.save(),e.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this.transform(e);const i=this.width+4,n=this.height+4;return e.clearRect(-i/2,-n/2,i,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function sm(a,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{s!=="constructor"&&Object.defineProperty(a.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),a}A(nh,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class de extends nh{}sm(de,[Ip]),N.setClass(de),N.setClass(de,"object");const im=(a,t,e,s)=>{const i=2*(s=Math.round(s))+1,{data:n}=a.getImageData(t-s,e-s,i,i);for(let r=3;r<n.length;r+=4)if(n[r]>0)return!1;return!0};class nm{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new D(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new D(1/this.options.scaleX,1/this.options.scaleY):new D(1,1)}createSideVector(t,e){const s=fc(t,e);return this.options.strokeUniform?s.multiply(this.scale):s}projectOrthogonally(t,e,s){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,s)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new D(t);return e.y+=e.x*Math.tan(Ot(this.options.skewY)),e.x+=e.y*Math.tan(Ot(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ay=new D;class Ro extends nm{static getOrthogonalRotationFactor(t,e){const s=e?mc(t,e):Wp(t);return Math.abs(s)<ln?-1:1}constructor(t,e,s,i){super(i),A(this,"AB",void 0),A(this,"AC",void 0),A(this,"alpha",void 0),A(this,"bisector",void 0),this.A=new D(t),this.B=new D(e),this.C=new D(s),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=mc(this.AB,this.AC),this.bisector=bc(ju(this.AB.eq(Ay)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),n=Nu(i),r=Ro.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,s*r)}projectBevel(){const t=[];return(this.alpha%bi==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){const t=[],e=Math.abs(this.alpha),s=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*s),n=this.options.strokeUniform?pc(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return pc(i)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new D(Ro.getOrthogonalRotationFactor(this.bisector),Ro.getOrthogonalRotationFactor(new D(this.bisector.y,this.bisector.x)));return[new D(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new D(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(n=>{Bu(n,t,e)&&s.push(this.A.add(n))}),s}projectRoundWithSkew(t,e){const s=[],{skewX:i,skewY:n,scaleX:r,scaleY:o,strokeUniform:h}=this.options,l=new D(Math.tan(Ot(i)),Math.tan(Ot(n))),d=this.strokeProjectionMagnitude,u=h?d/o/Math.sqrt(1/o**2+1/r**2*l.y**2):d/Math.sqrt(1+l.y**2),g=new D(Math.sqrt(Math.max(d**2-u**2,0)),u),f=h?d/Math.sqrt(1+l.x**2*(1/o)**2/(1/r+1/r*l.x*l.y)**2):d/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),p=new D(f,Math.sqrt(Math.max(d**2-f**2,0)));return[p,p.scalarMultiply(-1),g,g.scalarMultiply(-1)].map(m=>this.applySkew(h?m.multiply(this.strokeUniformScalar):m)).forEach(m=>{Bu(m,t,e)&&s.push(this.applySkew(this.A).add(m))}),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%bi==0,s=this.applySkew(this.A),i=t[e?0:2].subtract(s),n=t[e?1:0].subtract(s),r=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=Oo(i,r)>0,h=o?i:n,l=o?n:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(h,l)):t.push(...this.projectRoundNoSkew(h,l)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class rm extends nm{constructor(t,e,s){super(s),this.A=new D(t),this.T=new D(e)}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(Nu(i),s)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new D(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Ro(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new D(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),s=this.scaleUnitVector(bc(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(s);t.push(i.add(e),i.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const om=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const s=[];if(a.length===0)return s;const i=a.reduce((n,r)=>(n[n.length-1].eq(r)||n.push(new D(r)),n),[new D(a[0])]);if(i.length===1)e=!0;else if(!e){const n=i[0],r=((o,h)=>{for(let l=o.length-1;l>=0;l--)if(h(o[l],l,o))return l;return-1})(i,o=>!o.eq(n));i.splice(r+1)}return i.forEach((n,r,o)=>{let h,l;r===0?(l=o[1],h=e?n:o[o.length-1]):r===o.length-1?(h=o[r-1],l=e?n:o[0]):(h=o[r-1],l=o[r+1]),e&&o.length===1?s.push(...new rm(n,n,t).project()):!e||r!==0&&r!==o.length-1?s.push(...new Ro(n,h,l,t).project()):s.push(...new rm(n,r===0?l:h,t).project())}),s},Uu=a=>{const t={};return Object.keys(a).forEach(e=>{t[e]={},Object.keys(a[e]).forEach(s=>{t[e][s]=T({},a[e][s])})}),t},am=a=>a.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),wc=a=>{const t=[];for(let e,s=0;s<a.length;s++)(e=Ty(a,s))!==!1&&t.push(e);return t},Ty=(a,t)=>{const e=a.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return a.charAt(t);if(55296<=e&&e<=56319){if(a.length<=t+1)throw"High surrogate without following low surrogate";const i=a.charCodeAt(t+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return a.charAt(t)+a.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const s=a.charCodeAt(t-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1};var Ey=Object.freeze({__proto__:null,capitalize:function(a){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return"".concat(a.charAt(0).toUpperCase()).concat(t?a.slice(1):a.slice(1).toLowerCase())},escapeXml:am,graphemeSplit:wc});const xc=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return a.fill!==t.fill||a.stroke!==t.stroke||a.strokeWidth!==t.strokeWidth||a.fontSize!==t.fontSize||a.fontFamily!==t.fontFamily||a.fontWeight!==t.fontWeight||a.fontStyle!==t.fontStyle||a.textBackgroundColor!==t.textBackgroundColor||a.deltaY!==t.deltaY||e&&(a.overline!==t.overline||a.underline!==t.underline||a.linethrough!==t.linethrough)},hm=(a,t)=>{const e=t.split(`
38
38
  `),s=[];let i=-1,n={};a=Uu(a);for(let r=0;r<e.length;r++){const o=wc(e[r]);if(a[r])for(let h=0;h<o.length;h++){i++;const l=a[r][h];l&&Object.keys(l).length>0&&(xc(n,l,!0)?s.push({start:i,end:i+1,style:l}):s[s.length-1].end++),n=l||{}}else i+=o.length,n={}}return s},lm=(a,t)=>{if(!Array.isArray(a))return Uu(a);const e=t.split(yu),s={};let i=-1,n=0;for(let r=0;r<e.length;r++){const o=wc(e[r]);for(let h=0;h<o.length;h++)i++,a[n]&&a[n].start<=i&&i<a[n].end&&(s[r]=s[r]||{},s[r][h]=T({},a[n].style),i===a[n].end-1&&n++)}return s},gn=["display","transform",jt,"fill-opacity","fill-rule","opacity",Ce,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function cm(a,t){const e=a.nodeName,s=a.getAttribute("class"),i=a.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let r;if(r=new RegExp("^"+e,"i"),t=t.replace(r,""),i&&t.length&&(r=new RegExp("#"+i+n,"i"),t=t.replace(r,"")),s&&t.length){const o=s.split(" ");for(let h=o.length;h--;)r=new RegExp("\\."+o[h]+n,"i"),t=t.replace(r,"")}return t.length===0}function ky(a,t){let e=!0;const s=cm(a,t.pop());return s&&t.length&&(e=function(i,n){let r,o=!0;for(;i.parentElement&&i.parentElement.nodeType===1&&n.length;)o&&(r=n.pop()),o=cm(i=i.parentElement,r);return n.length===0}(a,t)),s&&e&&t.length===0}const My=a=>{var t;return(t=Uv[a])!==null&&t!==void 0?t:a},Oy=new RegExp("(".concat(Ss,")"),"gi"),Dy=a=>a.replace(Oy," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var dm,um,gm,fm,pm,mm,bm;const Te="(".concat(Ss,")"),Py=String.raw(dm||(dm=hn(["(skewX)(",")"],["(skewX)\\(","\\)"])),Te),Fy=String.raw(um||(um=hn(["(skewY)(",")"],["(skewY)\\(","\\)"])),Te),Ry=String.raw(gm||(gm=hn(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Te,Te,Te),Ly=String.raw(fm||(fm=hn(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Te,Te),Iy=String.raw(pm||(pm=hn(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Te,Te),jy=String.raw(mm||(mm=hn(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Te,Te,Te,Te,Te,Te),qu="(?:".concat(jy,"|").concat(Iy,"|").concat(Ry,"|").concat(Ly,"|").concat(Py,"|").concat(Fy,")"),Ny="(?:".concat(qu,"*)"),By=String.raw(bm||(bm=hn(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Ny),Hy=new RegExp(By),Wy=new RegExp(qu),zy=new RegExp(qu,"g");function Sc(a){const t=[];if(!(a=Dy(a).replace(/\s*([()])\s*/gi,"$1"))||a&&!Hy.test(a))return[...we];for(const e of a.matchAll(zy)){const s=Wy.exec(e[0]);if(!s)continue;let i=we;const n=s.filter(p=>!!p),[,r,...o]=n,[h,l,d,u,g,f]=o.map(p=>parseFloat(p));switch(r){case"translate":i=To(h,l);break;case _u:i=Eo({angle:h},{x:l,y:d});break;case ic:i=hc(h,l);break;case So:i=Cu(h);break;case Co:i=Au(h);break;case"matrix":i=[h,l,d,u,g,f]}t.push(i)}return ac(t)}function Xy(a,t,e,s){const i=Array.isArray(t);let n,r=t;if(a!==jt&&a!==Ce||t!==xe){if(a==="strokeUniform")return t==="non-scaling-stroke";if(a==="strokeDashArray")r=t===xe?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(a==="transformMatrix")r=e&&e.transformMatrix?Rt(e.transformMatrix,Sc(t)):Sc(t);else if(a==="visible")r=t!==xe&&t!=="hidden",e&&e.visible===!1&&(r=!1);else if(a==="opacity")r=parseFloat(t),e&&e.opacity!==void 0&&(r*=e.opacity);else if(a==="textAnchor")r=t==="start"?lt:t==="end"?Ft:Q;else if(a==="charSpacing")n=Ae(t,s)/s*1e3;else if(a==="paintFirst"){const o=t.indexOf(jt),h=t.indexOf(Ce);r=jt,(o>-1&&h>-1&&h<o||o===-1&&h>-1)&&(r=Ce)}else{if(a==="href"||a==="xlink:href"||a==="font"||a==="id")return t;if(a==="imageSmoothing")return t==="optimizeQuality";n=i?t.map(Ae):Ae(t,s)}}else r="";return!i&&isNaN(n)?r:n}function Vy(a,t){const e=a.match(Yv);if(!e)return;const s=e[1],i=e[3],n=e[4],r=e[5],o=e[6];s&&(t.fontStyle=s),i&&(t.fontWeight=isNaN(parseFloat(i))?i:parseFloat(i)),n&&(t.fontSize=Ae(n)),o&&(t.fontFamily=o),r&&(t.lineHeight=r==="normal"?1:r)}function $u(a,t){a.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[s,i]=e.split(":");t[s.trim().toLowerCase()]=i.trim()})}function Gy(a){const t={},e=a.getAttribute("style");return e&&(typeof e=="string"?$u(e,t):function(s,i){Object.entries(s).forEach(n=>{let[r,o]=n;o!==void 0&&(i[r.toLowerCase()]=o)})}(e,t)),t}const Yy={stroke:"strokeOpacity",fill:"fillOpacity"};function wi(a,t,e){if(!a)return{};let s,i={},n=bu;a.parentNode&&Np.test(a.parentNode.nodeName)&&(i=wi(a.parentElement,t,e),i.fontSize&&(s=n=Ae(i.fontSize)));const r=T(T(T({},t.reduce((l,d)=>{const u=a.getAttribute(d);return u&&(l[d]=u),l},{})),function(l){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const g in d)ky(l,g.split(" "))&&(u=T(T({},u),d[g]));return u}(a,e)),Gy(a));r[Iu]&&a.setAttribute(Iu,r[Iu]),r[Lu]&&(s=Ae(r[Lu],n),r[Lu]="".concat(s));const o={};for(const l in r){const d=My(l),u=Xy(d,r[l],i,s);o[d]=u}o&&o.font&&Vy(o.font,o);const h=T(T({},i),o);return Np.test(a.nodeName)?h:function(l){const d=de.getDefaults();return Object.entries(Yy).forEach(u=>{let[g,f]=u;if(l[f]===void 0||l[g]==="")return;if(l[g]===void 0){if(!d[g])return;l[g]=d[g]}if(l[g].indexOf("url(")===0)return;const p=new ut(l[g]);l[g]=p.setAlpha(xt(p.getAlpha()*l[f],2)).toRgba()}),l}(h)}const Uy=["left","top","width","height","visible"],vm=["rx","ry"];class Ys extends de{static getDefaults(){return T(T({},super.getDefaults()),Ys.ownDefaults)}constructor(t){super(),Object.assign(this,Ys.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:s}=this,i=-e/2,n=-s/2,r=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,s/2):0,h=r!==0||o!==0;t.beginPath(),t.moveTo(i+r,n),t.lineTo(i+e-r,n),h&&t.bezierCurveTo(i+e-cn*r,n,i+e,n+cn*o,i+e,n+o),t.lineTo(i+e,n+s-o),h&&t.bezierCurveTo(i+e,n+s-cn*o,i+e-cn*r,n+s,i+e-r,n+s),t.lineTo(i+r,n+s),h&&t.bezierCurveTo(i+cn*r,n+s,i,n+s-cn*o,i,n+s-o),t.lineTo(i,n+o),h&&t.bezierCurveTo(i,n+cn*o,i+cn*r,n,i+r,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...vm,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(s,'" ry="').concat(i,'" width="').concat(t,'" height="').concat(e,`" />
39
39
  `)]}static async fromElement(t,e,s){const i=wi(t,this.ATTRIBUTE_NAMES,s),{left:n=0,top:r=0,width:o=0,height:h=0,visible:l=!0}=i,d=wt(i,Uy);return new this(T(T(T({},e),d),{},{left:n,top:r,width:o,height:h,visible:!!(l&&o&&h)}))}}A(Ys,"type","Rect"),A(Ys,"cacheProperties",[...yi,...vm]),A(Ys,"ownDefaults",{rx:0,ry:0}),A(Ys,"ATTRIBUTE_NAMES",[...gn,"x","y","rx","ry","width","height"]),N.setClass(Ys),N.setSVGClass(Ys);const xi="initialization",Cc="added",Ku="removed",Ac="imperative",ym=(a,t)=>{const{strokeUniform:e,strokeWidth:s,width:i,height:n,group:r}=t,o=r&&r!==a?sh(r.calcTransformMatrix(),a.calcTransformMatrix()):null,h=o?t.getRelativeCenterPoint().transform(o):t.getRelativeCenterPoint(),l=!t.isStrokeAccountedForInDimensions(),d=e&&l?Op(new D(s,s),void 0,a.calcTransformMatrix()):xu,u=!e&&l?s:0,g=dc(i+u,n+u,ac([o,t.calcOwnMatrix()],!0)).add(d).scalarDivide(2);return[h.subtract(g),h.add(g)]};class Tc{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===xi||e===Ac||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==xi&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===Ac&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:r,width:o,height:h}=Gs(t.map(u=>ym(i,u)).reduce((u,g)=>u.concat(g),[])),l=new D(o,h),d=new D(n,r).add(l.scalarDivide(2));if(s===xi){const u=this.getInitialSize(e,{size:l,center:d});return{center:d,relativeCorrection:new D(0,0),size:u}}return{center:d.transform(i.calcOwnMatrix()),size:l}}}A(Tc,"type","strategy");class Qu extends Tc{shouldPerformLayout(t){return!0}}A(Qu,"type","fit-content"),N.setClass(Qu);const qy=["strategy"],$y=["target","strategy","bubbles","prevStrategy"],_m="layoutManager";class rh{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Qu;A(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=T(T({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const s=this.getLayoutResult(e);s&&this.commitLayout(e,s),this.onAfterLayout(e,s),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:s}=e;return[nc,np,qa,rp,ec,op,sc,jv,Nv].map(i=>t.on(i,n=>this.performLayout(i===nc?{type:"object_modified",trigger:i,e:n,target:s}:{type:"object_modifying",trigger:i,e:n,target:s})))}subscribe(t,e){this.unsubscribe(t,e);const s=this.attachHandlers(t,e);this._subscriptions.set(t,s)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(s=>s()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){const{target:e,type:s}=t,{canvas:i}=e;if(s===xi||s===Cc?this.subscribeTargets(t):s===Ku&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),s===Ac&&t.deep){const n=wt(t,qy);e.forEachObject(r=>r.layoutManager&&r.layoutManager.performLayout(T(T({},n),{},{bubbles:!1,target:r})))}}getLayoutResult(t){const{target:e,strategy:s,type:i}=t,n=s.calcLayoutResult(t,e.getObjects());if(!n)return;const r=i===xi?new D:e.getRelativeCenterPoint(),{center:o,correction:h=new D,relativeCorrection:l=new D}=n,d=r.subtract(o).add(h).transform(i===xi?we:Ie(e.calcOwnMatrix()),!0).add(l);return{result:n,prevCenter:r,nextCenter:o,offset:d}}commitLayout(t,e){const{target:s}=t,{result:{size:i},nextCenter:n}=e;var r,o;s.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===xi?s.set({left:(r=t.x)!==null&&r!==void 0?r:n.x+i.x*Nt(s.originX),top:(o=t.y)!==null&&o!==void 0?o:n.y+i.y*Nt(s.originY)}):(s.setPositionByOrigin(n,Q,Q),s.setCoords(),s.set("dirty",!0))}layoutObjects(t,e){const{target:s}=t;s.forEachObject(i=>{i.group===s&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,s.clipPath)}layoutObject(t,e,s){let{offset:i}=e;s.set({left:s.left+i.x,top:s.top+i.y})}onAfterLayout(t,e){const{target:s,strategy:i,bubbles:n,prevStrategy:r}=t,o=wt(t,$y),{canvas:h}=s;s.fire("layout:after",{context:t,result:e}),h&&h.fire("object:layout:after",{context:t,result:e,target:s});const l=s.parent;n&&l!=null&&l.layoutManager&&((o.path||(o.path=[])).push(s),l.layoutManager.performLayout(T(T({},o),{},{target:l}))),s.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(s=>s())),t.clear()}toObject(){return{type:_m,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}N.setClass(rh,_m);const Ky=["type","objects","layoutManager"];class Qy extends rh{performLayout(){}}class Us extends ap(de){static getDefaults(){return T(T({},super.getDefaults()),Us.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),A(this,"_activeObjects",[]),A(this,"__objectSelectionTracker",void 0),A(this,"__objectSelectionDisposer",void 0),Object.assign(this,Us.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var s;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(i=>{this.enterGroup(i,!1)}),this.layoutManager=(s=e.layoutManager)!==null&&s!==void 0?s:new rh,this.layoutManager.performLayout({type:xi,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(mi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(mi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,s,i)=>this.canEnterGroup(e)&&i.indexOf(e)===s)}add(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];const i=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...i);return this._onAfterObjectsChange(Cc,i),n}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const n=this._filterObjectsBeforeEnteringGroup(s),r=super.insertAt(t,...n);return this._onAfterObjectsChange(Cc,n),r}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Ku,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const s=this[t];return super._set(t,e),t==="canvas"&&s!==e&&(this._objects||[]).forEach(i=>{i._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:s}=e;const i=this._activeObjects;if(t)i.push(s),this._set("dirty",!0);else if(i.length>0){const n=i.indexOf(s);n>-1&&(i.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Mo(t,Rt(Ie(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const s=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();s&&(s===t||t.isDescendantOf(s))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Mo(t,Rt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const s=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;s>-1&&this._activeObjects.splice(s,1)}shouldCache(){const t=de.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,s){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var i;const r=this._objects[n];(i=this.canvas)!==null&&i!==void 0&&i.preserveObjectStacking&&r.group!==this?(t.save(),t.transform(...Ie(this.calcTransformMatrix())),r.render(t),t.restore()):r.group===this&&r.render(t)}this._drawClipPath(t,this.clipPath,s)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(T({target:this,type:Ac},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const s=this.includeDefaultValues;return this._objects.filter(function(i){return!i.excludeFromExport}).map(function(i){const n=i.includeDefaultValues;i.includeDefaultValues=s;const r=i[t||"toObject"](e);return i.includeDefaultValues=n,r})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return T(T(T({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=Ys.prototype._toSVG.call(this),s=e.indexOf("COMMON_PARTS");e[s]='for="group" ';const i=e.join("");return t?t(i):i}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
40
40
  `],s=this._createSVGBgRect(t);s&&e.push(" ",s);for(let i=0;i<this._objects.length;i++)e.push(" ",this._objects[i].toSVG(t));return e.push(`</g>
@@ -506,4 +506,4 @@ void main() {
506
506
  `),position:m,pageIndex:_-1,rect:d.slice(0),rotation:u,id:g,deleted:!1,popupRef:f}}const r=await super.deserialize(e,s,i);return b(r,Ze,e.fontSize),b(r,Is,z.makeHexColor(...e.color)),b(r,Je,v(o=vt,qi,Ff).call(o,e.value)),r.annotationElementId=e.id||null,r._initialData=n,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=vt._internalPadding*this.parentScale,i=this.getRect(s,s),n=gt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:c(this,Is)),r={annotationType:Z.FREETEXT,color:n,fontSize:c(this,Ze),value:v(this,Ht,qb).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!v(this,Ht,$b).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${c(this,Ze)}px * var(--scale-factor))`,i.color=c(this,Is),s.replaceChildren();for(const r of c(this,Je).split(`
507
507
  `)){const o=document.createElement("div");o.append(r?document.createTextNode(r):document.createElement("br")),s.append(o)}const n=vt._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:c(this,Je)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Is=new WeakMap,Je=new WeakMap,_l=new WeakMap,Zr=new WeakMap,Ze=new WeakMap,Ht=new WeakSet,Gb=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-c(this,Ze))*this.parentScale),b(this,Ze,n),v(this,Ht,tu).call(this)},i=c(this,Ze);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Yb=function(e){const s=n=>{b(this,Is,this.editorDiv.style.color=n)},i=c(this,Is);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Ub=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(v(i=vt,qi,eu).call(i,n)),s=n);return e.join(`
508
508
  `)},tu=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:r}=this,o=r.style.display,h=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",n.div.append(this.div),i=r.getBoundingClientRect(),r.remove(),r.style.display=o,r.classList.toggle("hidden",h)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},qi=new WeakSet,eu=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(md,"")},su=function(){if(this.editorDiv.replaceChildren(),!!c(this,Je))for(const e of c(this,Je).split(`
509
- `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},qb=function(){return c(this,Je).replaceAll(" "," ")},Ff=function(e){return e.replaceAll(" "," ")},$b=function(e){const{value:s,fontSize:i,color:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,h)=>o!==n[h])||e.pageIndex!==r},w(vt,qi),q(vt,"_freeTextDefaultContent",""),q(vt,"_internalPadding",0),q(vt,"_defaultColor",null),q(vt,"_defaultFontSize",10),q(vt,"_type","freetext"),q(vt,"_editorType",Z.FREETEXT);let Ug=vt;class Z0{toSVGPath(){yt("Abstract method `toSVGPath` must be implemented.")}get box(){yt("Abstract getter `box` must be implemented.")}serialize(t,e){yt("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){yt("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){yt("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}const $i=class $i{constructor({x:t,y:e},s,i,n,r,o=0){w(this,qt);w(this,ts);w(this,js,[]);w(this,wa);w(this,xa);w(this,hi,[]);w(this,it,new Float64Array(18));w(this,to);w(this,eo);w(this,wl);w(this,xl);w(this,Sa);w(this,Ca);w(this,Bn,[]);b(this,ts,s),b(this,Ca,n*i),b(this,xa,r),c(this,it).set([NaN,NaN,NaN,NaN,t,e],6),b(this,wa,o),b(this,xl,c($i,Sl)*i),b(this,wl,c($i,jd)*i),b(this,Sa,i),c(this,Bn).push(t,e)}isEmpty(){return isNaN(c(this,it)[8])}add({x:t,y:e}){var P;b(this,to,t),b(this,eo,e);const[s,i,n,r]=c(this,ts);let[o,h,l,d]=c(this,it).subarray(8,12);const u=t-l,g=e-d,f=Math.hypot(u,g);if(f<c(this,wl))return!1;const p=f-c(this,xl),m=p/f,_=m*u,y=m*g;let x=o,S=h;o=l,h=d,l+=_,d+=y,(P=c(this,Bn))==null||P.push(t,e);const C=-y/p,E=_/p,M=C*c(this,Ca),k=E*c(this,Ca);return c(this,it).set(c(this,it).subarray(2,8),0),c(this,it).set([l+M,d+k],4),c(this,it).set(c(this,it).subarray(14,18),12),c(this,it).set([l-M,d-k],16),isNaN(c(this,it)[6])?(c(this,hi).length===0&&(c(this,it).set([o+M,h+k],2),c(this,hi).push(NaN,NaN,NaN,NaN,(o+M-s)/n,(h+k-i)/r),c(this,it).set([o-M,h-k],14),c(this,js).push(NaN,NaN,NaN,NaN,(o-M-s)/n,(h-k-i)/r)),c(this,it).set([x,S,o,h,l,d],6),!this.isEmpty()):(c(this,it).set([x,S,o,h,l,d],6),Math.abs(Math.atan2(S-h,x-o)-Math.atan2(y,_))<Math.PI/2?([o,h,l,d]=c(this,it).subarray(2,6),c(this,hi).push(NaN,NaN,NaN,NaN,((o+l)/2-s)/n,((h+d)/2-i)/r),[o,h,x,S]=c(this,it).subarray(14,18),c(this,js).push(NaN,NaN,NaN,NaN,((x+o)/2-s)/n,((S+h)/2-i)/r),!0):([x,S,o,h,l,d]=c(this,it).subarray(0,6),c(this,hi).push(((x+5*o)/6-s)/n,((S+5*h)/6-i)/r,((5*o+l)/6-s)/n,((5*h+d)/6-i)/r,((o+l)/2-s)/n,((h+d)/2-i)/r),[l,d,o,h,x,S]=c(this,it).subarray(12,18),c(this,js).push(((x+5*o)/6-s)/n,((S+5*h)/6-i)/r,((5*o+l)/6-s)/n,((5*h+d)/6-i)/r,((o+l)/2-s)/n,((h+d)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=c(this,hi),e=c(this,js);if(isNaN(c(this,it)[6])&&!this.isEmpty())return v(this,qt,Kb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);v(this,qt,Jb).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return v(this,qt,Qb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,r){return new tb(t,e,s,i,n,r)}getOutlines(){var u;const t=c(this,hi),e=c(this,js),s=c(this,it),[i,n,r,o]=c(this,ts),h=new Float64Array((((u=c(this,Bn))==null?void 0:u.length)??0)+2);for(let g=0,f=h.length-2;g<f;g+=2)h[g]=(c(this,Bn)[g]-i)/r,h[g+1]=(c(this,Bn)[g+1]-n)/o;if(h[h.length-2]=(c(this,to)-i)/r,h[h.length-1]=(c(this,eo)-n)/o,isNaN(s[6])&&!this.isEmpty())return v(this,qt,Zb).call(this,h);const l=new Float64Array(c(this,hi).length+24+c(this,js).length);let d=t.length;for(let g=0;g<d;g+=2){if(isNaN(t[g])){l[g]=l[g+1]=NaN;continue}l[g]=t[g],l[g+1]=t[g+1]}d=v(this,qt,ev).call(this,l,d);for(let g=e.length-6;g>=6;g-=6)for(let f=0;f<6;f+=2){if(isNaN(e[g+f])){l[d]=l[d+1]=NaN,d+=2;continue}l[d]=e[g+f],l[d+1]=e[g+f+1],d+=2}return v(this,qt,tv).call(this,l,d),this.newFreeDrawOutline(l,h,c(this,ts),c(this,Sa),c(this,wa),c(this,xa))}};ts=new WeakMap,js=new WeakMap,wa=new WeakMap,xa=new WeakMap,hi=new WeakMap,it=new WeakMap,to=new WeakMap,eo=new WeakMap,wl=new WeakMap,xl=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,Bn=new WeakMap,Sl=new WeakMap,Id=new WeakMap,jd=new WeakMap,qt=new WeakSet,Yl=function(){const t=c(this,it).subarray(4,6),e=c(this,it).subarray(16,18),[s,i,n,r]=c(this,ts);return[(c(this,to)+(t[0]-e[0])/2-s)/n,(c(this,eo)+(t[1]-e[1])/2-i)/r,(c(this,to)+(e[0]-t[0])/2-s)/n,(c(this,eo)+(e[1]-t[1])/2-i)/r]},Kb=function(){const[t,e,s,i]=c(this,ts),[n,r,o,h]=v(this,qt,Yl).call(this);return`M${(c(this,it)[2]-t)/s} ${(c(this,it)[3]-e)/i} L${(c(this,it)[4]-t)/s} ${(c(this,it)[5]-e)/i} L${n} ${r} L${o} ${h} L${(c(this,it)[16]-t)/s} ${(c(this,it)[17]-e)/i} L${(c(this,it)[14]-t)/s} ${(c(this,it)[15]-e)/i} Z`},Qb=function(t){const e=c(this,js);t.push(`L${e[4]} ${e[5]} Z`)},Jb=function(t){const[e,s,i,n]=c(this,ts),r=c(this,it).subarray(4,6),o=c(this,it).subarray(16,18),[h,l,d,u]=v(this,qt,Yl).call(this);t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${h} ${l} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},Zb=function(t){const e=c(this,it),[s,i,n,r]=c(this,ts),[o,h,l,d]=v(this,qt,Yl).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(u,t,c(this,ts),c(this,Sa),c(this,wa),c(this,xa))},tv=function(t,e){const s=c(this,js);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},ev=function(t,e){const s=c(this,it).subarray(4,6),i=c(this,it).subarray(16,18),[n,r,o,h]=c(this,ts),[l,d,u,g]=v(this,qt,Yl).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-r)/h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,u,g,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-r)/h],e),e+=24},w($i,Sl,8),w($i,Id,2),w($i,jd,c($i,Sl)+c($i,Id));let bd=$i;class tb extends Z0{constructor(e,s,i,n,r,o){super();w(this,We);w(this,Aa);w(this,so,null);w(this,Ki);w(this,Cl);w(this,es);w(this,Al);w(this,It);b(this,It,e),b(this,es,s),b(this,Aa,i),b(this,Al,n),b(this,Ki,r),b(this,Cl,o),v(this,We,sv).call(this,o);const{x:h,y:l,width:d,height:u}=c(this,so);for(let g=0,f=e.length;g<f;g+=2)e[g]=(e[g]-h)/d,e[g+1]=(e[g+1]-l)/u;for(let g=0,f=s.length;g<f;g+=2)s[g]=(s[g]-h)/d,s[g+1]=(s[g+1]-l)/u}toSVGPath(){const e=[`M${c(this,It)[4]} ${c(this,It)[5]}`];for(let s=6,i=c(this,It).length;s<i;s+=6){if(isNaN(c(this,It)[s])){e.push(`L${c(this,It)[s+4]} ${c(this,It)[s+5]}`);continue}e.push(`C${c(this,It)[s]} ${c(this,It)[s+1]} ${c(this,It)[s+2]} ${c(this,It)[s+3]} ${c(this,It)[s+4]} ${c(this,It)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],r){const o=i-e,h=n-s;let l,d;switch(r){case 0:l=v(this,We,Ul).call(this,c(this,It),e,n,o,-h),d=v(this,We,Ul).call(this,c(this,es),e,n,o,-h);break;case 90:l=v(this,We,ql).call(this,c(this,It),e,s,o,h),d=v(this,We,ql).call(this,c(this,es),e,s,o,h);break;case 180:l=v(this,We,Ul).call(this,c(this,It),i,s,-o,h),d=v(this,We,Ul).call(this,c(this,es),i,s,-o,h);break;case 270:l=v(this,We,ql).call(this,c(this,It),i,n,-o,-h),d=v(this,We,ql).call(this,c(this,es),i,n,-o,-h);break}return{outline:Array.from(l),points:[Array.from(d)]}}get box(){return c(this,so)}newOutliner(e,s,i,n,r,o=0){return new bd(e,s,i,n,r,o)}getNewOutline(e,s){const{x:i,y:n,width:r,height:o}=c(this,so),[h,l,d,u]=c(this,Aa),g=r*d,f=o*u,p=i*d+h,m=n*u+l,_=this.newOutliner({x:c(this,es)[0]*g+p,y:c(this,es)[1]*f+m},c(this,Aa),c(this,Al),e,c(this,Cl),s??c(this,Ki));for(let y=2;y<c(this,es).length;y+=2)_.add({x:c(this,es)[y]*g+p,y:c(this,es)[y+1]*f+m});return _.getOutlines()}get mustRemoveSelfIntersections(){return!0}}Aa=new WeakMap,so=new WeakMap,Ki=new WeakMap,Cl=new WeakMap,es=new WeakMap,Al=new WeakMap,It=new WeakMap,We=new WeakSet,Ul=function(e,s,i,n,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h]*n,o[h+1]=i+e[h+1]*r;return o},ql=function(e,s,i,n,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h+1]*n,o[h+1]=i+e[h]*r;return o},sv=function(e){const s=c(this,It);let i=s[4],n=s[5],r=i,o=n,h=i,l=n,d=i,u=n;const g=e?Math.max:Math.min;for(let y=6,x=s.length;y<x;y+=6){if(isNaN(s[y]))r=Math.min(r,s[y+4]),o=Math.min(o,s[y+5]),h=Math.max(h,s[y+4]),l=Math.max(l,s[y+5]),u<s[y+5]?(d=s[y+4],u=s[y+5]):u===s[y+5]&&(d=g(d,s[y+4]));else{const S=z.bezierBoundingBox(i,n,...s.slice(y,y+6));r=Math.min(r,S[0]),o=Math.min(o,S[1]),h=Math.max(h,S[2]),l=Math.max(l,S[3]),u<S[3]?(d=S[2],u=S[3]):u===S[3]&&(d=g(d,S[2]))}i=s[y+4],n=s[y+5]}const f=r-c(this,Ki),p=o-c(this,Ki),m=h-r+2*c(this,Ki),_=l-o+2*c(this,Ki);b(this,so,{x:f,y:p,width:m,height:_,lastPoint:[d,u]})};class eb{constructor(t,e=0,s=0,i=!0){w(this,De);w(this,Tl);w(this,Hn,[]);w(this,Ns,[]);let n=1/0,r=-1/0,o=1/0,h=-1/0;const d=10**-4;for(const{x:y,y:x,width:S,height:C}of t){const E=Math.floor((y-e)/d)*d,M=Math.ceil((y+S+e)/d)*d,k=Math.floor((x-e)/d)*d,O=Math.ceil((x+C+e)/d)*d,P=[E,k,O,!0],F=[M,k,O,!1];c(this,Hn).push(P,F),n=Math.min(n,E),r=Math.max(r,M),o=Math.min(o,k),h=Math.max(h,O)}const u=r-n+2*s,g=h-o+2*s,f=n-s,p=o-s,m=c(this,Hn).at(i?-1:-2),_=[m[0],m[2]];for(const y of c(this,Hn)){const[x,S,C]=y;y[0]=(x-f)/u,y[1]=(S-p)/g,y[2]=(C-p)/g}b(this,Tl,{x:f,y:p,width:u,height:g,lastPoint:_})}getOutlines(){c(this,Hn).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of c(this,Hn))e[3]?(t.push(...v(this,De,Rf).call(this,e)),v(this,De,nv).call(this,e)):(v(this,De,rv).call(this,e),t.push(...v(this,De,Rf).call(this,e)));return v(this,De,iv).call(this,t)}}Tl=new WeakMap,Hn=new WeakMap,Ns=new WeakMap,De=new WeakSet,iv=function(t){const e=[],s=new Set;for(const r of t){const[o,h,l]=r;e.push([o,h,r],[o,l,r])}e.sort((r,o)=>r[1]-o[1]||r[0]-o[0]);for(let r=0,o=e.length;r<o;r+=2){const h=e[r][2],l=e[r+1][2];h.push(l),l.push(h),s.add(h),s.add(l)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[o,h,l,d,u]=r;s.delete(r);let g=o,f=h;for(n=[o,l],i.push(n);;){let p;if(s.has(d))p=d;else if(s.has(u))p=u;else break;s.delete(p),[o,h,l,d,u]=p,g!==o&&(n.push(g,f,o,f===h?h:l),g=o),f=f===h?l:h}n.push(g,f)}return new SS(i,c(this,Tl))},iu=function(t){const e=c(this,Ns);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1},nv=function([,t,e]){const s=v(this,De,iu).call(this,t);c(this,Ns).splice(s,0,[t,e])},rv=function([,t,e]){const s=v(this,De,iu).call(this,t);for(let i=s;i<c(this,Ns).length;i++){const[n,r]=c(this,Ns)[i];if(n!==t)break;if(n===t&&r===e){c(this,Ns).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=c(this,Ns)[i];if(n!==t)break;if(n===t&&r===e){c(this,Ns).splice(i,1);return}}},Rf=function(t){const[e,s,i]=t,n=[[e,s,i]],r=v(this,De,iu).call(this,i);for(let o=0;o<r;o++){const[h,l]=c(this,Ns)[o];for(let d=0,u=n.length;d<u;d++){const[,g,f]=n[d];if(!(l<=g||f<=h)){if(g>=h){if(f>l)n[d][1]=l;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=h,f>l&&n.push([e,l,f])}}}return n};class SS extends Z0{constructor(e,s){super();w(this,El);w(this,Ta);b(this,Ta,e),b(this,El,s)}toSVGPath(){const e=[];for(const s of c(this,Ta)){let[i,n]=s;e.push(`M${i} ${n}`);for(let r=2;r<s.length;r+=2){const o=s[r],h=s[r+1];o===i?(e.push(`V${h}`),n=h):h===n&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],r){const o=[],h=i-e,l=n-s;for(const d of c(this,Ta)){const u=new Array(d.length);for(let g=0;g<d.length;g+=2)u[g]=e+d[g]*h,u[g+1]=n-d[g+1]*l;o.push(u)}return o}get box(){return c(this,El)}get classNamesForDrawing(){return["highlight"]}get classNamesForOutlining(){return["highlightOutline"]}}El=new WeakMap,Ta=new WeakMap;class qg extends bd{newFreeDrawOutline(t,e,s,i,n,r){return new CS(t,e,s,i,n,r)}get classNamesForDrawing(){return["highlight","free"]}}class CS extends tb{get classNamesForDrawing(){return["highlight","free"]}get classNamesForOutlining(){return["highlightOutline","free"]}newOutliner(t,e,s,i,n,r=0){return new qg(t,e,s,i,n,r)}}const ze=class ze{constructor({editor:t=null,uiManager:e=null}){w(this,bt);w(this,Bs,null);w(this,io,null);w(this,Ea);w(this,$t,null);w(this,kl,!1);w(this,ka,!1);w(this,Ml,null);w(this,Ol);w(this,Wn,null);w(this,Hs,null);w(this,Ma);var s;t?(b(this,ka,!1),b(this,Ma,U.HIGHLIGHT_COLOR),b(this,Ml,t)):(b(this,ka,!0),b(this,Ma,U.HIGHLIGHT_DEFAULT_COLOR)),b(this,Hs,(t==null?void 0:t._uiManager)||e),b(this,Ol,c(this,Hs)._eventBus),b(this,Ea,(t==null?void 0:t.color)||((s=c(this,Hs))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),c(ze,Dl)||b(ze,Dl,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return ot(this,"_keyboardManager",new ph([[["Escape","mac+Escape"],ze.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ze.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ze.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ze.prototype._moveToPrevious],[["Home","mac+Home"],ze.prototype._moveToBeginning],[["End","mac+End"],ze.prototype._moveToEnd]]))}renderButton(){const t=b(this,Bs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=c(this,Hs)._signal;t.addEventListener("click",v(this,bt,yo).bind(this),{signal:e}),t.addEventListener("keydown",v(this,bt,jf).bind(this),{signal:e});const s=b(this,io,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=c(this,Ea),t.append(s),t}renderMainDropdown(){const t=b(this,$t,v(this,bt,Lf).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===c(this,Bs)){v(this,bt,yo).call(this,t);return}const e=t.target.getAttribute("data-color");e&&v(this,bt,If).call(this,e,t)}_moveToNext(t){var e,s;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}if(t.target===c(this,Bs)){(e=c(this,$t).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=c(this,$t))==null?void 0:e.firstChild)||t.target===c(this,Bs)){c(this,bt,$n)&&this._hideDropdownFromKeyboard();return}c(this,bt,$n)||v(this,bt,yo).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}(e=c(this,$t).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}(e=c(this,$t).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=c(this,$t))==null||t.classList.add("hidden"),(e=c(this,Wn))==null||e.abort(),b(this,Wn,null)}_hideDropdownFromKeyboard(){var t;if(!c(this,ka)){if(!c(this,bt,$n)){(t=c(this,Ml))==null||t.unselect();return}this.hideDropdown(),c(this,Bs).focus({preventScroll:!0,focusVisible:c(this,kl)})}}updateColor(t){if(c(this,io)&&(c(this,io).style.backgroundColor=t),!c(this,$t))return;const e=c(this,Hs).highlightColors.values();for(const s of c(this,$t).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=c(this,Bs))==null||t.remove(),b(this,Bs,null),b(this,io,null),(e=c(this,$t))==null||e.remove(),b(this,$t,null)}};Bs=new WeakMap,io=new WeakMap,Ea=new WeakMap,$t=new WeakMap,kl=new WeakMap,ka=new WeakMap,Ml=new WeakMap,Ol=new WeakMap,Wn=new WeakMap,Hs=new WeakMap,Ma=new WeakMap,Dl=new WeakMap,bt=new WeakSet,Lf=function(){const t=document.createElement("div"),e=c(this,Hs)._signal;t.addEventListener("contextmenu",hs,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of c(this,Hs).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",c(ze,Dl)[s]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===c(this,Ea)),n.addEventListener("click",v(this,bt,If).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",v(this,bt,jf).bind(this),{signal:e}),t},If=function(t,e){e.stopPropagation(),c(this,Ol).dispatch("switchannotationeditorparams",{source:this,type:c(this,Ma),value:t})},jf=function(t){ze._keyboardManager.exec(this,t)},yo=function(t){if(c(this,bt,$n)){this.hideDropdown();return}if(b(this,kl,t.detail===0),c(this,Wn)||(b(this,Wn,new AbortController),window.addEventListener("pointerdown",v(this,bt,ov).bind(this),{signal:c(this,Hs).combinedSignal(c(this,Wn))})),c(this,$t)){c(this,$t).classList.remove("hidden");return}const e=b(this,$t,v(this,bt,Lf).call(this));c(this,Bs).append(e)},ov=function(t){var e;(e=c(this,$t))!=null&&e.contains(t.target)||this.hideDropdown()},$n=function(){return c(this,$t)&&!c(this,$t).classList.contains("hidden")},w(ze,Dl,null);let vd=ze;const ht=class ht extends gt{constructor(e){super({...e,name:"highlightEditor"});w(this,J);w(this,Oa,null);w(this,Pl,0);w(this,Qi);w(this,no,null);w(this,Da,null);w(this,fs,null);w(this,Fl,null);w(this,Rl,0);w(this,ro,null);w(this,Ws,null);w(this,ve,null);w(this,Xe,!1);w(this,Pa,null);w(this,Ji);w(this,Kt,null);w(this,Fa,"");w(this,ps);w(this,Ll,"");this.color=e.color||ht._defaultColor,b(this,ps,e.thickness||ht._defaultThickness),b(this,Ji,e.opacity||ht._defaultOpacity),b(this,Qi,e.boxes||null),b(this,Ll,e.methodOfCreation||""),b(this,Fa,e.text||""),this._isDraggable=!1,e.highlightId>-1?(b(this,Xe,!0),v(this,J,nu).call(this,e),v(this,J,_o).call(this)):c(this,Qi)&&(b(this,Oa,e.anchorNode),b(this,Pl,e.anchorOffset),b(this,Fl,e.focusNode),b(this,Rl,e.focusOffset),v(this,J,Nf).call(this),v(this,J,_o).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=ht.prototype;return ot(this,"_keyboardManager",new ph([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:c(this,Xe)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:c(this,ps),methodOfCreation:c(this,Ll)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;gt.initialize(e,s),ht._defaultColor||(ht._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case U.HIGHLIGHT_DEFAULT_COLOR:ht._defaultColor=s;break;case U.HIGHLIGHT_THICKNESS:ht._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return c(this,Pa)}updateParams(e,s){switch(e){case U.HIGHLIGHT_COLOR:v(this,J,av).call(this,s);break;case U.HIGHLIGHT_THICKNESS:v(this,J,hv).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.HIGHLIGHT_DEFAULT_COLOR,ht._defaultColor],[U.HIGHLIGHT_THICKNESS,ht._defaultThickness]]}get propertiesToUpdate(){return[[U.HIGHLIGHT_COLOR,this.color||ht._defaultColor],[U.HIGHLIGHT_THICKNESS,c(this,ps)||ht._defaultThickness],[U.HIGHLIGHT_FREE,c(this,Xe)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(b(this,Da,new vd({editor:this})),e.addColorPicker(c(this,Da))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(v(this,J,$l).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,v(this,J,$l).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){v(this,J,Bf).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,J,_o).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?v(this,J,Bf).call(this):e&&(v(this,J,_o).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,r,o;const{drawLayer:s}=this.parent;let i;c(this,Xe)?(e=(e-this.rotation+360)%360,i=v(n=ht,ms,Ga).call(n,c(this,Ws).box,e)):i=v(r=ht,ms,Ga).call(r,this,e),s.rotate(c(this,ve),e),s.rotate(c(this,Kt),e),s.updateBox(c(this,ve),i),s.updateBox(c(this,Kt),v(o=ht,ms,Ga).call(o,c(this,fs).box,e))}render(){if(this.div)return this.div;const e=super.render();c(this,Fa)&&(e.setAttribute("aria-label",c(this,Fa)),e.setAttribute("role","mark")),c(this,Xe)?e.classList.add("free"):this.div.addEventListener("keydown",v(this,J,cv).bind(this),{signal:this._uiManager._signal});const s=b(this,ro,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=c(this,no);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),ld(this,c(this,ro),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(c(this,Kt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(c(this,Kt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:v(this,J,ru).call(this,!0);break;case 1:case 3:v(this,J,ru).call(this,!1);break}}select(){var e,s;super.select(),c(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(c(this,Kt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(c(this,Kt),"selected"))}unselect(){var e;super.unselect(),c(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(c(this,Kt),"selected"),c(this,Xe)||v(this,J,ru).call(this,!1))}get _mustFixPosition(){return!c(this,Xe)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(c(this,ve),e),this.parent.drawLayer.show(c(this,Kt),e))}static startHighlighting(e,s,{target:i,x:n,y:r}){const{x:o,y:h,width:l,height:d}=i.getBoundingClientRect(),u=new AbortController,g=e.combinedSignal(u),f=m=>{m.preventDefault(),m.stopPropagation()},p=m=>{u.abort(),v(this,ms,fv).call(this,e,m)};window.addEventListener("blur",p,{signal:g}),window.addEventListener("pointerup",p,{signal:g}),window.addEventListener("pointerdown",f,{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",hs,{signal:g}),i.addEventListener("pointermove",v(this,ms,gv).bind(this,e),{signal:g}),this._freeHighlight=new qg({x:n,y:r},[o,h,l,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(e,s,i){var m,_,y,x;let n=null;if(e instanceof Q0){const{data:{quadPoints:S,rect:C,rotation:E,id:M,color:k,opacity:O,popupRef:P},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:Z.HIGHLIGHT,color:Array.from(k),opacity:O,quadPoints:S,boxes:null,pageIndex:F-1,rect:C.slice(0),rotation:E,id:M,deleted:!1,popupRef:P}}else if(e instanceof Yg){const{data:{inkLists:S,rect:C,rotation:E,id:M,color:k,borderStyle:{rawWidth:O},popupRef:P},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:Z.HIGHLIGHT,color:Array.from(k),thickness:O,inkLists:S,boxes:null,pageIndex:F-1,rect:C.slice(0),rotation:E,id:M,deleted:!1,popupRef:P}}const{color:r,quadPoints:o,inkLists:h,opacity:l}=e,d=await super.deserialize(e,s,i);d.color=z.makeHexColor(...r),b(d,Ji,l||1),h&&b(d,ps,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,g]=d.pageDimensions,[f,p]=d.pageTranslation;if(o){const S=b(d,Qi,[]);for(let C=0;C<o.length;C+=8)S.push({x:(o[C]-f)/u,y:1-(o[C+1]-p)/g,width:(o[C+2]-o[C])/u,height:(o[C+1]-o[C+5])/g});v(m=d,J,Nf).call(m),v(_=d,J,_o).call(_),d.rotate(d.rotation)}else if(h){b(d,Xe,!0);const S=h[0],C={x:S[0]-f,y:g-(S[1]-p)},E=new qg(C,[0,0,u,g],1,c(d,ps)/2,!0,.001);for(let O=0,P=S.length;O<P;O+=2)C.x=S[O]-f,C.y=g-(S[O+1]-p),E.add(C);const{id:M,clipPathId:k}=s.drawLayer.draw(E,d.color,d._defaultOpacity,!0);v(y=d,J,nu).call(y,{highlightOutlines:E.getOutlines(),highlightId:M,clipPathId:k}),v(x=d,J,_o).call(x)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=gt._colorManager.convert(this.color),n={annotationType:Z.HIGHLIGHT,color:i,opacity:c(this,Ji),thickness:c(this,ps),quadPoints:v(this,J,dv).call(this),outlines:v(this,J,uv).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:v(this,J,$l).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!v(this,J,pv).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Oa=new WeakMap,Pl=new WeakMap,Qi=new WeakMap,no=new WeakMap,Da=new WeakMap,fs=new WeakMap,Fl=new WeakMap,Rl=new WeakMap,ro=new WeakMap,Ws=new WeakMap,ve=new WeakMap,Xe=new WeakMap,Pa=new WeakMap,Ji=new WeakMap,Kt=new WeakMap,Fa=new WeakMap,ps=new WeakMap,Ll=new WeakMap,J=new WeakSet,Nf=function(){const e=new eb(c(this,Qi),.001);b(this,Ws,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=c(this,Ws).box;const s=new eb(c(this,Qi),.0025,.001,this._uiManager.direction==="ltr");b(this,fs,s.getOutlines());const{lastPoint:i}=c(this,fs).box;b(this,Pa,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},nu=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var u,g;if(b(this,Ws,e),b(this,fs,e.getNewOutline(c(this,ps)/2+1.5,.0025)),s>=0)b(this,ve,s),b(this,no,i),this.parent.drawLayer.finalizeLine(s,e),b(this,Kt,this.parent.drawLayer.drawOutline(c(this,fs)));else if(this.parent){const f=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(c(this,ve),e),this.parent.drawLayer.updateBox(c(this,ve),v(u=ht,ms,Ga).call(u,c(this,Ws).box,(f-this.rotation+360)%360)),this.parent.drawLayer.updateLine(c(this,Kt),c(this,fs)),this.parent.drawLayer.updateBox(c(this,Kt),v(g=ht,ms,Ga).call(g,c(this,fs).box,f))}const{x:r,y:o,width:h,height:l}=e.box;switch(this.rotation){case 0:this.x=r,this.y=o,this.width=h,this.height=l;break;case 90:{const[f,p]=this.parentDimensions;this.x=o,this.y=1-r,this.width=h*p/f,this.height=l*f/p;break}case 180:this.x=1-r,this.y=1-o,this.width=h,this.height=l;break;case 270:{const[f,p]=this.parentDimensions;this.x=1-o,this.y=r,this.width=h*p/f,this.height=l*f/p;break}}const{lastPoint:d}=c(this,fs).box;b(this,Pa,[(d[0]-r)/h,(d[1]-o)/l])},av=function(e){const s=(r,o)=>{var h,l,d;this.color=r,(h=this.parent)==null||h.drawLayer.changeColor(c(this,ve),r),(l=c(this,Da))==null||l.updateColor(r),b(this,Ji,o),(d=this.parent)==null||d.drawLayer.changeOpacity(c(this,ve),o)},i=this.color,n=c(this,Ji);this.addCommands({cmd:s.bind(this,e,ht._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},hv=function(e){const s=c(this,ps),i=n=>{b(this,ps,n),v(this,J,lv).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},lv=function(e){if(!c(this,Xe))return;v(this,J,nu).call(this,{highlightOutlines:c(this,Ws).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Bf=function(){c(this,ve)===null||!this.parent||(this.parent.drawLayer.remove(c(this,ve)),b(this,ve,null),this.parent.drawLayer.remove(c(this,Kt)),b(this,Kt,null))},_o=function(e=this.parent){c(this,ve)===null&&({id:Fe(this,ve)._,clipPathId:Fe(this,no)._}=e.drawLayer.draw(c(this,Ws),this.color,c(this,Ji)),b(this,Kt,e.drawLayer.drawOutline(c(this,fs))),c(this,ro)&&(c(this,ro).style.clipPath=c(this,no)))},ms=new WeakSet,Ga=function({x:e,y:s,width:i,height:n},r){switch(r){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},cv=function(e){ht._keyboardManager.exec(this,e)},ru=function(e){if(!c(this,Oa))return;const s=window.getSelection();e?s.setPosition(c(this,Oa),c(this,Pl)):s.setPosition(c(this,Fl),c(this,Rl))},$l=function(){return c(this,Xe)?this.rotation:0},dv=function(){if(c(this,Xe))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,r=c(this,Qi),o=new Float32Array(r.length*8);let h=0;for(const{x:l,y:d,width:u,height:g}of r){const f=l*e+i,p=(1-d-g)*s+n;o[h]=o[h+4]=f,o[h+1]=o[h+3]=p,o[h+2]=o[h+6]=f+u*e,o[h+5]=o[h+7]=p+g*s,h+=8}return o},uv=function(e){return c(this,Ws).serialize(e,v(this,J,$l).call(this))},gv=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},fv=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},pv=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},w(ht,ms),q(ht,"_defaultColor",null),q(ht,"_defaultOpacity",1),q(ht,"_defaultThickness",12),q(ht,"_type","highlight"),q(ht,"_editorType",Z.HIGHLIGHT),q(ht,"_freeHighlightId",-1),q(ht,"_freeHighlight",null),q(ht,"_freeHighlightClipId","");let yd=ht;const kt=class kt extends gt{constructor(e){super({...e,name:"inkEditor"});w(this,L);w(this,oo,0);w(this,ao,0);w(this,li,null);w(this,Zi,new Path2D);w(this,bs,!1);w(this,ho,null);w(this,lo,!1);w(this,co,!1);w(this,tn,null);w(this,Ra,null);w(this,uo,0);w(this,go,0);w(this,zn,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){gt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case U.INK_THICKNESS:kt._defaultThickness=s;break;case U.INK_COLOR:kt._defaultColor=s;break;case U.INK_OPACITY:kt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case U.INK_THICKNESS:v(this,L,mv).call(this,s);break;case U.INK_COLOR:v(this,L,bv).call(this,s);break;case U.INK_OPACITY:v(this,L,vv).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.INK_THICKNESS,kt._defaultThickness],[U.INK_COLOR,kt._defaultColor||gt._defaultLineColor],[U.INK_OPACITY,Math.round(kt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[U.INK_THICKNESS,this.thickness||kt._defaultThickness],[U.INK_COLOR,this.color||kt._defaultColor||gt._defaultLineColor],[U.INK_OPACITY,Math.round(100*(this.opacity??kt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(v(this,L,ou).call(this),v(this,L,au).call(this)),this.isAttachedToDOM||(this.parent.add(this),v(this,L,Ya).call(this)),v(this,L,Kl).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,c(this,li)&&(clearTimeout(c(this,li)),b(this,li,null)),(e=c(this,tn))==null||e.disconnect(),b(this,tn,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){c(this,bs)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,v(this,L,zf).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),v(this,L,Xf).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){c(this,bs)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),b(this,bs,!0),this.div.classList.add("disabled"),v(this,L,Kl).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||c(this,bs)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),v(this,L,_v).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),v(this,L,Wf).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),v(this,L,Vf).call(this,e)}canvasPointerleave(e){v(this,L,Vf).call(this,e)}get isResizable(){return!this.isEmpty()&&c(this,bs)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,r,o]=v(this,L,yv).call(this);if(this.setAt(i,n,0,0),this.setDims(r,o),v(this,L,ou).call(this),this.width){const[h,l]=this.parentDimensions;this.setAspectRatio(this.width*h,this.height*l),this.setAt(e*h,s*l,this.width*h,this.height*l),b(this,co,!0),v(this,L,Ya).call(this),this.setDims(this.width*h,this.height*l),v(this,L,wo).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return v(this,L,au).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(c(this,uo)===i&&c(this,go)===n)return;b(this,uo,i),b(this,go,n),this.canvas.style.visibility="hidden";const[r,o]=this.parentDimensions;this.width=e/r,this.height=s/o,this.fixAndSetPosition(),c(this,bs)&&v(this,L,Gf).call(this,e,s),v(this,L,Ya).call(this),v(this,L,wo).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var _,y,x;if(e instanceof Yg)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=z.makeHexColor(...e.color),n.opacity=e.opacity;const[r,o]=n.pageDimensions,h=n.width*r,l=n.height*o,d=n.parentScale,u=e.thickness/2;b(n,bs,!0),b(n,uo,Math.round(h)),b(n,go,Math.round(l));const{paths:g,rect:f,rotation:p}=e;for(let{bezier:S}of g){S=v(_=kt,en,Ev).call(_,S,f,p);const C=[];n.paths.push(C);let E=d*(S[0]-u),M=d*(S[1]-u);for(let O=2,P=S.length;O<P;O+=6){const F=d*(S[O]-u),R=d*(S[O+1]-u),W=d*(S[O+2]-u),B=d*(S[O+3]-u),X=d*(S[O+4]-u),K=d*(S[O+5]-u);C.push([[E,M],[F,R],[W,B],[X,K]]),E=X,M=K}const k=v(this,en,Tv).call(this,C);n.bezierPath2D.push(k)}const m=v(y=n,L,Uf).call(y);return b(n,ao,Math.max(gt.MIN_SIZE,m[2]-m[0])),b(n,oo,Math.max(gt.MIN_SIZE,m[3]-m[1])),v(x=n,L,Gf).call(x,h,l),n}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=gt._colorManager.convert(this.ctx.strokeStyle);return{annotationType:Z.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:v(this,L,kv).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};oo=new WeakMap,ao=new WeakMap,li=new WeakMap,Zi=new WeakMap,bs=new WeakMap,ho=new WeakMap,lo=new WeakMap,co=new WeakMap,tn=new WeakMap,Ra=new WeakMap,uo=new WeakMap,go=new WeakMap,zn=new WeakMap,L=new WeakSet,mv=function(e){const s=n=>{this.thickness=n,v(this,L,Kl).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},bv=function(e){const s=n=>{this.color=n,v(this,L,wo).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},vv=function(e){const s=n=>{this.opacity=n,v(this,L,wo).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},yv=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Hf=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:r,scaleFactor:o}=this;e.lineWidth=n*r/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${Yw(i)}`},_v=function(e,s){this.canvas.addEventListener("contextmenu",hs,{signal:this._uiManager._signal}),v(this,L,Xf).call(this),b(this,ho,new AbortController);const i=this._uiManager.combinedSignal(c(this,ho));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,c(this,co)||(b(this,co,!0),v(this,L,Ya).call(this),this.thickness||(this.thickness=kt._defaultThickness),this.color||(this.color=kt._defaultColor||gt._defaultLineColor),this.opacity??(this.opacity=kt._defaultOpacity)),this.currentPath.push([e,s]),b(this,lo,!1),v(this,L,Hf).call(this),b(this,zn,()=>{v(this,L,Sv).call(this),c(this,zn)&&window.requestAnimationFrame(c(this,zn))}),window.requestAnimationFrame(c(this,zn))},Wf=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const r=this.currentPath;let o=c(this,Zi);if(r.push([e,s]),b(this,lo,!0),r.length<=2){o.moveTo(...r[0]),o.lineTo(e,s);return}r.length===3&&(b(this,Zi,o=new Path2D),o.moveTo(...r[0])),v(this,L,Cv).call(this,o,...r.at(-3),...r.at(-2),e,s)},wv=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);c(this,Zi).lineTo(...e)},xv=function(e,s){b(this,zn,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),v(this,L,Wf).call(this,e,s),v(this,L,wv).call(this);let i;if(this.currentPath.length!==1)i=v(this,L,Av).call(this);else{const l=[e,s];i=[[l,l.slice(),l.slice(),l]]}const n=c(this,Zi),r=this.currentPath;this.currentPath=[],b(this,Zi,new Path2D);const o=()=>{this.allRawPaths.push(r),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},h=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(v(this,L,ou).call(this),v(this,L,au).call(this)),v(this,L,Kl).call(this))};this.addCommands({cmd:o,undo:h,mustExec:!0})},Sv=function(){if(!c(this,lo))return;b(this,lo,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:r}=this;r.save(),r.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)r.stroke(o);r.stroke(c(this,Zi)),r.restore()},Cv=function(e,s,i,n,r,o,h){const l=(s+n)/2,d=(i+r)/2,u=(n+o)/2,g=(r+h)/2;e.bezierCurveTo(l+2*(n-l)/3,d+2*(r-d)/3,u+2*(n-u)/3,g+2*(r-g)/3,u,g)},Av=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,r]=e[0];for(i=1;i<e.length-2;i++){const[f,p]=e[i],[m,_]=e[i+1],y=(f+m)/2,x=(p+_)/2,S=[n+2*(f-n)/3,r+2*(p-r)/3],C=[y+2*(f-y)/3,x+2*(p-x)/3];s.push([[n,r],S,C,[y,x]]),[n,r]=[y,x]}const[o,h]=e[i],[l,d]=e[i+1],u=[n+2*(o-n)/3,r+2*(h-r)/3],g=[l+2*(o-l)/3,d+2*(h-d)/3];return s.push([[n,r],u,g,[l,d]]),s},wo=function(){if(this.isEmpty()){v(this,L,hu).call(this);return}v(this,L,Hf).call(this);const{canvas:e,ctx:s}=this;s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),v(this,L,hu).call(this);for(const i of this.bezierPath2D)s.stroke(i)},zf=function(){if(c(this,Ra))return;b(this,Ra,new AbortController);const e=this._uiManager.combinedSignal(c(this,Ra));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:e})},Xf=function(){var e;(e=this.pointerdownAC)==null||e.abort(),this.pointerdownAC=null},Vf=function(e){var s;(s=c(this,ho))==null||s.abort(),b(this,ho,null),v(this,L,zf).call(this),c(this,li)&&clearTimeout(c(this,li)),b(this,li,setTimeout(()=>{b(this,li,null),this.canvas.removeEventListener("contextmenu",hs)},10)),v(this,L,xv).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},ou=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},au=function(){b(this,tn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),c(this,tn).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=c(this,tn))==null||e.disconnect(),b(this,tn,null)},{once:!0})},Ya=function(){if(!c(this,co))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),v(this,L,hu).call(this)},Gf=function(e,s){const i=v(this,L,lu).call(this),n=(e-i)/c(this,ao),r=(s-i)/c(this,oo);this.scaleFactor=Math.min(n,r)},hu=function(){const e=v(this,L,lu).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},en=new WeakSet,Tv=function(e){const s=new Path2D;for(let i=0,n=e.length;i<n;i++){const[r,o,h,l]=e[i];i===0&&s.moveTo(...r),s.bezierCurveTo(o[0],o[1],h[0],h[1],l[0],l[1])}return s},Yf=function(e,s,i){const[n,r,o,h]=s;switch(i){case 0:for(let l=0,d=e.length;l<d;l+=2)e[l]+=n,e[l+1]=h-e[l+1];break;case 90:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=e[l+1]+n,e[l+1]=u+r}break;case 180:for(let l=0,d=e.length;l<d;l+=2)e[l]=o-e[l],e[l+1]+=r;break;case 270:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=o-e[l+1],e[l+1]=h-u}break;default:throw new Error("Invalid rotation")}return e},Ev=function(e,s,i){const[n,r,o,h]=s;switch(i){case 0:for(let l=0,d=e.length;l<d;l+=2)e[l]-=n,e[l+1]=h-e[l+1];break;case 90:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=e[l+1]-r,e[l+1]=u-n}break;case 180:for(let l=0,d=e.length;l<d;l+=2)e[l]=o-e[l],e[l+1]-=r;break;case 270:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=h-e[l+1],e[l+1]=o-u}break;default:throw new Error("Invalid rotation")}return e},kv=function(e,s,i,n){var d,u;const r=[],o=this.thickness/2,h=e*s+o,l=e*i+o;for(const g of this.paths){const f=[],p=[];for(let m=0,_=g.length;m<_;m++){const[y,x,S,C]=g[m];if(y[0]===C[0]&&y[1]===C[1]&&_===1){const B=e*y[0]+h,X=e*y[1]+l;f.push(B,X),p.push(B,X);break}const E=e*y[0]+h,M=e*y[1]+l,k=e*x[0]+h,O=e*x[1]+l,P=e*S[0]+h,F=e*S[1]+l,R=e*C[0]+h,W=e*C[1]+l;m===0&&(f.push(E,M),p.push(E,M)),f.push(k,O,P,F,R,W),p.push(k,O),m===_-1&&p.push(R,W)}r.push({bezier:v(d=kt,en,Yf).call(d,f,n,this.rotation),points:v(u=kt,en,Yf).call(u,p,n,this.rotation)})}return r},Uf=function(){let e=1/0,s=-1/0,i=1/0,n=-1/0;for(const r of this.paths)for(const[o,h,l,d]of r){const u=z.bezierBoundingBox(...o,...h,...l,...d);e=Math.min(e,u[0]),i=Math.min(i,u[1]),s=Math.max(s,u[2]),n=Math.max(n,u[3])}return[e,i,s,n]},lu=function(){return c(this,bs)?Math.ceil(this.thickness*this.parentScale):0},Kl=function(e=!1){if(this.isEmpty())return;if(!c(this,bs)){v(this,L,wo).call(this);return}const s=v(this,L,Uf).call(this),i=v(this,L,lu).call(this);b(this,ao,Math.max(gt.MIN_SIZE,s[2]-s[0])),b(this,oo,Math.max(gt.MIN_SIZE,s[3]-s[1]));const n=Math.ceil(i+c(this,ao)*this.scaleFactor),r=Math.ceil(i+c(this,oo)*this.scaleFactor),[o,h]=this.parentDimensions;this.width=n/o,this.height=r/h,this.setAspectRatio(n,r);const l=this.translationX,d=this.translationY;this.translationX=-s[0],this.translationY=-s[1],v(this,L,Ya).call(this),v(this,L,wo).call(this),b(this,uo,n),b(this,go,r),this.setDims(n,r);const u=e?i/this.scaleFactor/2:0;this.translate(l-this.translationX-u,d-this.translationY-u)},w(kt,en),q(kt,"_defaultColor",null),q(kt,"_defaultOpacity",1),q(kt,"_defaultThickness",1),q(kt,"_type","ink"),q(kt,"_editorType",Z.INK);let $g=kt;const Il=class Il extends gt{constructor(e){super({...e,name:"stampEditor"});w(this,nt);w(this,Mt,null);w(this,oe,null);w(this,Xn,null);w(this,sn,null);w(this,Vn,null);w(this,La,"");w(this,ci,null);w(this,nn,null);w(this,di,null);w(this,ss,!1);w(this,Ia,!1);b(this,sn,e.bitmapUrl),b(this,Vn,e.bitmapFile)}static initialize(e,s){gt.initialize(e,s)}static get supportedTypes(){return ot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(Z.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:r,height:o}=e||this.copyCanvas(null,null,!0).imageData,h=await i.guess({name:"altText",request:{data:n,width:r,height:o,channels:n.length/(r*o)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const l=h.output;return await this.setGuessedAltText(l),s&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}remove(){var e,s;c(this,oe)&&(b(this,Mt,null),this._uiManager.imageManager.deleteId(c(this,oe)),(e=c(this,ci))==null||e.remove(),b(this,ci,null),(s=c(this,nn))==null||s.disconnect(),b(this,nn,null),c(this,di)&&(clearTimeout(c(this,di)),b(this,di,null))),super.remove()}rebuild(){if(!this.parent){c(this,oe)&&v(this,nt,cu).call(this);return}super.rebuild(),this.div!==null&&(c(this,oe)&&c(this,ci)===null&&v(this,nt,cu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(c(this,Xn)||c(this,Mt)||c(this,sn)||c(this,Vn)||c(this,oe))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),c(this,Mt)?v(this,nt,qf).call(this):v(this,nt,cu).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}copyCanvas(e,s,i=!1){var f;e||(e=224);const{width:n,height:r}=c(this,Mt),o=new Tg;let h=c(this,Mt),l=n,d=r,u=null;if(s){if(n>s||r>s){const O=Math.min(s/n,s/r);l=Math.floor(n*O),d=Math.floor(r*O)}u=document.createElement("canvas");const p=u.width=Math.ceil(l*o.sx),m=u.height=Math.ceil(d*o.sy);c(this,ss)||(h=v(this,nt,du).call(this,p,m));const _=u.getContext("2d");_.filter=this._uiManager.hcmFilter;let y="white",x="#cfcfd8";this._uiManager.hcmFilter!=="none"?x="black":(f=window.matchMedia)!=null&&f.call(window,"(prefers-color-scheme: dark)").matches&&(y="#8f8f9d",x="#42414d");const S=15,C=S*o.sx,E=S*o.sy,M=new OffscreenCanvas(C*2,E*2),k=M.getContext("2d");k.fillStyle=y,k.fillRect(0,0,C*2,E*2),k.fillStyle=x,k.fillRect(0,0,C,E),k.fillRect(C,E,C,E),_.fillStyle=_.createPattern(M,"repeat"),_.fillRect(0,0,p,m),_.drawImage(h,0,0,h.width,h.height,0,0,p,m)}let g=null;if(i){let p,m;if(o.symmetric&&h.width<e&&h.height<e)p=h.width,m=h.height;else if(h=c(this,Mt),n>e||r>e){const x=Math.min(e/n,e/r);p=Math.floor(n*x),m=Math.floor(r*x),c(this,ss)||(h=v(this,nt,du).call(this,p,m))}const y=new OffscreenCanvas(p,m).getContext("2d",{willReadFrequently:!0});y.drawImage(h,0,0,h.width,h.height,0,0,p,m),g={width:p,height:m,data:y.getImageData(0,0,p,m).data}}return{canvas:u,width:l,height:d,imageData:g}}getImageForAltText(){return c(this,ci)}static async deserialize(e,s,i){var m;let n=null;if(e instanceof J0){const{data:{rect:_,rotation:y,id:x,structParent:S,popupRef:C},container:E,parent:{page:{pageNumber:M}}}=e,k=E.querySelector("canvas"),O=i.imageManager.getFromCanvas(E.id,k);k.remove();const P=((m=await s._structTree.getAriaAttributes(`${wg}${x}`))==null?void 0:m.get("aria-label"))||"";n=e={annotationType:Z.STAMP,bitmapId:O.id,bitmap:O.bitmap,pageIndex:M-1,rect:_.slice(0),rotation:y,id:x,deleted:!1,accessibilityData:{decorative:!1,altText:P},isSvg:!1,structParent:S,popupRef:C}}const r=await super.deserialize(e,s,i),{rect:o,bitmap:h,bitmapUrl:l,bitmapId:d,isSvg:u,accessibilityData:g}=e;d&&i.imageManager.isValidId(d)?(b(r,oe,d),h&&b(r,Mt,h)):b(r,sn,l),b(r,ss,u);const[f,p]=r.pageDimensions;return r.width=(o[2]-o[0])/f,r.height=(o[3]-o[1])/p,r.annotationElementId=e.id||null,g&&(r.altTextData=g),r._initialData=n,b(r,Ia,!!n),r}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:Z.STAMP,bitmapId:c(this,oe),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:c(this,ss),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=v(this,nt,uu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:r}=this.serializeAltText(!1);if(!n&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const h=v(this,nt,Dv).call(this,i);if(h.isSame)return null;h.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=c(this,ss)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(c(this,oe)))s.stamps.set(c(this,oe),{area:o,serialized:i}),i.bitmap=v(this,nt,uu).call(this,!1);else if(c(this,ss)){const h=s.stamps.get(c(this,oe));o>h.area&&(h.area=o,h.serialized.bitmap.close(),h.serialized.bitmap=v(this,nt,uu).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Mt=new WeakMap,oe=new WeakMap,Xn=new WeakMap,sn=new WeakMap,Vn=new WeakMap,La=new WeakMap,ci=new WeakMap,nn=new WeakMap,di=new WeakMap,ss=new WeakMap,Ia=new WeakMap,nt=new WeakSet,Ql=function(e,s=!1){if(!e){this.remove();return}b(this,Mt,e.bitmap),s||(b(this,oe,e.id),b(this,ss,e.isSvg)),e.file&&b(this,La,e.file.name),v(this,nt,qf).call(this)},Jl=function(){if(b(this,Xn,null),this._uiManager.enableWaiting(!1),!!c(this,ci)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,Mt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,Mt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},cu=function(){if(c(this,oe)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,oe)).then(i=>v(this,nt,Ql).call(this,i,!0)).finally(()=>v(this,nt,Jl).call(this));return}if(c(this,sn)){const i=c(this,sn);b(this,sn,null),this._uiManager.enableWaiting(!0),b(this,Xn,this._uiManager.imageManager.getFromUrl(i).then(n=>v(this,nt,Ql).call(this,n)).finally(()=>v(this,nt,Jl).call(this)));return}if(c(this,Vn)){const i=c(this,Vn);b(this,Vn,null),this._uiManager.enableWaiting(!0),b(this,Xn,this._uiManager.imageManager.getFromFile(i).then(n=>v(this,nt,Ql).call(this,n)).finally(()=>v(this,nt,Jl).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Il.supportedTypesStr;const s=this._uiManager._signal;b(this,Xn,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),v(this,nt,Ql).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>v(this,nt,Jl).call(this))),e.click()},qf=function(){const{div:e}=this;let{width:s,height:i}=c(this,Mt);const[n,r]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*r;else if(s>o*n||i>o*r){const u=Math.min(o*n/s,o*r/i);s*=u,i*=u}const[h,l]=this.parentDimensions;this.setDims(s*h/n,i*l/r),this._uiManager.enableWaiting(!1);const d=b(this,ci,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),v(this,nt,$f).call(this,s,i),v(this,nt,Ov).call(this),c(this,Ia)||(this.parent.addUndoableEditor(this),b(this,Ia,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,La)&&d.setAttribute("aria-label",c(this,La))},Mv=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,c(this,di)!==null&&clearTimeout(c(this,di)),b(this,di,setTimeout(()=>{b(this,di,null),v(this,nt,$f).call(this,e,s)},200))},du=function(e,s){const{width:i,height:n}=c(this,Mt);let r=i,o=n,h=c(this,Mt);for(;r>2*e||o>2*s;){const l=r,d=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(r,o);u.getContext("2d").drawImage(h,0,0,l,d,0,0,r,o),h=u.transferToImageBitmap()}return h},$f=function(e,s){const i=new Tg,n=Math.ceil(e*i.sx),r=Math.ceil(s*i.sy),o=c(this,ci);if(!o||o.width===n&&o.height===r)return;o.width=n,o.height=r;const h=c(this,ss)?c(this,Mt):v(this,nt,du).call(this,n,r),l=o.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(h,0,0,h.width,h.height,0,0,n,r)},uu=function(e){if(e){if(c(this,ss)){const n=this._uiManager.imageManager.getSvgUrl(c(this,oe));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=c(this,Mt),s.getContext("2d").drawImage(c(this,Mt),0,0),s.toDataURL()}if(c(this,ss)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*bn.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*bn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,r);return o.getContext("2d").drawImage(c(this,Mt),0,0,c(this,Mt).width,c(this,Mt).height,0,0,n,r),o.transferToImageBitmap()}return structuredClone(c(this,Mt))},Ov=function(){this._uiManager._signal&&(b(this,nn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&v(this,nt,Mv).call(this,s.width,s.height)})),c(this,nn).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=c(this,nn))==null||e.disconnect(),b(this,nn,null)},{once:!0}))},Dv=function(e){var l;const{rect:s,pageIndex:i,accessibilityData:{altText:n}}=this._initialData,r=e.rect.every((d,u)=>Math.abs(d-s[u])<1),o=e.pageIndex===i,h=(((l=e.accessibilityData)==null?void 0:l.alt)||"")===n;return{isSame:r&&o&&h,isSameAltText:h}},q(Il,"_type","stamp"),q(Il,"_editorType",Z.STAMP);let Kg=Il;const zs=class zs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:h,viewport:l,l10n:d}){w(this,ae);w(this,fo);w(this,ja,!1);w(this,ui,null);w(this,Gn,null);w(this,rn,null);w(this,is,new Map);w(this,Yn,!1);w(this,Na,!1);w(this,Ba,!1);w(this,ye,null);w(this,on,null);w(this,G);const u=[...c(zs,Un).values()];if(!zs._initialized){zs._initialized=!0;for(const g of u)g.initialize(d,t)}t.registerEditorTypes(u),b(this,G,t),this.pageIndex=e,this.div=s,b(this,fo,n),b(this,ui,r),this.viewport=l,b(this,ye,h),this.drawLayer=o,this._structTree=i,c(this,G).addLayer(this)}get isEmpty(){return c(this,is).size===0}get isInvisible(){return this.isEmpty&&c(this,G).getMode()===Z.NONE}updateToolbar(t){c(this,G).updateToolbar(t)}updateMode(t=c(this,G).getMode()){switch(v(this,ae,gu).call(this),t){case Z.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Z.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Z.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of c(zs,Un).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=c(this,ye))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(c(this,G).getMode()!==Z.INK)return;if(!t){for(const s of c(this,is).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){c(this,G).setEditingState(t)}addCommands(t){c(this,G).addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=c(this,ui))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of c(this,is).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(c(this,G).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!c(this,ui))return;const e=c(this,ui).getEditableAnnotations();for(const s of e){if(s.hide(),c(this,G).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;b(this,Ba,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of c(this,is).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(c(this,ui)){const n=c(this,ui).getEditableAnnotations();for(const r of n){const{id:o}=r.data;if(c(this,G).isDeletedAnnotationElement(o))continue;let h=e.get(o);if(h){h.resetAnnotationElement(r),h.show(!1),r.show();continue}h=t.get(o),h&&(c(this,G).addChangedExistingAnnotation(h),h.renderAnnotationElement(r)&&h.show(!1)),r.show()}}v(this,ae,gu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of c(zs,Un).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),b(this,Ba,!1)}getEditableAnnotation(t){var e;return((e=c(this,ui))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){c(this,G).getActive()!==t&&c(this,G).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=c(this,ye))!=null&&t.div&&!c(this,on)){b(this,on,new AbortController);const e=c(this,G).combinedSignal(c(this,on));c(this,ye).div.addEventListener("pointerdown",v(this,ae,Pv).bind(this),{signal:e}),c(this,ye).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=c(this,ye))!=null&&t.div&&c(this,on)&&(c(this,on).abort(),b(this,on,null),c(this,ye).div.classList.remove("highlighting"))}enableClick(){if(c(this,Gn))return;b(this,Gn,new AbortController);const t=c(this,G).combinedSignal(c(this,Gn));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;(t=c(this,Gn))==null||t.abort(),b(this,Gn,null)}attach(t){c(this,is).set(t.id,t);const{annotationElementId:e}=t;e&&c(this,G).isDeletedAnnotationElement(e)&&c(this,G).removeDeletedAnnotationElement(t)}detach(t){var e;c(this,is).delete(t.id),(e=c(this,fo))==null||e.removePointerInTextLayer(t.contentDiv),!c(this,Ba)&&t.annotationElementId&&c(this,G).addDeletedAnnotationElement(t)}remove(t){this.detach(t),c(this,G).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,c(this,Na)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(c(this,G).addDeletedAnnotationElement(t.annotationElementId),gt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),c(this,G).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),c(this,G).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!c(this,rn)&&(t._focusEventsAllowed=!1,b(this,rn,setTimeout(()=>{b(this,rn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:c(this,G)._signal}),e.focus())},0))),t._structTreeParentId=(s=c(this,fo))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return c(this,G).getId()}combinedSignal(t){return c(this,G).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=c(this,ae,Kf))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){c(this,G).updateToolbar(t),c(this,G).updateMode(t);const{offsetX:s,offsetY:i}=v(this,ae,Jf).call(this),n=this.getNextId(),r=v(this,ae,Qf).call(this,{parent:this,id:n,x:s,y:i,uiManager:c(this,G),isCentered:!0,...e});r&&this.add(r)}async deserialize(t){var e;return await((e=c(zs,Un).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,c(this,G)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=v(this,ae,Qf).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:c(this,G),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(v(this,ae,Jf).call(this),!0)}setSelected(t){c(this,G).setSelected(t)}toggleSelected(t){c(this,G).toggleSelected(t)}unselect(t){c(this,G).unselect(t)}pointerup(t){const{isMac:e}=Ee.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&c(this,Yn)){if(b(this,Yn,!1),!c(this,ja)){b(this,ja,!0);return}if(c(this,G).getMode()===Z.STAMP){c(this,G).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(c(this,G).getMode()===Z.HIGHLIGHT&&this.enableTextSelection(),c(this,Yn)){b(this,Yn,!1);return}const{isMac:e}=Ee.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;b(this,Yn,!0);const s=c(this,G).getActive();b(this,ja,!s||s.isEmpty())}findNewParent(t,e,s){const i=c(this,G).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=c(this,G).getActive())==null?void 0:t.parent)===this&&(c(this,G).commitOrRemove(),c(this,G).setActiveEditor(null)),c(this,rn)&&(clearTimeout(c(this,rn)),b(this,rn,null));for(const s of c(this,is).values())(e=c(this,fo))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,c(this,is).clear(),c(this,G).removeLayer(this)}render({viewport:t}){this.viewport=t,dr(this.div,t);for(const e of c(this,G).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){c(this,G).commitOrRemove(),v(this,ae,gu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,dr(this.div,{rotation:s}),e!==s)for(const i of c(this,is).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return c(this,G).viewParameters.realScale}};fo=new WeakMap,ja=new WeakMap,ui=new WeakMap,Gn=new WeakMap,rn=new WeakMap,is=new WeakMap,Yn=new WeakMap,Na=new WeakMap,Ba=new WeakMap,ye=new WeakMap,on=new WeakMap,G=new WeakMap,Un=new WeakMap,ae=new WeakSet,Pv=function(t){c(this,G).unselectAll();const{target:e}=t;if(e===c(this,ye).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&c(this,ye).div.contains(e)){const{isMac:s}=Ee.platform;if(t.button!==0||t.ctrlKey&&s)return;c(this,G).showAllEditors("highlight",!0,!0),c(this,ye).div.classList.add("free"),this.toggleDrawing(),yd.startHighlighting(this,c(this,G).direction==="ltr",{target:c(this,ye).div,x:t.x,y:t.y}),c(this,ye).div.addEventListener("pointerup",()=>{c(this,ye).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,G)._signal}),t.preventDefault()}},Kf=function(){return c(zs,Un).get(c(this,G).getMode())},Qf=function(t){const e=c(this,ae,Kf);return e?new e.prototype.constructor(t):null},Jf=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),o=Math.min(window.innerWidth,t+s),h=Math.min(window.innerHeight,e+i),l=(n+o)/2-t,d=(r+h)/2-e,[u,g]=this.viewport.rotation%180===0?[l,d]:[d,l];return{offsetX:u,offsetY:g}},gu=function(){b(this,Na,!0);for(const t of c(this,is).values())t.isEmpty()&&t.remove();b(this,Na,!1)},q(zs,"_initialized",!1),w(zs,Un,new Map([Ug,$g,Kg,yd].map(t=>[t._editorType,t])));let Qg=zs;const he=class he{constructor({pageIndex:t}){w(this,po);w(this,gi,null);w(this,jl,0);w(this,Wt,new Map);w(this,an,new Map);this.pageIndex=t}setParent(t){if(!c(this,gi)){b(this,gi,t);return}if(c(this,gi)!==t){if(c(this,Wt).size>0)for(const e of c(this,Wt).values())e.remove(),t.append(e);b(this,gi,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new Vg)}draw(t,e,s,i=!1){const n=Fe(this,jl)._++,r=v(this,po,tp).call(this,t.box);r.classList.add(...t.classNamesForDrawing);const o=he._svgFactory.createElement("defs");r.append(o);const h=he._svgFactory.createElement("path");o.append(h);const l=`path_p${this.pageIndex}_${n}`;h.setAttribute("id",l),h.setAttribute("d",t.toSVGPath()),i&&c(this,an).set(n,h);const d=v(this,po,Fv).call(this,o,l),u=he._svgFactory.createElement("use");return r.append(u),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),u.setAttribute("href",`#${l}`),c(this,Wt).set(n,r),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=Fe(this,jl)._++,s=v(this,po,tp).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=he._svgFactory.createElement("defs");s.append(i);const n=he._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const d=he._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=he._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const g=he._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${r}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const h=he._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${r}`),o&&h.setAttribute("mask",`url(#${o})`);const l=h.cloneNode();return s.append(l),h.classList.add("mainOutline"),l.classList.add("secondaryOutline"),c(this,Wt).set(e,s),e}finalizeLine(t,e){const s=c(this,an).get(t);c(this,an).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){c(this,Wt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){c(this,an).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;v(s=he,Nl,Zf).call(s,c(this,Wt).get(t),e)}show(t,e){c(this,Wt).get(t).classList.toggle("hidden",!e)}rotate(t,e){c(this,Wt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){c(this,Wt).get(t).setAttribute("fill",e)}changeOpacity(t,e){c(this,Wt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){c(this,Wt).get(t).classList.add(e)}removeClass(t,e){c(this,Wt).get(t).classList.remove(e)}getSVGRoot(t){return c(this,Wt).get(t)}remove(t){c(this,an).delete(t),c(this,gi)!==null&&(c(this,Wt).get(t).remove(),c(this,Wt).delete(t))}destroy(){b(this,gi,null);for(const t of c(this,Wt).values())t.remove();c(this,Wt).clear(),c(this,an).clear()}};gi=new WeakMap,jl=new WeakMap,Wt=new WeakMap,an=new WeakMap,Nl=new WeakSet,Zf=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`},po=new WeakSet,tp=function(t){var s;const e=he._svgFactory.create(1,1,!0);return c(this,gi).append(e),e.setAttribute("aria-hidden",!0),v(s=he,Nl,Zf).call(s,e,t),e},Fv=function(t,e){const s=he._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=he._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},w(he,Nl);let Jg=he;$.AbortException,$.AnnotationEditorLayer,$.AnnotationEditorParamsType,$.AnnotationEditorType,$.AnnotationEditorUIManager,$.AnnotationLayer,$.AnnotationMode,$.ColorPicker,$.DOMSVGFactory,$.DrawLayer,$.FeatureTest;var AS=$.GlobalWorkerOptions;$.ImageKind,$.InvalidPDFException,$.MissingPDFException,$.OPS,$.OutputScale,$.PDFDataRangeTransport,$.PDFDateString,$.PDFWorker,$.PasswordResponses,$.PermissionFlag,$.PixelsPerInch,$.RenderingCancelledException,$.TextLayer,$.UnexpectedResponseException,$.Util,$.VerbosityLevel,$.XfaLayer,$.build,$.createValidAbsoluteUrl,$.fetchData;var TS=$.getDocument;$.getFilenameFromUrl,$.getPdfFilenameFromUrl,$.getXfaPageViewport,$.isDataScheme,$.isPdfFile,$.noContextMenu,$.normalizeUnicode,$.setLayerDimensions,$.shadow,$.version;const ES={fabric:"^6.5.0","pdfjs-dist":"^4.8.69"};function kS(a){return new Promise((t,e)=>{const s=new FileReader;s.addEventListener("load",()=>t(s.result)),s.addEventListener("error",e),s.readAsDataURL(a)})}const MS=ES["pdfjs-dist"].replace("^","");AS.workerSrc=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${MS}/pdf.worker.min.mjs`;async function OS(a){const t="data:application/pdf;base64,",e=await kS(a);if(typeof e=="string")return window.atob(e.slice(t.length))}function DS(a,t){return TS({data:a,password:t}).promise}const PS={top:100,left:50,scaleX:.5,scaleY:.5,borderColor:"black",cornerStrokeColor:"black",cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},FS={top:100,left:50,fontFamily:"helvetica",borderColor:"black",cornerStrokeColor:"black",scaleX:.7,scaleY:.7,cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},RS={stroke:"#000",hoverStroke:"#B7EC5D",src:""};function sb(a=""){let t=0,e=null,s=null,i=1,n={...RS};function r(){if(!a||as.has(a))return;const k=fw(a);return k.on("selection:cleared",()=>C(k)),k}function o(k,O){var R;const P=k.type,F={"application/pdf":h,"image/png":u,"image/jpeg":u};return((R=F[P])==null?void 0:R.call(F,k,O))??Promise.reject(new Error(`Unsupported ${P} file type.`))}async function h(k,O){const P=await OS(k);if(!P)return;const F=pw(k,P);try{return await l({page:1,PDFBase64:P,scale:.8,password:O}),{...F,pages:t}}catch(R){return Promise.reject(R)}}async function l({page:k,PDFBase64:O,scale:P,password:F}){try{const R=await DS(O,F),W=await Y.toRaw(R).getPage(k),{renderTask:B,canvas:X}=mw(W,P);return t=R.numPages,B.promise.then(()=>d(X))}catch(R){return Promise.reject(R)}}function d(k){vw(a,k)}async function u(k){return await yw(a,k)}async function g({url:k,scale:O=.5}){await o0(a,{url:k,scale:O})}async function f(k,O){const P=as.get(a);if(!P)return;const F=await ge.fromURL(k,{},{...PS,...O});P.add(F),m(P,F)}function p(k,O){const P=as.get(a);if(!P)return;const F=new ue(k,{...FS,...O});P.add(F),m(P,F)}function m(k,O){O.on("selected",P=>_({canvas:k,target:P.target})),O.on("modified",P=>ch(P.target,e)),O.on("scaling",P=>ch(P.transform.target,e)),O.on("moving",P=>ch(P.transform.target,e)),O.on("rotating",P=>ch(P.transform.target,e))}async function _({canvas:k,target:O,stroke:P=n.stroke,uuid:F=Date.now()}){if((e==null?void 0:e.stroke)===`${P}-${F}`)return;const R=await bw(n.src,P,F);C(k),e=R,s=O,y(k,O,F),x(i,!0),k.add(R)}function y(k,O,P){e&&(e.on("selected",()=>{k.remove(O),C(k)}),e.on("mouseover",()=>{_({canvas:k,target:O,stroke:n.hoverStroke,uuid:P})}),e.on("mouseout",()=>{_({canvas:k,target:O,stroke:n.stroke,uuid:P})}))}function x(k,O=!1){const P=as.get(a);i=k,P&&(ww(s,k,n),_w(s,k,e),!O&&P.renderAll())}function S(k){if(!k)return;n={...n,...k};const O=as.get(a);!e||!s||!O||_({target:s,canvas:O})}function C(k){e&&(k.remove(e),e=s=null)}function E(){xw(a)}function M(){Sw(a)}return{createCanvas:r,loadFile:o,specifyPage:l,renderImage:g,addFabric:f,addTextFabric:p,clearActive:E,deleteCanvas:M,scaleFabric:x,setCloseSvgOptions:S}}function LS(a){let t=0;const e=gw(()=>{t!==window.innerWidth&&(t=window.innerWidth,a())});Y.onMounted(()=>{window.addEventListener("resize",e)}),Y.onBeforeUnmount(()=>{window.removeEventListener("resize",e)})}const IS=Y.defineComponent({__name:"pdf-canvas",props:{file:{},page:{default:1},canvasId:{default:"PDF-canvas"},fileZoom:{default:1},fileScale:{default:1},canvasScale:{default:1},canvasClass:{default:""},isDrop:{type:Boolean,default:!1},password:{},dropTextOptions:{},dropImageOptions:{},closeSvgOptions:{}},setup(a,{expose:t}){const e=a,s=Y.ref(null),i=`${e.canvasId}-${e.page-1}`,n=Y.computed(()=>e.fileZoom*e.canvasScale),{createCanvas:r,specifyPage:o,addFabric:h,addTextFabric:l,renderImage:d,clearActive:u,deleteCanvas:g,scaleFabric:f,setCloseSvgOptions:p}=sb(i);m(),LS(m);async function m(){const{file:S,page:C,fileScale:E}=e;window.requestAnimationFrame(async()=>{if(await Y.nextTick(),r(),S.PDFBase64.startsWith("data:image")||S.canvas){const{canvas:M}=S,k=M?7:3,O=M!=null&&M.length?M[C-1]:S.PDFBase64;d({url:O,scale:E/k});return}await o({page:C,PDFBase64:S.PDFBase64,scale:E,password:e.password})})}function _(S){if(!e.isDrop||!S.dataTransfer)return;const{dataTransfer:C,offsetX:E,offsetY:M}=S,k=C.getData("text"),O=C.getData("image"),P={left:E-71,top:M-55};O&&y(O,P),k&&x(k,P)}function y(S,C){h(S,{...C,...e.dropImageOptions})}function x(S,C){l(S,{...C,...e.dropTextOptions})}return Y.watch([()=>e.fileScale,()=>e.page,()=>e.file,()=>e.password],m),Y.watch(n,S=>f(S),{immediate:!0}),Y.watch(()=>e.closeSvgOptions,p,{immediate:!0}),Y.onBeforeUnmount(g),t({addImage:y,addText:x,clearActive:u,deleteCanvas:g,canvasRef:s}),(S,C)=>(Y.openBlock(),Y.createElementBlock("div",{style:Y.normalizeStyle({transform:`scale(${n.value})`}),onDragover:C[0]||(C[0]=Y.withModifiers(()=>{},["stop","prevent"])),onDragenter:C[1]||(C[1]=Y.withModifiers(()=>{},["stop","prevent"])),onDrop:Y.withModifiers(_,["stop","prevent"])},[Y.createElementVNode("canvas",{id:i,ref_key:"canvasRef",ref:s,class:Y.normalizeClass(S.canvasClass)},null,2)],36))}}),_d=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));rt.default=IS,rt.useFabric=sb,Object.defineProperties(rt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
509
+ `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},qb=function(){return c(this,Je).replaceAll(" "," ")},Ff=function(e){return e.replaceAll(" "," ")},$b=function(e){const{value:s,fontSize:i,color:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,h)=>o!==n[h])||e.pageIndex!==r},w(vt,qi),q(vt,"_freeTextDefaultContent",""),q(vt,"_internalPadding",0),q(vt,"_defaultColor",null),q(vt,"_defaultFontSize",10),q(vt,"_type","freetext"),q(vt,"_editorType",Z.FREETEXT);let Ug=vt;class Z0{toSVGPath(){yt("Abstract method `toSVGPath` must be implemented.")}get box(){yt("Abstract getter `box` must be implemented.")}serialize(t,e){yt("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){yt("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){yt("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}const $i=class $i{constructor({x:t,y:e},s,i,n,r,o=0){w(this,qt);w(this,ts);w(this,js,[]);w(this,wa);w(this,xa);w(this,hi,[]);w(this,it,new Float64Array(18));w(this,to);w(this,eo);w(this,wl);w(this,xl);w(this,Sa);w(this,Ca);w(this,Bn,[]);b(this,ts,s),b(this,Ca,n*i),b(this,xa,r),c(this,it).set([NaN,NaN,NaN,NaN,t,e],6),b(this,wa,o),b(this,xl,c($i,Sl)*i),b(this,wl,c($i,jd)*i),b(this,Sa,i),c(this,Bn).push(t,e)}isEmpty(){return isNaN(c(this,it)[8])}add({x:t,y:e}){var P;b(this,to,t),b(this,eo,e);const[s,i,n,r]=c(this,ts);let[o,h,l,d]=c(this,it).subarray(8,12);const u=t-l,g=e-d,f=Math.hypot(u,g);if(f<c(this,wl))return!1;const p=f-c(this,xl),m=p/f,_=m*u,y=m*g;let x=o,S=h;o=l,h=d,l+=_,d+=y,(P=c(this,Bn))==null||P.push(t,e);const C=-y/p,E=_/p,M=C*c(this,Ca),k=E*c(this,Ca);return c(this,it).set(c(this,it).subarray(2,8),0),c(this,it).set([l+M,d+k],4),c(this,it).set(c(this,it).subarray(14,18),12),c(this,it).set([l-M,d-k],16),isNaN(c(this,it)[6])?(c(this,hi).length===0&&(c(this,it).set([o+M,h+k],2),c(this,hi).push(NaN,NaN,NaN,NaN,(o+M-s)/n,(h+k-i)/r),c(this,it).set([o-M,h-k],14),c(this,js).push(NaN,NaN,NaN,NaN,(o-M-s)/n,(h-k-i)/r)),c(this,it).set([x,S,o,h,l,d],6),!this.isEmpty()):(c(this,it).set([x,S,o,h,l,d],6),Math.abs(Math.atan2(S-h,x-o)-Math.atan2(y,_))<Math.PI/2?([o,h,l,d]=c(this,it).subarray(2,6),c(this,hi).push(NaN,NaN,NaN,NaN,((o+l)/2-s)/n,((h+d)/2-i)/r),[o,h,x,S]=c(this,it).subarray(14,18),c(this,js).push(NaN,NaN,NaN,NaN,((x+o)/2-s)/n,((S+h)/2-i)/r),!0):([x,S,o,h,l,d]=c(this,it).subarray(0,6),c(this,hi).push(((x+5*o)/6-s)/n,((S+5*h)/6-i)/r,((5*o+l)/6-s)/n,((5*h+d)/6-i)/r,((o+l)/2-s)/n,((h+d)/2-i)/r),[l,d,o,h,x,S]=c(this,it).subarray(12,18),c(this,js).push(((x+5*o)/6-s)/n,((S+5*h)/6-i)/r,((5*o+l)/6-s)/n,((5*h+d)/6-i)/r,((o+l)/2-s)/n,((h+d)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=c(this,hi),e=c(this,js);if(isNaN(c(this,it)[6])&&!this.isEmpty())return v(this,qt,Kb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);v(this,qt,Jb).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return v(this,qt,Qb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,r){return new tb(t,e,s,i,n,r)}getOutlines(){var u;const t=c(this,hi),e=c(this,js),s=c(this,it),[i,n,r,o]=c(this,ts),h=new Float64Array((((u=c(this,Bn))==null?void 0:u.length)??0)+2);for(let g=0,f=h.length-2;g<f;g+=2)h[g]=(c(this,Bn)[g]-i)/r,h[g+1]=(c(this,Bn)[g+1]-n)/o;if(h[h.length-2]=(c(this,to)-i)/r,h[h.length-1]=(c(this,eo)-n)/o,isNaN(s[6])&&!this.isEmpty())return v(this,qt,Zb).call(this,h);const l=new Float64Array(c(this,hi).length+24+c(this,js).length);let d=t.length;for(let g=0;g<d;g+=2){if(isNaN(t[g])){l[g]=l[g+1]=NaN;continue}l[g]=t[g],l[g+1]=t[g+1]}d=v(this,qt,ev).call(this,l,d);for(let g=e.length-6;g>=6;g-=6)for(let f=0;f<6;f+=2){if(isNaN(e[g+f])){l[d]=l[d+1]=NaN,d+=2;continue}l[d]=e[g+f],l[d+1]=e[g+f+1],d+=2}return v(this,qt,tv).call(this,l,d),this.newFreeDrawOutline(l,h,c(this,ts),c(this,Sa),c(this,wa),c(this,xa))}};ts=new WeakMap,js=new WeakMap,wa=new WeakMap,xa=new WeakMap,hi=new WeakMap,it=new WeakMap,to=new WeakMap,eo=new WeakMap,wl=new WeakMap,xl=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,Bn=new WeakMap,Sl=new WeakMap,Id=new WeakMap,jd=new WeakMap,qt=new WeakSet,Yl=function(){const t=c(this,it).subarray(4,6),e=c(this,it).subarray(16,18),[s,i,n,r]=c(this,ts);return[(c(this,to)+(t[0]-e[0])/2-s)/n,(c(this,eo)+(t[1]-e[1])/2-i)/r,(c(this,to)+(e[0]-t[0])/2-s)/n,(c(this,eo)+(e[1]-t[1])/2-i)/r]},Kb=function(){const[t,e,s,i]=c(this,ts),[n,r,o,h]=v(this,qt,Yl).call(this);return`M${(c(this,it)[2]-t)/s} ${(c(this,it)[3]-e)/i} L${(c(this,it)[4]-t)/s} ${(c(this,it)[5]-e)/i} L${n} ${r} L${o} ${h} L${(c(this,it)[16]-t)/s} ${(c(this,it)[17]-e)/i} L${(c(this,it)[14]-t)/s} ${(c(this,it)[15]-e)/i} Z`},Qb=function(t){const e=c(this,js);t.push(`L${e[4]} ${e[5]} Z`)},Jb=function(t){const[e,s,i,n]=c(this,ts),r=c(this,it).subarray(4,6),o=c(this,it).subarray(16,18),[h,l,d,u]=v(this,qt,Yl).call(this);t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${h} ${l} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},Zb=function(t){const e=c(this,it),[s,i,n,r]=c(this,ts),[o,h,l,d]=v(this,qt,Yl).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(u,t,c(this,ts),c(this,Sa),c(this,wa),c(this,xa))},tv=function(t,e){const s=c(this,js);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},ev=function(t,e){const s=c(this,it).subarray(4,6),i=c(this,it).subarray(16,18),[n,r,o,h]=c(this,ts),[l,d,u,g]=v(this,qt,Yl).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-r)/h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,u,g,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-r)/h],e),e+=24},w($i,Sl,8),w($i,Id,2),w($i,jd,c($i,Sl)+c($i,Id));let bd=$i;class tb extends Z0{constructor(e,s,i,n,r,o){super();w(this,We);w(this,Aa);w(this,so,null);w(this,Ki);w(this,Cl);w(this,es);w(this,Al);w(this,It);b(this,It,e),b(this,es,s),b(this,Aa,i),b(this,Al,n),b(this,Ki,r),b(this,Cl,o),v(this,We,sv).call(this,o);const{x:h,y:l,width:d,height:u}=c(this,so);for(let g=0,f=e.length;g<f;g+=2)e[g]=(e[g]-h)/d,e[g+1]=(e[g+1]-l)/u;for(let g=0,f=s.length;g<f;g+=2)s[g]=(s[g]-h)/d,s[g+1]=(s[g+1]-l)/u}toSVGPath(){const e=[`M${c(this,It)[4]} ${c(this,It)[5]}`];for(let s=6,i=c(this,It).length;s<i;s+=6){if(isNaN(c(this,It)[s])){e.push(`L${c(this,It)[s+4]} ${c(this,It)[s+5]}`);continue}e.push(`C${c(this,It)[s]} ${c(this,It)[s+1]} ${c(this,It)[s+2]} ${c(this,It)[s+3]} ${c(this,It)[s+4]} ${c(this,It)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],r){const o=i-e,h=n-s;let l,d;switch(r){case 0:l=v(this,We,Ul).call(this,c(this,It),e,n,o,-h),d=v(this,We,Ul).call(this,c(this,es),e,n,o,-h);break;case 90:l=v(this,We,ql).call(this,c(this,It),e,s,o,h),d=v(this,We,ql).call(this,c(this,es),e,s,o,h);break;case 180:l=v(this,We,Ul).call(this,c(this,It),i,s,-o,h),d=v(this,We,Ul).call(this,c(this,es),i,s,-o,h);break;case 270:l=v(this,We,ql).call(this,c(this,It),i,n,-o,-h),d=v(this,We,ql).call(this,c(this,es),i,n,-o,-h);break}return{outline:Array.from(l),points:[Array.from(d)]}}get box(){return c(this,so)}newOutliner(e,s,i,n,r,o=0){return new bd(e,s,i,n,r,o)}getNewOutline(e,s){const{x:i,y:n,width:r,height:o}=c(this,so),[h,l,d,u]=c(this,Aa),g=r*d,f=o*u,p=i*d+h,m=n*u+l,_=this.newOutliner({x:c(this,es)[0]*g+p,y:c(this,es)[1]*f+m},c(this,Aa),c(this,Al),e,c(this,Cl),s??c(this,Ki));for(let y=2;y<c(this,es).length;y+=2)_.add({x:c(this,es)[y]*g+p,y:c(this,es)[y+1]*f+m});return _.getOutlines()}get mustRemoveSelfIntersections(){return!0}}Aa=new WeakMap,so=new WeakMap,Ki=new WeakMap,Cl=new WeakMap,es=new WeakMap,Al=new WeakMap,It=new WeakMap,We=new WeakSet,Ul=function(e,s,i,n,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h]*n,o[h+1]=i+e[h+1]*r;return o},ql=function(e,s,i,n,r){const o=new Float64Array(e.length);for(let h=0,l=e.length;h<l;h+=2)o[h]=s+e[h+1]*n,o[h+1]=i+e[h]*r;return o},sv=function(e){const s=c(this,It);let i=s[4],n=s[5],r=i,o=n,h=i,l=n,d=i,u=n;const g=e?Math.max:Math.min;for(let y=6,x=s.length;y<x;y+=6){if(isNaN(s[y]))r=Math.min(r,s[y+4]),o=Math.min(o,s[y+5]),h=Math.max(h,s[y+4]),l=Math.max(l,s[y+5]),u<s[y+5]?(d=s[y+4],u=s[y+5]):u===s[y+5]&&(d=g(d,s[y+4]));else{const S=z.bezierBoundingBox(i,n,...s.slice(y,y+6));r=Math.min(r,S[0]),o=Math.min(o,S[1]),h=Math.max(h,S[2]),l=Math.max(l,S[3]),u<S[3]?(d=S[2],u=S[3]):u===S[3]&&(d=g(d,S[2]))}i=s[y+4],n=s[y+5]}const f=r-c(this,Ki),p=o-c(this,Ki),m=h-r+2*c(this,Ki),_=l-o+2*c(this,Ki);b(this,so,{x:f,y:p,width:m,height:_,lastPoint:[d,u]})};class eb{constructor(t,e=0,s=0,i=!0){w(this,De);w(this,Tl);w(this,Hn,[]);w(this,Ns,[]);let n=1/0,r=-1/0,o=1/0,h=-1/0;const d=10**-4;for(const{x:y,y:x,width:S,height:C}of t){const E=Math.floor((y-e)/d)*d,M=Math.ceil((y+S+e)/d)*d,k=Math.floor((x-e)/d)*d,O=Math.ceil((x+C+e)/d)*d,P=[E,k,O,!0],F=[M,k,O,!1];c(this,Hn).push(P,F),n=Math.min(n,E),r=Math.max(r,M),o=Math.min(o,k),h=Math.max(h,O)}const u=r-n+2*s,g=h-o+2*s,f=n-s,p=o-s,m=c(this,Hn).at(i?-1:-2),_=[m[0],m[2]];for(const y of c(this,Hn)){const[x,S,C]=y;y[0]=(x-f)/u,y[1]=(S-p)/g,y[2]=(C-p)/g}b(this,Tl,{x:f,y:p,width:u,height:g,lastPoint:_})}getOutlines(){c(this,Hn).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of c(this,Hn))e[3]?(t.push(...v(this,De,Rf).call(this,e)),v(this,De,nv).call(this,e)):(v(this,De,rv).call(this,e),t.push(...v(this,De,Rf).call(this,e)));return v(this,De,iv).call(this,t)}}Tl=new WeakMap,Hn=new WeakMap,Ns=new WeakMap,De=new WeakSet,iv=function(t){const e=[],s=new Set;for(const r of t){const[o,h,l]=r;e.push([o,h,r],[o,l,r])}e.sort((r,o)=>r[1]-o[1]||r[0]-o[0]);for(let r=0,o=e.length;r<o;r+=2){const h=e[r][2],l=e[r+1][2];h.push(l),l.push(h),s.add(h),s.add(l)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[o,h,l,d,u]=r;s.delete(r);let g=o,f=h;for(n=[o,l],i.push(n);;){let p;if(s.has(d))p=d;else if(s.has(u))p=u;else break;s.delete(p),[o,h,l,d,u]=p,g!==o&&(n.push(g,f,o,f===h?h:l),g=o),f=f===h?l:h}n.push(g,f)}return new SS(i,c(this,Tl))},iu=function(t){const e=c(this,Ns);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1},nv=function([,t,e]){const s=v(this,De,iu).call(this,t);c(this,Ns).splice(s,0,[t,e])},rv=function([,t,e]){const s=v(this,De,iu).call(this,t);for(let i=s;i<c(this,Ns).length;i++){const[n,r]=c(this,Ns)[i];if(n!==t)break;if(n===t&&r===e){c(this,Ns).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=c(this,Ns)[i];if(n!==t)break;if(n===t&&r===e){c(this,Ns).splice(i,1);return}}},Rf=function(t){const[e,s,i]=t,n=[[e,s,i]],r=v(this,De,iu).call(this,i);for(let o=0;o<r;o++){const[h,l]=c(this,Ns)[o];for(let d=0,u=n.length;d<u;d++){const[,g,f]=n[d];if(!(l<=g||f<=h)){if(g>=h){if(f>l)n[d][1]=l;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=h,f>l&&n.push([e,l,f])}}}return n};class SS extends Z0{constructor(e,s){super();w(this,El);w(this,Ta);b(this,Ta,e),b(this,El,s)}toSVGPath(){const e=[];for(const s of c(this,Ta)){let[i,n]=s;e.push(`M${i} ${n}`);for(let r=2;r<s.length;r+=2){const o=s[r],h=s[r+1];o===i?(e.push(`V${h}`),n=h):h===n&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],r){const o=[],h=i-e,l=n-s;for(const d of c(this,Ta)){const u=new Array(d.length);for(let g=0;g<d.length;g+=2)u[g]=e+d[g]*h,u[g+1]=n-d[g+1]*l;o.push(u)}return o}get box(){return c(this,El)}get classNamesForDrawing(){return["highlight"]}get classNamesForOutlining(){return["highlightOutline"]}}El=new WeakMap,Ta=new WeakMap;class qg extends bd{newFreeDrawOutline(t,e,s,i,n,r){return new CS(t,e,s,i,n,r)}get classNamesForDrawing(){return["highlight","free"]}}class CS extends tb{get classNamesForDrawing(){return["highlight","free"]}get classNamesForOutlining(){return["highlightOutline","free"]}newOutliner(t,e,s,i,n,r=0){return new qg(t,e,s,i,n,r)}}const ze=class ze{constructor({editor:t=null,uiManager:e=null}){w(this,bt);w(this,Bs,null);w(this,io,null);w(this,Ea);w(this,$t,null);w(this,kl,!1);w(this,ka,!1);w(this,Ml,null);w(this,Ol);w(this,Wn,null);w(this,Hs,null);w(this,Ma);var s;t?(b(this,ka,!1),b(this,Ma,U.HIGHLIGHT_COLOR),b(this,Ml,t)):(b(this,ka,!0),b(this,Ma,U.HIGHLIGHT_DEFAULT_COLOR)),b(this,Hs,(t==null?void 0:t._uiManager)||e),b(this,Ol,c(this,Hs)._eventBus),b(this,Ea,(t==null?void 0:t.color)||((s=c(this,Hs))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),c(ze,Dl)||b(ze,Dl,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return ot(this,"_keyboardManager",new ph([[["Escape","mac+Escape"],ze.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ze.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ze.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ze.prototype._moveToPrevious],[["Home","mac+Home"],ze.prototype._moveToBeginning],[["End","mac+End"],ze.prototype._moveToEnd]]))}renderButton(){const t=b(this,Bs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=c(this,Hs)._signal;t.addEventListener("click",v(this,bt,yo).bind(this),{signal:e}),t.addEventListener("keydown",v(this,bt,jf).bind(this),{signal:e});const s=b(this,io,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=c(this,Ea),t.append(s),t}renderMainDropdown(){const t=b(this,$t,v(this,bt,Lf).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===c(this,Bs)){v(this,bt,yo).call(this,t);return}const e=t.target.getAttribute("data-color");e&&v(this,bt,If).call(this,e,t)}_moveToNext(t){var e,s;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}if(t.target===c(this,Bs)){(e=c(this,$t).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=c(this,$t))==null?void 0:e.firstChild)||t.target===c(this,Bs)){c(this,bt,$n)&&this._hideDropdownFromKeyboard();return}c(this,bt,$n)||v(this,bt,yo).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}(e=c(this,$t).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!c(this,bt,$n)){v(this,bt,yo).call(this,t);return}(e=c(this,$t).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=c(this,$t))==null||t.classList.add("hidden"),(e=c(this,Wn))==null||e.abort(),b(this,Wn,null)}_hideDropdownFromKeyboard(){var t;if(!c(this,ka)){if(!c(this,bt,$n)){(t=c(this,Ml))==null||t.unselect();return}this.hideDropdown(),c(this,Bs).focus({preventScroll:!0,focusVisible:c(this,kl)})}}updateColor(t){if(c(this,io)&&(c(this,io).style.backgroundColor=t),!c(this,$t))return;const e=c(this,Hs).highlightColors.values();for(const s of c(this,$t).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=c(this,Bs))==null||t.remove(),b(this,Bs,null),b(this,io,null),(e=c(this,$t))==null||e.remove(),b(this,$t,null)}};Bs=new WeakMap,io=new WeakMap,Ea=new WeakMap,$t=new WeakMap,kl=new WeakMap,ka=new WeakMap,Ml=new WeakMap,Ol=new WeakMap,Wn=new WeakMap,Hs=new WeakMap,Ma=new WeakMap,Dl=new WeakMap,bt=new WeakSet,Lf=function(){const t=document.createElement("div"),e=c(this,Hs)._signal;t.addEventListener("contextmenu",hs,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of c(this,Hs).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",c(ze,Dl)[s]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===c(this,Ea)),n.addEventListener("click",v(this,bt,If).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",v(this,bt,jf).bind(this),{signal:e}),t},If=function(t,e){e.stopPropagation(),c(this,Ol).dispatch("switchannotationeditorparams",{source:this,type:c(this,Ma),value:t})},jf=function(t){ze._keyboardManager.exec(this,t)},yo=function(t){if(c(this,bt,$n)){this.hideDropdown();return}if(b(this,kl,t.detail===0),c(this,Wn)||(b(this,Wn,new AbortController),window.addEventListener("pointerdown",v(this,bt,ov).bind(this),{signal:c(this,Hs).combinedSignal(c(this,Wn))})),c(this,$t)){c(this,$t).classList.remove("hidden");return}const e=b(this,$t,v(this,bt,Lf).call(this));c(this,Bs).append(e)},ov=function(t){var e;(e=c(this,$t))!=null&&e.contains(t.target)||this.hideDropdown()},$n=function(){return c(this,$t)&&!c(this,$t).classList.contains("hidden")},w(ze,Dl,null);let vd=ze;const ht=class ht extends gt{constructor(e){super({...e,name:"highlightEditor"});w(this,J);w(this,Oa,null);w(this,Pl,0);w(this,Qi);w(this,no,null);w(this,Da,null);w(this,fs,null);w(this,Fl,null);w(this,Rl,0);w(this,ro,null);w(this,Ws,null);w(this,ve,null);w(this,Xe,!1);w(this,Pa,null);w(this,Ji);w(this,Kt,null);w(this,Fa,"");w(this,ps);w(this,Ll,"");this.color=e.color||ht._defaultColor,b(this,ps,e.thickness||ht._defaultThickness),b(this,Ji,e.opacity||ht._defaultOpacity),b(this,Qi,e.boxes||null),b(this,Ll,e.methodOfCreation||""),b(this,Fa,e.text||""),this._isDraggable=!1,e.highlightId>-1?(b(this,Xe,!0),v(this,J,nu).call(this,e),v(this,J,_o).call(this)):c(this,Qi)&&(b(this,Oa,e.anchorNode),b(this,Pl,e.anchorOffset),b(this,Fl,e.focusNode),b(this,Rl,e.focusOffset),v(this,J,Nf).call(this),v(this,J,_o).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=ht.prototype;return ot(this,"_keyboardManager",new ph([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:c(this,Xe)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:c(this,ps),methodOfCreation:c(this,Ll)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;gt.initialize(e,s),ht._defaultColor||(ht._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case U.HIGHLIGHT_DEFAULT_COLOR:ht._defaultColor=s;break;case U.HIGHLIGHT_THICKNESS:ht._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return c(this,Pa)}updateParams(e,s){switch(e){case U.HIGHLIGHT_COLOR:v(this,J,av).call(this,s);break;case U.HIGHLIGHT_THICKNESS:v(this,J,hv).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.HIGHLIGHT_DEFAULT_COLOR,ht._defaultColor],[U.HIGHLIGHT_THICKNESS,ht._defaultThickness]]}get propertiesToUpdate(){return[[U.HIGHLIGHT_COLOR,this.color||ht._defaultColor],[U.HIGHLIGHT_THICKNESS,c(this,ps)||ht._defaultThickness],[U.HIGHLIGHT_FREE,c(this,Xe)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(b(this,Da,new vd({editor:this})),e.addColorPicker(c(this,Da))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(v(this,J,$l).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,v(this,J,$l).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){v(this,J,Bf).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,J,_o).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?v(this,J,Bf).call(this):e&&(v(this,J,_o).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,r,o;const{drawLayer:s}=this.parent;let i;c(this,Xe)?(e=(e-this.rotation+360)%360,i=v(n=ht,ms,Ga).call(n,c(this,Ws).box,e)):i=v(r=ht,ms,Ga).call(r,this,e),s.rotate(c(this,ve),e),s.rotate(c(this,Kt),e),s.updateBox(c(this,ve),i),s.updateBox(c(this,Kt),v(o=ht,ms,Ga).call(o,c(this,fs).box,e))}render(){if(this.div)return this.div;const e=super.render();c(this,Fa)&&(e.setAttribute("aria-label",c(this,Fa)),e.setAttribute("role","mark")),c(this,Xe)?e.classList.add("free"):this.div.addEventListener("keydown",v(this,J,cv).bind(this),{signal:this._uiManager._signal});const s=b(this,ro,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=c(this,no);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),ld(this,c(this,ro),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(c(this,Kt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(c(this,Kt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:v(this,J,ru).call(this,!0);break;case 1:case 3:v(this,J,ru).call(this,!1);break}}select(){var e,s;super.select(),c(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(c(this,Kt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(c(this,Kt),"selected"))}unselect(){var e;super.unselect(),c(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(c(this,Kt),"selected"),c(this,Xe)||v(this,J,ru).call(this,!1))}get _mustFixPosition(){return!c(this,Xe)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(c(this,ve),e),this.parent.drawLayer.show(c(this,Kt),e))}static startHighlighting(e,s,{target:i,x:n,y:r}){const{x:o,y:h,width:l,height:d}=i.getBoundingClientRect(),u=new AbortController,g=e.combinedSignal(u),f=m=>{m.preventDefault(),m.stopPropagation()},p=m=>{u.abort(),v(this,ms,fv).call(this,e,m)};window.addEventListener("blur",p,{signal:g}),window.addEventListener("pointerup",p,{signal:g}),window.addEventListener("pointerdown",f,{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",hs,{signal:g}),i.addEventListener("pointermove",v(this,ms,gv).bind(this,e),{signal:g}),this._freeHighlight=new qg({x:n,y:r},[o,h,l,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(e,s,i){var m,_,y,x;let n=null;if(e instanceof Q0){const{data:{quadPoints:S,rect:C,rotation:E,id:M,color:k,opacity:O,popupRef:P},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:Z.HIGHLIGHT,color:Array.from(k),opacity:O,quadPoints:S,boxes:null,pageIndex:F-1,rect:C.slice(0),rotation:E,id:M,deleted:!1,popupRef:P}}else if(e instanceof Yg){const{data:{inkLists:S,rect:C,rotation:E,id:M,color:k,borderStyle:{rawWidth:O},popupRef:P},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:Z.HIGHLIGHT,color:Array.from(k),thickness:O,inkLists:S,boxes:null,pageIndex:F-1,rect:C.slice(0),rotation:E,id:M,deleted:!1,popupRef:P}}const{color:r,quadPoints:o,inkLists:h,opacity:l}=e,d=await super.deserialize(e,s,i);d.color=z.makeHexColor(...r),b(d,Ji,l||1),h&&b(d,ps,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,g]=d.pageDimensions,[f,p]=d.pageTranslation;if(o){const S=b(d,Qi,[]);for(let C=0;C<o.length;C+=8)S.push({x:(o[C]-f)/u,y:1-(o[C+1]-p)/g,width:(o[C+2]-o[C])/u,height:(o[C+1]-o[C+5])/g});v(m=d,J,Nf).call(m),v(_=d,J,_o).call(_),d.rotate(d.rotation)}else if(h){b(d,Xe,!0);const S=h[0],C={x:S[0]-f,y:g-(S[1]-p)},E=new qg(C,[0,0,u,g],1,c(d,ps)/2,!0,.001);for(let O=0,P=S.length;O<P;O+=2)C.x=S[O]-f,C.y=g-(S[O+1]-p),E.add(C);const{id:M,clipPathId:k}=s.drawLayer.draw(E,d.color,d._defaultOpacity,!0);v(y=d,J,nu).call(y,{highlightOutlines:E.getOutlines(),highlightId:M,clipPathId:k}),v(x=d,J,_o).call(x)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=gt._colorManager.convert(this.color),n={annotationType:Z.HIGHLIGHT,color:i,opacity:c(this,Ji),thickness:c(this,ps),quadPoints:v(this,J,dv).call(this),outlines:v(this,J,uv).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:v(this,J,$l).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!v(this,J,pv).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Oa=new WeakMap,Pl=new WeakMap,Qi=new WeakMap,no=new WeakMap,Da=new WeakMap,fs=new WeakMap,Fl=new WeakMap,Rl=new WeakMap,ro=new WeakMap,Ws=new WeakMap,ve=new WeakMap,Xe=new WeakMap,Pa=new WeakMap,Ji=new WeakMap,Kt=new WeakMap,Fa=new WeakMap,ps=new WeakMap,Ll=new WeakMap,J=new WeakSet,Nf=function(){const e=new eb(c(this,Qi),.001);b(this,Ws,e.getOutlines()),{x:this.x,y:this.y,width:this.width,height:this.height}=c(this,Ws).box;const s=new eb(c(this,Qi),.0025,.001,this._uiManager.direction==="ltr");b(this,fs,s.getOutlines());const{lastPoint:i}=c(this,fs).box;b(this,Pa,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},nu=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var u,g;if(b(this,Ws,e),b(this,fs,e.getNewOutline(c(this,ps)/2+1.5,.0025)),s>=0)b(this,ve,s),b(this,no,i),this.parent.drawLayer.finalizeLine(s,e),b(this,Kt,this.parent.drawLayer.drawOutline(c(this,fs)));else if(this.parent){const f=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(c(this,ve),e),this.parent.drawLayer.updateBox(c(this,ve),v(u=ht,ms,Ga).call(u,c(this,Ws).box,(f-this.rotation+360)%360)),this.parent.drawLayer.updateLine(c(this,Kt),c(this,fs)),this.parent.drawLayer.updateBox(c(this,Kt),v(g=ht,ms,Ga).call(g,c(this,fs).box,f))}const{x:r,y:o,width:h,height:l}=e.box;switch(this.rotation){case 0:this.x=r,this.y=o,this.width=h,this.height=l;break;case 90:{const[f,p]=this.parentDimensions;this.x=o,this.y=1-r,this.width=h*p/f,this.height=l*f/p;break}case 180:this.x=1-r,this.y=1-o,this.width=h,this.height=l;break;case 270:{const[f,p]=this.parentDimensions;this.x=1-o,this.y=r,this.width=h*p/f,this.height=l*f/p;break}}const{lastPoint:d}=c(this,fs).box;b(this,Pa,[(d[0]-r)/h,(d[1]-o)/l])},av=function(e){const s=(r,o)=>{var h,l,d;this.color=r,(h=this.parent)==null||h.drawLayer.changeColor(c(this,ve),r),(l=c(this,Da))==null||l.updateColor(r),b(this,Ji,o),(d=this.parent)==null||d.drawLayer.changeOpacity(c(this,ve),o)},i=this.color,n=c(this,Ji);this.addCommands({cmd:s.bind(this,e,ht._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},hv=function(e){const s=c(this,ps),i=n=>{b(this,ps,n),v(this,J,lv).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},lv=function(e){if(!c(this,Xe))return;v(this,J,nu).call(this,{highlightOutlines:c(this,Ws).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Bf=function(){c(this,ve)===null||!this.parent||(this.parent.drawLayer.remove(c(this,ve)),b(this,ve,null),this.parent.drawLayer.remove(c(this,Kt)),b(this,Kt,null))},_o=function(e=this.parent){c(this,ve)===null&&({id:Fe(this,ve)._,clipPathId:Fe(this,no)._}=e.drawLayer.draw(c(this,Ws),this.color,c(this,Ji)),b(this,Kt,e.drawLayer.drawOutline(c(this,fs))),c(this,ro)&&(c(this,ro).style.clipPath=c(this,no)))},ms=new WeakSet,Ga=function({x:e,y:s,width:i,height:n},r){switch(r){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},cv=function(e){ht._keyboardManager.exec(this,e)},ru=function(e){if(!c(this,Oa))return;const s=window.getSelection();e?s.setPosition(c(this,Oa),c(this,Pl)):s.setPosition(c(this,Fl),c(this,Rl))},$l=function(){return c(this,Xe)?this.rotation:0},dv=function(){if(c(this,Xe))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,r=c(this,Qi),o=new Float32Array(r.length*8);let h=0;for(const{x:l,y:d,width:u,height:g}of r){const f=l*e+i,p=(1-d-g)*s+n;o[h]=o[h+4]=f,o[h+1]=o[h+3]=p,o[h+2]=o[h+6]=f+u*e,o[h+5]=o[h+7]=p+g*s,h+=8}return o},uv=function(e){return c(this,Ws).serialize(e,v(this,J,$l).call(this))},gv=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},fv=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},pv=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},w(ht,ms),q(ht,"_defaultColor",null),q(ht,"_defaultOpacity",1),q(ht,"_defaultThickness",12),q(ht,"_type","highlight"),q(ht,"_editorType",Z.HIGHLIGHT),q(ht,"_freeHighlightId",-1),q(ht,"_freeHighlight",null),q(ht,"_freeHighlightClipId","");let yd=ht;const kt=class kt extends gt{constructor(e){super({...e,name:"inkEditor"});w(this,L);w(this,oo,0);w(this,ao,0);w(this,li,null);w(this,Zi,new Path2D);w(this,bs,!1);w(this,ho,null);w(this,lo,!1);w(this,co,!1);w(this,tn,null);w(this,Ra,null);w(this,uo,0);w(this,go,0);w(this,zn,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){gt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case U.INK_THICKNESS:kt._defaultThickness=s;break;case U.INK_COLOR:kt._defaultColor=s;break;case U.INK_OPACITY:kt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case U.INK_THICKNESS:v(this,L,mv).call(this,s);break;case U.INK_COLOR:v(this,L,bv).call(this,s);break;case U.INK_OPACITY:v(this,L,vv).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[U.INK_THICKNESS,kt._defaultThickness],[U.INK_COLOR,kt._defaultColor||gt._defaultLineColor],[U.INK_OPACITY,Math.round(kt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[U.INK_THICKNESS,this.thickness||kt._defaultThickness],[U.INK_COLOR,this.color||kt._defaultColor||gt._defaultLineColor],[U.INK_OPACITY,Math.round(100*(this.opacity??kt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(v(this,L,ou).call(this),v(this,L,au).call(this)),this.isAttachedToDOM||(this.parent.add(this),v(this,L,Ya).call(this)),v(this,L,Kl).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,c(this,li)&&(clearTimeout(c(this,li)),b(this,li,null)),(e=c(this,tn))==null||e.disconnect(),b(this,tn,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){c(this,bs)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,v(this,L,zf).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),v(this,L,Xf).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){c(this,bs)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),b(this,bs,!0),this.div.classList.add("disabled"),v(this,L,Kl).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||c(this,bs)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),v(this,L,_v).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),v(this,L,Wf).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),v(this,L,Vf).call(this,e)}canvasPointerleave(e){v(this,L,Vf).call(this,e)}get isResizable(){return!this.isEmpty()&&c(this,bs)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,r,o]=v(this,L,yv).call(this);if(this.setAt(i,n,0,0),this.setDims(r,o),v(this,L,ou).call(this),this.width){const[h,l]=this.parentDimensions;this.setAspectRatio(this.width*h,this.height*l),this.setAt(e*h,s*l,this.width*h,this.height*l),b(this,co,!0),v(this,L,Ya).call(this),this.setDims(this.width*h,this.height*l),v(this,L,wo).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return v(this,L,au).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(c(this,uo)===i&&c(this,go)===n)return;b(this,uo,i),b(this,go,n),this.canvas.style.visibility="hidden";const[r,o]=this.parentDimensions;this.width=e/r,this.height=s/o,this.fixAndSetPosition(),c(this,bs)&&v(this,L,Gf).call(this,e,s),v(this,L,Ya).call(this),v(this,L,wo).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var _,y,x;if(e instanceof Yg)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=z.makeHexColor(...e.color),n.opacity=e.opacity;const[r,o]=n.pageDimensions,h=n.width*r,l=n.height*o,d=n.parentScale,u=e.thickness/2;b(n,bs,!0),b(n,uo,Math.round(h)),b(n,go,Math.round(l));const{paths:g,rect:f,rotation:p}=e;for(let{bezier:S}of g){S=v(_=kt,en,Ev).call(_,S,f,p);const C=[];n.paths.push(C);let E=d*(S[0]-u),M=d*(S[1]-u);for(let O=2,P=S.length;O<P;O+=6){const F=d*(S[O]-u),R=d*(S[O+1]-u),W=d*(S[O+2]-u),B=d*(S[O+3]-u),X=d*(S[O+4]-u),K=d*(S[O+5]-u);C.push([[E,M],[F,R],[W,B],[X,K]]),E=X,M=K}const k=v(this,en,Tv).call(this,C);n.bezierPath2D.push(k)}const m=v(y=n,L,Uf).call(y);return b(n,ao,Math.max(gt.MIN_SIZE,m[2]-m[0])),b(n,oo,Math.max(gt.MIN_SIZE,m[3]-m[1])),v(x=n,L,Gf).call(x,h,l),n}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),s=gt._colorManager.convert(this.ctx.strokeStyle);return{annotationType:Z.INK,color:s,thickness:this.thickness,opacity:this.opacity,paths:v(this,L,kv).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};oo=new WeakMap,ao=new WeakMap,li=new WeakMap,Zi=new WeakMap,bs=new WeakMap,ho=new WeakMap,lo=new WeakMap,co=new WeakMap,tn=new WeakMap,Ra=new WeakMap,uo=new WeakMap,go=new WeakMap,zn=new WeakMap,L=new WeakSet,mv=function(e){const s=n=>{this.thickness=n,v(this,L,Kl).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},bv=function(e){const s=n=>{this.color=n,v(this,L,wo).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},vv=function(e){const s=n=>{this.opacity=n,v(this,L,wo).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:U.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},yv=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Hf=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:r,scaleFactor:o}=this;e.lineWidth=n*r/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${Yw(i)}`},_v=function(e,s){this.canvas.addEventListener("contextmenu",hs,{signal:this._uiManager._signal}),v(this,L,Xf).call(this),b(this,ho,new AbortController);const i=this._uiManager.combinedSignal(c(this,ho));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,c(this,co)||(b(this,co,!0),v(this,L,Ya).call(this),this.thickness||(this.thickness=kt._defaultThickness),this.color||(this.color=kt._defaultColor||gt._defaultLineColor),this.opacity??(this.opacity=kt._defaultOpacity)),this.currentPath.push([e,s]),b(this,lo,!1),v(this,L,Hf).call(this),b(this,zn,()=>{v(this,L,Sv).call(this),c(this,zn)&&window.requestAnimationFrame(c(this,zn))}),window.requestAnimationFrame(c(this,zn))},Wf=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const r=this.currentPath;let o=c(this,Zi);if(r.push([e,s]),b(this,lo,!0),r.length<=2){o.moveTo(...r[0]),o.lineTo(e,s);return}r.length===3&&(b(this,Zi,o=new Path2D),o.moveTo(...r[0])),v(this,L,Cv).call(this,o,...r.at(-3),...r.at(-2),e,s)},wv=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);c(this,Zi).lineTo(...e)},xv=function(e,s){b(this,zn,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),v(this,L,Wf).call(this,e,s),v(this,L,wv).call(this);let i;if(this.currentPath.length!==1)i=v(this,L,Av).call(this);else{const l=[e,s];i=[[l,l.slice(),l.slice(),l]]}const n=c(this,Zi),r=this.currentPath;this.currentPath=[],b(this,Zi,new Path2D);const o=()=>{this.allRawPaths.push(r),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},h=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(v(this,L,ou).call(this),v(this,L,au).call(this)),v(this,L,Kl).call(this))};this.addCommands({cmd:o,undo:h,mustExec:!0})},Sv=function(){if(!c(this,lo))return;b(this,lo,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:r}=this;r.save(),r.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)r.stroke(o);r.stroke(c(this,Zi)),r.restore()},Cv=function(e,s,i,n,r,o,h){const l=(s+n)/2,d=(i+r)/2,u=(n+o)/2,g=(r+h)/2;e.bezierCurveTo(l+2*(n-l)/3,d+2*(r-d)/3,u+2*(n-u)/3,g+2*(r-g)/3,u,g)},Av=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,r]=e[0];for(i=1;i<e.length-2;i++){const[f,p]=e[i],[m,_]=e[i+1],y=(f+m)/2,x=(p+_)/2,S=[n+2*(f-n)/3,r+2*(p-r)/3],C=[y+2*(f-y)/3,x+2*(p-x)/3];s.push([[n,r],S,C,[y,x]]),[n,r]=[y,x]}const[o,h]=e[i],[l,d]=e[i+1],u=[n+2*(o-n)/3,r+2*(h-r)/3],g=[l+2*(o-l)/3,d+2*(h-d)/3];return s.push([[n,r],u,g,[l,d]]),s},wo=function(){if(this.isEmpty()){v(this,L,hu).call(this);return}v(this,L,Hf).call(this);const{canvas:e,ctx:s}=this;s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),v(this,L,hu).call(this);for(const i of this.bezierPath2D)s.stroke(i)},zf=function(){if(c(this,Ra))return;b(this,Ra,new AbortController);const e=this._uiManager.combinedSignal(c(this,Ra));this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:e})},Xf=function(){var e;(e=this.pointerdownAC)==null||e.abort(),this.pointerdownAC=null},Vf=function(e){var s;(s=c(this,ho))==null||s.abort(),b(this,ho,null),v(this,L,zf).call(this),c(this,li)&&clearTimeout(c(this,li)),b(this,li,setTimeout(()=>{b(this,li,null),this.canvas.removeEventListener("contextmenu",hs)},10)),v(this,L,xv).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},ou=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},au=function(){b(this,tn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),c(this,tn).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=c(this,tn))==null||e.disconnect(),b(this,tn,null)},{once:!0})},Ya=function(){if(!c(this,co))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),v(this,L,hu).call(this)},Gf=function(e,s){const i=v(this,L,lu).call(this),n=(e-i)/c(this,ao),r=(s-i)/c(this,oo);this.scaleFactor=Math.min(n,r)},hu=function(){const e=v(this,L,lu).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},en=new WeakSet,Tv=function(e){const s=new Path2D;for(let i=0,n=e.length;i<n;i++){const[r,o,h,l]=e[i];i===0&&s.moveTo(...r),s.bezierCurveTo(o[0],o[1],h[0],h[1],l[0],l[1])}return s},Yf=function(e,s,i){const[n,r,o,h]=s;switch(i){case 0:for(let l=0,d=e.length;l<d;l+=2)e[l]+=n,e[l+1]=h-e[l+1];break;case 90:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=e[l+1]+n,e[l+1]=u+r}break;case 180:for(let l=0,d=e.length;l<d;l+=2)e[l]=o-e[l],e[l+1]+=r;break;case 270:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=o-e[l+1],e[l+1]=h-u}break;default:throw new Error("Invalid rotation")}return e},Ev=function(e,s,i){const[n,r,o,h]=s;switch(i){case 0:for(let l=0,d=e.length;l<d;l+=2)e[l]-=n,e[l+1]=h-e[l+1];break;case 90:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=e[l+1]-r,e[l+1]=u-n}break;case 180:for(let l=0,d=e.length;l<d;l+=2)e[l]=o-e[l],e[l+1]-=r;break;case 270:for(let l=0,d=e.length;l<d;l+=2){const u=e[l];e[l]=h-e[l+1],e[l+1]=o-u}break;default:throw new Error("Invalid rotation")}return e},kv=function(e,s,i,n){var d,u;const r=[],o=this.thickness/2,h=e*s+o,l=e*i+o;for(const g of this.paths){const f=[],p=[];for(let m=0,_=g.length;m<_;m++){const[y,x,S,C]=g[m];if(y[0]===C[0]&&y[1]===C[1]&&_===1){const B=e*y[0]+h,X=e*y[1]+l;f.push(B,X),p.push(B,X);break}const E=e*y[0]+h,M=e*y[1]+l,k=e*x[0]+h,O=e*x[1]+l,P=e*S[0]+h,F=e*S[1]+l,R=e*C[0]+h,W=e*C[1]+l;m===0&&(f.push(E,M),p.push(E,M)),f.push(k,O,P,F,R,W),p.push(k,O),m===_-1&&p.push(R,W)}r.push({bezier:v(d=kt,en,Yf).call(d,f,n,this.rotation),points:v(u=kt,en,Yf).call(u,p,n,this.rotation)})}return r},Uf=function(){let e=1/0,s=-1/0,i=1/0,n=-1/0;for(const r of this.paths)for(const[o,h,l,d]of r){const u=z.bezierBoundingBox(...o,...h,...l,...d);e=Math.min(e,u[0]),i=Math.min(i,u[1]),s=Math.max(s,u[2]),n=Math.max(n,u[3])}return[e,i,s,n]},lu=function(){return c(this,bs)?Math.ceil(this.thickness*this.parentScale):0},Kl=function(e=!1){if(this.isEmpty())return;if(!c(this,bs)){v(this,L,wo).call(this);return}const s=v(this,L,Uf).call(this),i=v(this,L,lu).call(this);b(this,ao,Math.max(gt.MIN_SIZE,s[2]-s[0])),b(this,oo,Math.max(gt.MIN_SIZE,s[3]-s[1]));const n=Math.ceil(i+c(this,ao)*this.scaleFactor),r=Math.ceil(i+c(this,oo)*this.scaleFactor),[o,h]=this.parentDimensions;this.width=n/o,this.height=r/h,this.setAspectRatio(n,r);const l=this.translationX,d=this.translationY;this.translationX=-s[0],this.translationY=-s[1],v(this,L,Ya).call(this),v(this,L,wo).call(this),b(this,uo,n),b(this,go,r),this.setDims(n,r);const u=e?i/this.scaleFactor/2:0;this.translate(l-this.translationX-u,d-this.translationY-u)},w(kt,en),q(kt,"_defaultColor",null),q(kt,"_defaultOpacity",1),q(kt,"_defaultThickness",1),q(kt,"_type","ink"),q(kt,"_editorType",Z.INK);let $g=kt;const Il=class Il extends gt{constructor(e){super({...e,name:"stampEditor"});w(this,nt);w(this,Mt,null);w(this,oe,null);w(this,Xn,null);w(this,sn,null);w(this,Vn,null);w(this,La,"");w(this,ci,null);w(this,nn,null);w(this,di,null);w(this,ss,!1);w(this,Ia,!1);b(this,sn,e.bitmapUrl),b(this,Vn,e.bitmapFile)}static initialize(e,s){gt.initialize(e,s)}static get supportedTypes(){return ot(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(Z.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:r,height:o}=e||this.copyCanvas(null,null,!0).imageData,h=await i.guess({name:"altText",request:{data:n,width:r,height:o,channels:n.length/(r*o)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const l=h.output;return await this.setGuessedAltText(l),s&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}remove(){var e,s;c(this,oe)&&(b(this,Mt,null),this._uiManager.imageManager.deleteId(c(this,oe)),(e=c(this,ci))==null||e.remove(),b(this,ci,null),(s=c(this,nn))==null||s.disconnect(),b(this,nn,null),c(this,di)&&(clearTimeout(c(this,di)),b(this,di,null))),super.remove()}rebuild(){if(!this.parent){c(this,oe)&&v(this,nt,cu).call(this);return}super.rebuild(),this.div!==null&&(c(this,oe)&&c(this,ci)===null&&v(this,nt,cu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(c(this,Xn)||c(this,Mt)||c(this,sn)||c(this,Vn)||c(this,oe))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),c(this,Mt)?v(this,nt,qf).call(this):v(this,nt,cu).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}copyCanvas(e,s,i=!1){var f;e||(e=224);const{width:n,height:r}=c(this,Mt),o=new Tg;let h=c(this,Mt),l=n,d=r,u=null;if(s){if(n>s||r>s){const O=Math.min(s/n,s/r);l=Math.floor(n*O),d=Math.floor(r*O)}u=document.createElement("canvas");const p=u.width=Math.ceil(l*o.sx),m=u.height=Math.ceil(d*o.sy);c(this,ss)||(h=v(this,nt,du).call(this,p,m));const _=u.getContext("2d");_.filter=this._uiManager.hcmFilter;let y="white",x="#cfcfd8";this._uiManager.hcmFilter!=="none"?x="black":(f=window.matchMedia)!=null&&f.call(window,"(prefers-color-scheme: dark)").matches&&(y="#8f8f9d",x="#42414d");const S=15,C=S*o.sx,E=S*o.sy,M=new OffscreenCanvas(C*2,E*2),k=M.getContext("2d");k.fillStyle=y,k.fillRect(0,0,C*2,E*2),k.fillStyle=x,k.fillRect(0,0,C,E),k.fillRect(C,E,C,E),_.fillStyle=_.createPattern(M,"repeat"),_.fillRect(0,0,p,m),_.drawImage(h,0,0,h.width,h.height,0,0,p,m)}let g=null;if(i){let p,m;if(o.symmetric&&h.width<e&&h.height<e)p=h.width,m=h.height;else if(h=c(this,Mt),n>e||r>e){const x=Math.min(e/n,e/r);p=Math.floor(n*x),m=Math.floor(r*x),c(this,ss)||(h=v(this,nt,du).call(this,p,m))}const y=new OffscreenCanvas(p,m).getContext("2d",{willReadFrequently:!0});y.drawImage(h,0,0,h.width,h.height,0,0,p,m),g={width:p,height:m,data:y.getImageData(0,0,p,m).data}}return{canvas:u,width:l,height:d,imageData:g}}getImageForAltText(){return c(this,ci)}static async deserialize(e,s,i){var m;let n=null;if(e instanceof J0){const{data:{rect:_,rotation:y,id:x,structParent:S,popupRef:C},container:E,parent:{page:{pageNumber:M}}}=e,k=E.querySelector("canvas"),O=i.imageManager.getFromCanvas(E.id,k);k.remove();const P=((m=await s._structTree.getAriaAttributes(`${wg}${x}`))==null?void 0:m.get("aria-label"))||"";n=e={annotationType:Z.STAMP,bitmapId:O.id,bitmap:O.bitmap,pageIndex:M-1,rect:_.slice(0),rotation:y,id:x,deleted:!1,accessibilityData:{decorative:!1,altText:P},isSvg:!1,structParent:S,popupRef:C}}const r=await super.deserialize(e,s,i),{rect:o,bitmap:h,bitmapUrl:l,bitmapId:d,isSvg:u,accessibilityData:g}=e;d&&i.imageManager.isValidId(d)?(b(r,oe,d),h&&b(r,Mt,h)):b(r,sn,l),b(r,ss,u);const[f,p]=r.pageDimensions;return r.width=(o[2]-o[0])/f,r.height=(o[3]-o[1])/p,r.annotationElementId=e.id||null,g&&(r.altTextData=g),r._initialData=n,b(r,Ia,!!n),r}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:Z.STAMP,bitmapId:c(this,oe),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:c(this,ss),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=v(this,nt,uu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:r}=this.serializeAltText(!1);if(!n&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const h=v(this,nt,Dv).call(this,i);if(h.isSame)return null;h.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=c(this,ss)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(c(this,oe)))s.stamps.set(c(this,oe),{area:o,serialized:i}),i.bitmap=v(this,nt,uu).call(this,!1);else if(c(this,ss)){const h=s.stamps.get(c(this,oe));o>h.area&&(h.area=o,h.serialized.bitmap.close(),h.serialized.bitmap=v(this,nt,uu).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Mt=new WeakMap,oe=new WeakMap,Xn=new WeakMap,sn=new WeakMap,Vn=new WeakMap,La=new WeakMap,ci=new WeakMap,nn=new WeakMap,di=new WeakMap,ss=new WeakMap,Ia=new WeakMap,nt=new WeakSet,Ql=function(e,s=!1){if(!e){this.remove();return}b(this,Mt,e.bitmap),s||(b(this,oe,e.id),b(this,ss,e.isSvg)),e.file&&b(this,La,e.file.name),v(this,nt,qf).call(this)},Jl=function(){if(b(this,Xn,null),this._uiManager.enableWaiting(!1),!!c(this,ci)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,Mt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&c(this,Mt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},cu=function(){if(c(this,oe)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(c(this,oe)).then(i=>v(this,nt,Ql).call(this,i,!0)).finally(()=>v(this,nt,Jl).call(this));return}if(c(this,sn)){const i=c(this,sn);b(this,sn,null),this._uiManager.enableWaiting(!0),b(this,Xn,this._uiManager.imageManager.getFromUrl(i).then(n=>v(this,nt,Ql).call(this,n)).finally(()=>v(this,nt,Jl).call(this)));return}if(c(this,Vn)){const i=c(this,Vn);b(this,Vn,null),this._uiManager.enableWaiting(!0),b(this,Xn,this._uiManager.imageManager.getFromFile(i).then(n=>v(this,nt,Ql).call(this,n)).finally(()=>v(this,nt,Jl).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Il.supportedTypesStr;const s=this._uiManager._signal;b(this,Xn,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),v(this,nt,Ql).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>v(this,nt,Jl).call(this))),e.click()},qf=function(){const{div:e}=this;let{width:s,height:i}=c(this,Mt);const[n,r]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*r;else if(s>o*n||i>o*r){const u=Math.min(o*n/s,o*r/i);s*=u,i*=u}const[h,l]=this.parentDimensions;this.setDims(s*h/n,i*l/r),this._uiManager.enableWaiting(!1);const d=b(this,ci,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),v(this,nt,$f).call(this,s,i),v(this,nt,Ov).call(this),c(this,Ia)||(this.parent.addUndoableEditor(this),b(this,Ia,!0)),this._reportTelemetry({action:"inserted_image"}),c(this,La)&&d.setAttribute("aria-label",c(this,La))},Mv=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,c(this,di)!==null&&clearTimeout(c(this,di)),b(this,di,setTimeout(()=>{b(this,di,null),v(this,nt,$f).call(this,e,s)},200))},du=function(e,s){const{width:i,height:n}=c(this,Mt);let r=i,o=n,h=c(this,Mt);for(;r>2*e||o>2*s;){const l=r,d=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(r,o);u.getContext("2d").drawImage(h,0,0,l,d,0,0,r,o),h=u.transferToImageBitmap()}return h},$f=function(e,s){const i=new Tg,n=Math.ceil(e*i.sx),r=Math.ceil(s*i.sy),o=c(this,ci);if(!o||o.width===n&&o.height===r)return;o.width=n,o.height=r;const h=c(this,ss)?c(this,Mt):v(this,nt,du).call(this,n,r),l=o.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(h,0,0,h.width,h.height,0,0,n,r)},uu=function(e){if(e){if(c(this,ss)){const n=this._uiManager.imageManager.getSvgUrl(c(this,oe));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=c(this,Mt),s.getContext("2d").drawImage(c(this,Mt),0,0),s.toDataURL()}if(c(this,ss)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*bn.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*bn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,r);return o.getContext("2d").drawImage(c(this,Mt),0,0,c(this,Mt).width,c(this,Mt).height,0,0,n,r),o.transferToImageBitmap()}return structuredClone(c(this,Mt))},Ov=function(){this._uiManager._signal&&(b(this,nn,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&v(this,nt,Mv).call(this,s.width,s.height)})),c(this,nn).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=c(this,nn))==null||e.disconnect(),b(this,nn,null)},{once:!0}))},Dv=function(e){var l;const{rect:s,pageIndex:i,accessibilityData:{altText:n}}=this._initialData,r=e.rect.every((d,u)=>Math.abs(d-s[u])<1),o=e.pageIndex===i,h=(((l=e.accessibilityData)==null?void 0:l.alt)||"")===n;return{isSame:r&&o&&h,isSameAltText:h}},q(Il,"_type","stamp"),q(Il,"_editorType",Z.STAMP);let Kg=Il;const zs=class zs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:h,viewport:l,l10n:d}){w(this,ae);w(this,fo);w(this,ja,!1);w(this,ui,null);w(this,Gn,null);w(this,rn,null);w(this,is,new Map);w(this,Yn,!1);w(this,Na,!1);w(this,Ba,!1);w(this,ye,null);w(this,on,null);w(this,G);const u=[...c(zs,Un).values()];if(!zs._initialized){zs._initialized=!0;for(const g of u)g.initialize(d,t)}t.registerEditorTypes(u),b(this,G,t),this.pageIndex=e,this.div=s,b(this,fo,n),b(this,ui,r),this.viewport=l,b(this,ye,h),this.drawLayer=o,this._structTree=i,c(this,G).addLayer(this)}get isEmpty(){return c(this,is).size===0}get isInvisible(){return this.isEmpty&&c(this,G).getMode()===Z.NONE}updateToolbar(t){c(this,G).updateToolbar(t)}updateMode(t=c(this,G).getMode()){switch(v(this,ae,gu).call(this),t){case Z.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Z.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Z.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of c(zs,Un).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=c(this,ye))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(c(this,G).getMode()!==Z.INK)return;if(!t){for(const s of c(this,is).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){c(this,G).setEditingState(t)}addCommands(t){c(this,G).addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=c(this,ui))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of c(this,is).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(c(this,G).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!c(this,ui))return;const e=c(this,ui).getEditableAnnotations();for(const s of e){if(s.hide(),c(this,G).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;b(this,Ba,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of c(this,is).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(c(this,ui)){const n=c(this,ui).getEditableAnnotations();for(const r of n){const{id:o}=r.data;if(c(this,G).isDeletedAnnotationElement(o))continue;let h=e.get(o);if(h){h.resetAnnotationElement(r),h.show(!1),r.show();continue}h=t.get(o),h&&(c(this,G).addChangedExistingAnnotation(h),h.renderAnnotationElement(r)&&h.show(!1)),r.show()}}v(this,ae,gu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of c(zs,Un).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),b(this,Ba,!1)}getEditableAnnotation(t){var e;return((e=c(this,ui))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){c(this,G).getActive()!==t&&c(this,G).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=c(this,ye))!=null&&t.div&&!c(this,on)){b(this,on,new AbortController);const e=c(this,G).combinedSignal(c(this,on));c(this,ye).div.addEventListener("pointerdown",v(this,ae,Pv).bind(this),{signal:e}),c(this,ye).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=c(this,ye))!=null&&t.div&&c(this,on)&&(c(this,on).abort(),b(this,on,null),c(this,ye).div.classList.remove("highlighting"))}enableClick(){if(c(this,Gn))return;b(this,Gn,new AbortController);const t=c(this,G).combinedSignal(c(this,Gn));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;(t=c(this,Gn))==null||t.abort(),b(this,Gn,null)}attach(t){c(this,is).set(t.id,t);const{annotationElementId:e}=t;e&&c(this,G).isDeletedAnnotationElement(e)&&c(this,G).removeDeletedAnnotationElement(t)}detach(t){var e;c(this,is).delete(t.id),(e=c(this,fo))==null||e.removePointerInTextLayer(t.contentDiv),!c(this,Ba)&&t.annotationElementId&&c(this,G).addDeletedAnnotationElement(t)}remove(t){this.detach(t),c(this,G).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,c(this,Na)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(c(this,G).addDeletedAnnotationElement(t.annotationElementId),gt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),c(this,G).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),c(this,G).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!c(this,rn)&&(t._focusEventsAllowed=!1,b(this,rn,setTimeout(()=>{b(this,rn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:c(this,G)._signal}),e.focus())},0))),t._structTreeParentId=(s=c(this,fo))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return c(this,G).getId()}combinedSignal(t){return c(this,G).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=c(this,ae,Kf))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){c(this,G).updateToolbar(t),c(this,G).updateMode(t);const{offsetX:s,offsetY:i}=v(this,ae,Jf).call(this),n=this.getNextId(),r=v(this,ae,Qf).call(this,{parent:this,id:n,x:s,y:i,uiManager:c(this,G),isCentered:!0,...e});r&&this.add(r)}async deserialize(t){var e;return await((e=c(zs,Un).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,c(this,G)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=v(this,ae,Qf).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:c(this,G),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(v(this,ae,Jf).call(this),!0)}setSelected(t){c(this,G).setSelected(t)}toggleSelected(t){c(this,G).toggleSelected(t)}unselect(t){c(this,G).unselect(t)}pointerup(t){const{isMac:e}=Ee.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&c(this,Yn)){if(b(this,Yn,!1),!c(this,ja)){b(this,ja,!0);return}if(c(this,G).getMode()===Z.STAMP){c(this,G).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(c(this,G).getMode()===Z.HIGHLIGHT&&this.enableTextSelection(),c(this,Yn)){b(this,Yn,!1);return}const{isMac:e}=Ee.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;b(this,Yn,!0);const s=c(this,G).getActive();b(this,ja,!s||s.isEmpty())}findNewParent(t,e,s){const i=c(this,G).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=c(this,G).getActive())==null?void 0:t.parent)===this&&(c(this,G).commitOrRemove(),c(this,G).setActiveEditor(null)),c(this,rn)&&(clearTimeout(c(this,rn)),b(this,rn,null));for(const s of c(this,is).values())(e=c(this,fo))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,c(this,is).clear(),c(this,G).removeLayer(this)}render({viewport:t}){this.viewport=t,dr(this.div,t);for(const e of c(this,G).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){c(this,G).commitOrRemove(),v(this,ae,gu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,dr(this.div,{rotation:s}),e!==s)for(const i of c(this,is).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return c(this,G).viewParameters.realScale}};fo=new WeakMap,ja=new WeakMap,ui=new WeakMap,Gn=new WeakMap,rn=new WeakMap,is=new WeakMap,Yn=new WeakMap,Na=new WeakMap,Ba=new WeakMap,ye=new WeakMap,on=new WeakMap,G=new WeakMap,Un=new WeakMap,ae=new WeakSet,Pv=function(t){c(this,G).unselectAll();const{target:e}=t;if(e===c(this,ye).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&c(this,ye).div.contains(e)){const{isMac:s}=Ee.platform;if(t.button!==0||t.ctrlKey&&s)return;c(this,G).showAllEditors("highlight",!0,!0),c(this,ye).div.classList.add("free"),this.toggleDrawing(),yd.startHighlighting(this,c(this,G).direction==="ltr",{target:c(this,ye).div,x:t.x,y:t.y}),c(this,ye).div.addEventListener("pointerup",()=>{c(this,ye).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:c(this,G)._signal}),t.preventDefault()}},Kf=function(){return c(zs,Un).get(c(this,G).getMode())},Qf=function(t){const e=c(this,ae,Kf);return e?new e.prototype.constructor(t):null},Jf=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),o=Math.min(window.innerWidth,t+s),h=Math.min(window.innerHeight,e+i),l=(n+o)/2-t,d=(r+h)/2-e,[u,g]=this.viewport.rotation%180===0?[l,d]:[d,l];return{offsetX:u,offsetY:g}},gu=function(){b(this,Na,!0);for(const t of c(this,is).values())t.isEmpty()&&t.remove();b(this,Na,!1)},q(zs,"_initialized",!1),w(zs,Un,new Map([Ug,$g,Kg,yd].map(t=>[t._editorType,t])));let Qg=zs;const he=class he{constructor({pageIndex:t}){w(this,po);w(this,gi,null);w(this,jl,0);w(this,Wt,new Map);w(this,an,new Map);this.pageIndex=t}setParent(t){if(!c(this,gi)){b(this,gi,t);return}if(c(this,gi)!==t){if(c(this,Wt).size>0)for(const e of c(this,Wt).values())e.remove(),t.append(e);b(this,gi,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new Vg)}draw(t,e,s,i=!1){const n=Fe(this,jl)._++,r=v(this,po,tp).call(this,t.box);r.classList.add(...t.classNamesForDrawing);const o=he._svgFactory.createElement("defs");r.append(o);const h=he._svgFactory.createElement("path");o.append(h);const l=`path_p${this.pageIndex}_${n}`;h.setAttribute("id",l),h.setAttribute("d",t.toSVGPath()),i&&c(this,an).set(n,h);const d=v(this,po,Fv).call(this,o,l),u=he._svgFactory.createElement("use");return r.append(u),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),u.setAttribute("href",`#${l}`),c(this,Wt).set(n,r),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=Fe(this,jl)._++,s=v(this,po,tp).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=he._svgFactory.createElement("defs");s.append(i);const n=he._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const d=he._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=he._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const g=he._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${r}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const h=he._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${r}`),o&&h.setAttribute("mask",`url(#${o})`);const l=h.cloneNode();return s.append(l),h.classList.add("mainOutline"),l.classList.add("secondaryOutline"),c(this,Wt).set(e,s),e}finalizeLine(t,e){const s=c(this,an).get(t);c(this,an).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){c(this,Wt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){c(this,an).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;v(s=he,Nl,Zf).call(s,c(this,Wt).get(t),e)}show(t,e){c(this,Wt).get(t).classList.toggle("hidden",!e)}rotate(t,e){c(this,Wt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){c(this,Wt).get(t).setAttribute("fill",e)}changeOpacity(t,e){c(this,Wt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){c(this,Wt).get(t).classList.add(e)}removeClass(t,e){c(this,Wt).get(t).classList.remove(e)}getSVGRoot(t){return c(this,Wt).get(t)}remove(t){c(this,an).delete(t),c(this,gi)!==null&&(c(this,Wt).get(t).remove(),c(this,Wt).delete(t))}destroy(){b(this,gi,null);for(const t of c(this,Wt).values())t.remove();c(this,Wt).clear(),c(this,an).clear()}};gi=new WeakMap,jl=new WeakMap,Wt=new WeakMap,an=new WeakMap,Nl=new WeakSet,Zf=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`},po=new WeakSet,tp=function(t){var s;const e=he._svgFactory.create(1,1,!0);return c(this,gi).append(e),e.setAttribute("aria-hidden",!0),v(s=he,Nl,Zf).call(s,e,t),e},Fv=function(t,e){const s=he._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=he._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},w(he,Nl);let Jg=he;$.AbortException,$.AnnotationEditorLayer,$.AnnotationEditorParamsType,$.AnnotationEditorType,$.AnnotationEditorUIManager,$.AnnotationLayer,$.AnnotationMode,$.ColorPicker,$.DOMSVGFactory,$.DrawLayer,$.FeatureTest;var AS=$.GlobalWorkerOptions;$.ImageKind,$.InvalidPDFException,$.MissingPDFException,$.OPS,$.OutputScale,$.PDFDataRangeTransport,$.PDFDateString,$.PDFWorker,$.PasswordResponses,$.PermissionFlag,$.PixelsPerInch,$.RenderingCancelledException,$.TextLayer,$.UnexpectedResponseException,$.Util,$.VerbosityLevel,$.XfaLayer,$.build,$.createValidAbsoluteUrl,$.fetchData;var TS=$.getDocument;$.getFilenameFromUrl,$.getPdfFilenameFromUrl,$.getXfaPageViewport,$.isDataScheme,$.isPdfFile,$.noContextMenu,$.normalizeUnicode,$.setLayerDimensions,$.shadow,$.version;const ES={fabric:"^6.5.1","pdfjs-dist":"4.8.69"};function kS(a){return new Promise((t,e)=>{const s=new FileReader;s.addEventListener("load",()=>t(s.result)),s.addEventListener("error",e),s.readAsDataURL(a)})}const MS=ES["pdfjs-dist"].replace("^","");AS.workerSrc=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${MS}/pdf.worker.min.mjs`;async function OS(a){const t="data:application/pdf;base64,",e=await kS(a);if(typeof e=="string")return window.atob(e.slice(t.length))}function DS(a,t){return TS({data:a,password:t}).promise}const PS={top:100,left:50,scaleX:.5,scaleY:.5,borderColor:"black",cornerStrokeColor:"black",cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},FS={top:100,left:50,fontFamily:"helvetica",borderColor:"black",cornerStrokeColor:"black",scaleX:.7,scaleY:.7,cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},RS={stroke:"#000",hoverStroke:"#B7EC5D",src:""};function sb(a=""){let t=0,e=null,s=null,i=1,n={...RS};function r(){if(!a||as.has(a))return;const k=fw(a);return k.on("selection:cleared",()=>C(k)),k}function o(k,O){var R;const P=k.type,F={"application/pdf":h,"image/png":u,"image/jpeg":u};return((R=F[P])==null?void 0:R.call(F,k,O))??Promise.reject(new Error(`Unsupported ${P} file type.`))}async function h(k,O){const P=await OS(k);if(!P)return;const F=pw(k,P);try{return await l({page:1,PDFBase64:P,scale:.8,password:O}),{...F,pages:t}}catch(R){return Promise.reject(R)}}async function l({page:k,PDFBase64:O,scale:P,password:F}){try{const R=await DS(O,F),W=await Y.toRaw(R).getPage(k),{renderTask:B,canvas:X}=mw(W,P);return t=R.numPages,B.promise.then(()=>d(X))}catch(R){return Promise.reject(R)}}function d(k){vw(a,k)}async function u(k){return await yw(a,k)}async function g({url:k,scale:O=.5}){await o0(a,{url:k,scale:O})}async function f(k,O){const P=as.get(a);if(!P)return;const F=await ge.fromURL(k,{},{...PS,...O});P.add(F),m(P,F)}function p(k,O){const P=as.get(a);if(!P)return;const F=new ue(k,{...FS,...O});P.add(F),m(P,F)}function m(k,O){O.on("selected",P=>_({canvas:k,target:P.target})),O.on("modified",P=>ch(P.target,e)),O.on("scaling",P=>ch(P.transform.target,e)),O.on("moving",P=>ch(P.transform.target,e)),O.on("rotating",P=>ch(P.transform.target,e))}async function _({canvas:k,target:O,stroke:P=n.stroke,uuid:F=Date.now()}){if((e==null?void 0:e.stroke)===`${P}-${F}`)return;const R=await bw(n.src,P,F);C(k),e=R,s=O,y(k,O,F),x(i,!0),k.add(R)}function y(k,O,P){e&&(e.on("selected",()=>{k.remove(O),C(k)}),e.on("mouseover",()=>{_({canvas:k,target:O,stroke:n.hoverStroke,uuid:P})}),e.on("mouseout",()=>{_({canvas:k,target:O,stroke:n.stroke,uuid:P})}))}function x(k,O=!1){const P=as.get(a);i=k,P&&(ww(s,k,n),_w(s,k,e),!O&&P.renderAll())}function S(k){if(!k)return;n={...n,...k};const O=as.get(a);!e||!s||!O||_({target:s,canvas:O})}function C(k){e&&(k.remove(e),e=s=null)}function E(){xw(a)}function M(){Sw(a)}return{createCanvas:r,loadFile:o,specifyPage:l,renderImage:g,addFabric:f,addTextFabric:p,clearActive:E,deleteCanvas:M,scaleFabric:x,setCloseSvgOptions:S}}function LS(a){let t=0;const e=gw(()=>{t!==window.innerWidth&&(t=window.innerWidth,a())});Y.onMounted(()=>{window.addEventListener("resize",e)}),Y.onBeforeUnmount(()=>{window.removeEventListener("resize",e)})}const IS=Y.defineComponent({__name:"pdf-canvas",props:{file:{},page:{default:1},canvasId:{default:"PDF-canvas"},fileZoom:{default:1},fileScale:{default:1},canvasScale:{default:1},canvasClass:{default:""},isDrop:{type:Boolean,default:!1},password:{},dropTextOptions:{},dropImageOptions:{},closeSvgOptions:{}},setup(a,{expose:t}){const e=a,s=Y.ref(null),i=`${e.canvasId}-${e.page-1}`,n=Y.computed(()=>e.fileZoom*e.canvasScale),{createCanvas:r,specifyPage:o,addFabric:h,addTextFabric:l,renderImage:d,clearActive:u,deleteCanvas:g,scaleFabric:f,setCloseSvgOptions:p}=sb(i);m(),LS(m);async function m(){const{file:S,page:C,fileScale:E}=e;window.requestAnimationFrame(async()=>{if(await Y.nextTick(),r(),S.PDFBase64.startsWith("data:image")||S.canvas){const{canvas:M}=S,k=M?7:3,O=M!=null&&M.length?M[C-1]:S.PDFBase64;d({url:O,scale:E/k});return}await o({page:C,PDFBase64:S.PDFBase64,scale:E,password:e.password})})}function _(S){if(!e.isDrop||!S.dataTransfer)return;const{dataTransfer:C,offsetX:E,offsetY:M}=S,k=C.getData("text"),O=C.getData("image"),P={left:E-71,top:M-55};O&&y(O,P),k&&x(k,P)}function y(S,C){h(S,{...C,...e.dropImageOptions})}function x(S,C){l(S,{...C,...e.dropTextOptions})}return Y.watch([()=>e.fileScale,()=>e.page,()=>e.file,()=>e.password],m),Y.watch(n,S=>f(S),{immediate:!0}),Y.watch(()=>e.closeSvgOptions,p,{immediate:!0}),Y.onBeforeUnmount(g),t({addImage:y,addText:x,clearActive:u,deleteCanvas:g,canvasRef:s}),(S,C)=>(Y.openBlock(),Y.createElementBlock("div",{style:Y.normalizeStyle({transform:`scale(${n.value})`}),onDragover:C[0]||(C[0]=Y.withModifiers(()=>{},["stop","prevent"])),onDragenter:C[1]||(C[1]=Y.withModifiers(()=>{},["stop","prevent"])),onDrop:Y.withModifiers(_,["stop","prevent"])},[Y.createElementVNode("canvas",{id:i,ref_key:"canvasRef",ref:s,class:Y.normalizeClass(S.canvasClass)},null,2)],36))}}),_d=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));rt.default=IS,rt.useFabric=sb,Object.defineProperties(rt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});