PageSourceSearch

https://cdn.seame.ai/web/master/public/_nuxt/0YD0AGVK.js

js seame.ai collected 2026-10-02 01:16:00 UTC 315,560 bytes, 1 lines download raw bytes

1import{_ as t}from"./C9Y3eZR2.js";import{o as e,q as s,r as i,B as r,z as n,D as o,A as a,Q as h,s as c,w as l,b7 as u,ap as d,by as g,bv as f,a1 as p,bB as m,x as v,a as y,y as _,J as x,al as C,an as b,br as w,bP as S,bt as T,bu as O,ah as k,aj as D,ak as M,ag as E,a5 as j}from"./cSJXqLJP.js";import{g as P}from"./YMLz3lGn.js";import{a as A}from"./29-ojgIP.js";import{a as F,b as L}from"./CxzhUV-4.js";import{f as I,h as R}from"./BJg5L_K6.js";import{B}from"./Brl6AOMf.js";import{_ as W}from"./DLL-73DY.js";import{u as X}from"./CV8QpcOp.js";import{g as Y}from"./Cs0CWprB.js";import{u as V}from"./kZhsrzG4.js";import{uploadImageIns as H}from"./DpjsuU-Z.js";import{B as z}from"./C7wFnzWU.js";import{S as G}from"./C-c49lrL.js";import{P as N}from"./BzqHLkj5.js";import"./A5teTRza.js";import{_ as U,T as q}from"./BxOcbcob.js";import{_ as K}from"./CjP7cNSH.js";import{M as J}from"./DOIyEy7w.js";import{a as Z}from"./DVeFAIPx.js";import"./KOngkRup.js";import"./WTxLMT43.js";import"./DMGCbfwt.js";import"./DXBKKq3G.js";import"./C8O7Qn5t.js";import"./DjpUv2Du.js";import"./GAu3am23.js";import"./LvIr1giX.js";import"./CpYfQi_R.js";import"./NYSnit0S.js";import"./C1NgIiQP.js";import"./Bb_itNaH.js";import"./CQyXIe4c.js";import"./CrsYMdv7.js";import"./D658K2Ao.js";import"./D0RNJJ7a.js";import"./CYuXKwrG.js";import"./CCZgRATx.js";import"./Bkhzv7GX.js";import"./BDB8pUbi.js";import"./BS_bSTfS.js";import"./CEV2YTG-.js";import"./3g5ES1Ye.js";import"./0bUNwHje.js";import"./DyBguthx.js";import"./oVwFmAJF.js";import"./CwwCfN9U.js";import"./BAGUmzu1.js";import"./VPrdNIIw.js";import"./Be3998cI.js";import"./nTeQ7995.js";import"./D4n33-aV.js";import"./Fhx2l14Q.js";import"./BqX3D0Yp.js";import"./Cz1DCz5X.js";import"./ByfR_USM.js";import"./BUhdCGGt.js";import"./NnzZm7uT.js";import"./N59gm9wD.js";import"./DkNtyn64.js";function $(t,e,s){return(e="symbol"==typeof(i=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e,"string"))?i:i+"")in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t;var i}function Q(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),s.push.apply(s,i)}return s}function tt(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?Q(Object(s),!0).forEach(function(e){$(t,e,s[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Q(Object(s)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})}return t}function et(t,e){if(null==t)return{};var s,i,r=function(t,e){if(null==t)return{};var s={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)>=0)continue;s[i]=t[i]}return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i<n.length;i++)s=n[i],e.indexOf(s)>=0||{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function st(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class it{constructor(){$(this,"browserShadowBlurConstant",1),$(this,"DPI",96),$(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),$(this,"perfLimitSizeTotal",2097152),$(this,"maxCacheSideLimit",4096),$(this,"minCacheSideLimit",256),$(this,"disableStyleCopyPaste",!1),$(this,"enableGLFiltering",!0),$(this,"textureSize",4096),$(this,"forceGLPutImageData",!1),$(this,"cachesBoundsOfCurve",!1),$(this,"fontPaths",{}),$(this,"NUM_FRACTION_DIGITS",4)}}const rt=new class extends it{constructor(t){super(),this.configure(t)}configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,t)}addFonts(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fontPaths=tt(tt({},this.fontPaths),t)}removeFonts(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(t=>{delete this.fontPaths[t]})}clearFonts(){this.fontPaths={}}restoreDefaults(t){const e=new it,s=(null==t?void 0:t.reduce((t,s)=>(t[s]=e[s],t),{}))||e;this.configure(s)}},nt=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return console[t]("fabric",...s)};
1class ot extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class at extends ot{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class ht{}class ct extends ht{testPrecision(t,e){const s="precision ".concat(e," float;\nvoid 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(t=>this.testPrecision(e,t)),e.getExtension("WEBGL_lose_context").loseContext(),nt("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const lt={};let ut;const dt=()=>ut||(ut={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new ct,dispose(){},copyPasteData:lt}),gt=()=>dt().document,ft=()=>dt().window,pt=()=>{var t;return Math.max(null!==(t=rt.devicePixelRatio)&&void 0!==t?t:ft().devicePixelRatio,1)},mt=new class{constructor(){$(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(t){let{fontFamily:e,fontStyle:s,fontWeight:i}=t;e=e.toLowerCase();const r=this.charWidthsCache;r.has(e)||r.set(e,new Map);const n=r.get(e),o="".concat(s.toLowerCase(),"_").concat((i+"").toLowerCase());return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(t){t?this.charWidthsCache.delete((t||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(t){const{perfLimitSizeTotal:e}=rt,s=Math.sqrt(e*t);return[Math.floor(s),Math.floor(e/s)]}},vt="6.9.1";function yt(){}const _t=Math.PI/2,xt=2*Math.PI,Ct=Math.PI/180,bt=Object.freeze([1,0,0,1,0,0]),wt=16,St=.4477152502,Tt="center",Ot="left",kt="top",Dt="bottom",Mt="right",Et="none",jt=/\r?\n/,Pt="moving",At="scaling",Ft="rotating",Lt="rotate",It="skewing",Rt="resizing",Bt="modifyPoly",Wt="modifyPath",Xt="changed",Yt="scale",Vt="scaleX",Ht="scaleY",zt="skewX",Gt="skewY",Nt="fill",Ut="stroke",qt="modified",Kt="json",Jt="svg",Zt=new class{constructor(){this[Kt]=new Map,this[Jt]=new Map}has(t){return this[Kt].has(t)}getClass(t){const e=this[Kt].get(t);if(!e)throw new ot("No class registered for ".concat(t));return e}setClass(t,e){e?this[Kt].set(e,t):(this[Kt].set(t.type,t),this[Kt].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[Jt].get(t)}setSVGClass(t,e){this[Jt].set(null!=e?e:t.type.toLowerCase(),t)}},$t=new class extends Array{remove(t){const e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){const t=this.splice(0);return t.forEach(t=>t.abort()),t}cancelByCanvas(t){if(!t)return[];const e=this.filter(e=>{var s;return e.target===t||"object"==typeof e.target&&(null===(s=e.target)||void 0===s?void 0:s.canvas)===t});return e.forEach(t=>t.abort()),e}cancelByTarget(t){if(!t)return[];const e=this.filter(e=>e.target===t);return e.forEach(t=>t.abort()),e}};class Qt{constructor(){$(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)return Object.entries(t).forEach(t=>{let[e,s]=t;this.on(e,s)}),()=>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("object"==typeof t){const e=[];return Object.entries(t).forEach(t=>{let[s,i]=t;e.push(this.once(s,i))}),()=>e.forEach(t=>t())}if(e){const s=this.on(t,function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];e.call(this,...i),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(void 0===t)for(const s in this.__eventListeners)this._removeEventListener(s);else"object"==typeof t?Object.entries(t).forEach(t=>{let[e,s]=t;this._removeEventListener(e,s)}):this._removeEventListener(t,e)}fire(t,e){var s;if(!this.__eventListeners)return;const i=null===(s=this.__eventListeners[t])||void 0===s?void 0:s.concat();if(i)for(let r=0;r<i.length;r++)i[r].call(this,e||{})}}const te=(t,e)=>{const s=t.indexOf(e);return-1!==s&&t.splice(s,1),t},ee=t=>{if(0===t)return 1;switch(Math.abs(t)/_t){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},se=t=>{if(0===t)return 0;const e=t/_t,s=Math.sign(t);switch(e){case 1:return s;case 2:return 0;case 3:return-s}return Math.sin(t)};class ie{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new ie(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ie(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ie(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ie(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ie(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ie(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ie(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ie(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&&void 0!==arguments[1]?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new ie(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 ie(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ie(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 ie(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:re;const s=se(t),i=ee(t),r=this.subtract(e);return new ie(r.x*i-r.y*s,r.x*s+r.y*i).add(e)}transform(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new ie(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 re=new ie(0,0),ne=t=>!!t&&Array.isArray(t._objects);function oe(t){class e extends t{constructor(){super(...arguments),$(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];const i=this._objects.push(...e);return e.forEach(t=>this._onObjectAdded(t)),i}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];
1return this._objects.splice(t,0,...s),s.forEach(t=>this._onObjectAdded(t)),this._objects.length}remove(){const t=this._objects,e=[];for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return i.forEach(s=>{const i=t.indexOf(s);-1!==i&&(t.splice(i,1),e.push(s),this._onObjectRemoved(s))}),e}forEachObject(t){this.getObjects().forEach((e,s,i)=>t(e,s,i))}getObjects(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return 0===e.length?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,s){return!!this._objects.includes(t)||!!s&&this._objects.some(s=>s instanceof e&&s.contains(t,!0))}complexity(){return this._objects.reduce((t,e)=>t+(e.complexity?e.complexity():0),0)}sendObjectToBack(t){return!(!t||t===this._objects[0]||(te(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),0))}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1]||(te(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),0))}sendObjectBackwards(t,e){if(!t)return!1;const s=this._objects.indexOf(t);if(0!==s){const i=this.findNewLowerIndex(t,s,e);return te(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;const s=this._objects.indexOf(t);if(s!==this._objects.length-1){const i=this.findNewUpperIndex(t,s,e);return te(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(te(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,s){let i;if(s){i=e;for(let s=e-1;s>=0;--s)if(t.isOverlapping(this._objects[s])){i=s;break}}else i=e-1;return i}findNewUpperIndex(t,e,s){let i;if(s){i=e;for(let s=e+1;s<this._objects.length;++s)if(t.isOverlapping(this._objects[s])){i=s;break}}else i=e+1;return i}collectObjects(t){let{left:e,top:s,width:i,height:r}=t,{includeIntersecting:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ie(e,s),h=a.add(new ie(i,r));for(let c=this._objects.length-1;c>=0;c--){const t=this._objects[c];t.selectable&&t.visible&&(n&&t.intersectsWithRect(a,h)||t.isContainedWithinRect(a,h)||n&&t.containsPoint(a)||n&&t.containsPoint(h))&&o.push(t)}return o}}return e}class ae extends Qt{_setOptions(){let t=arguments.length>0&&void 0!==arguments[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"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}}function he(t){return ft().requestAnimationFrame(t)}let ce=0;const le=()=>ce++,ue=()=>{const t=gt().createElement("canvas");if(!t||void 0===t.getContext)throw new ot("Failed to create `canvas` element");return t},de=t=>{const e=ue();return e.width=t.width,e.height=t.height,e},ge=(t,e,s)=>t.toDataURL("image/".concat(e),s),fe=(t,e,s)=>new Promise((i,r)=>{t.toBlob(i,"image/".concat(e),s)}),pe=t=>t*Ct,me=t=>t/Ct,ve=(t,e,s)=>new ie(t).transform(e,s),ye=t=>{const e=1/(t[0]*t[3]-t[1]*t[2]),s=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:i,y:r}=new ie(t[4],t[5]).transform(s,!0);return s[4]=-i,s[5]=-r,s},_e=(t,e,s)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],s?0:t[0]*e[4]+t[2]*e[5]+t[4],s?0:t[1]*e[4]+t[3]*e[5]+t[5]],xe=(t,e)=>t.reduceRight((t,s)=>s&&t?_e(s,t,e):s||t,void 0)||bt.concat(),Ce=t=>{let[e,s]=t;return Math.atan2(s,e)},be=t=>{const e=Ce(t),s=Math.pow(t[0],2)+Math.pow(t[1],2),i=Math.sqrt(s),r=(t[0]*t[3]-t[2]*t[1])/i,n=Math.atan2(t[0]*t[2]+t[1]*t[3],s);return{angle:me(e),scaleX:i,scaleY:r,skewX:me(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},we=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Se(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:e=0,y:s=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=pe(t),r=ee(i),n=se(i);return[r,n,-n,r,e?e-(r*e-n*s):0,s?s-(n*e+r*s):0]}const Te=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Oe=t=>Math.tan(pe(t)),ke=t=>[1,0,Oe(t),1,0,0],De=t=>[1,Oe(t),0,1,0,0],Me=t=>{let{scaleX:e=1,scaleY:s=1,flipX:i=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Te(i?-e:e,r?-s:s);return n&&(a=_e(a,ke(n),!0)),o&&(a=_e(a,De(o),!0)),a},Ee=t=>{const{translateX:e=0,translateY:s=0,angle:i=0}=t;let r=we(e,s);i&&(r=_e(r,Se({angle:i})));const n=Me(t);return(t=>t.every((t,e)=>t===bt[e]))(n)||(r=_e(r,n)),r},je=function(t){let{signal:e,crossOrigin:s=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(i,r){if(e&&e.aborted)return r(new at("loadImage"));const n=gt().createElement("img");let o;e&&(o=function(t){n.src="",r(t)},e.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(null==e||e.removeEventListener("abort",o)),i(n)};t?(n.onload=a,n.onerror=function(){o&&(null==e||e.removeEventListener("abort",o)),r(new ot("Error loading ".concat(n.src)))},s&&(n.crossOrigin=s),n.src=t):a()})},Pe=function(t){let{signal:e,reviver:s=yt}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{const n=[];e&&e.addEventListener("abort",r,{once:!0}),Promise.all(t.map(t=>Zt.getClass(t.type).fromObject(t,{signal:e}).then(e=>(s(t,e),n.push(e),e)))).then(i).catch(t=>
1{n.forEach(t=>{t.dispose&&t.dispose()}),r(t)}).finally(()=>{e&&e.removeEventListener("abort",r)})})},Ae=function(t){let{signal:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((s,i)=>{const r=[];e&&e.addEventListener("abort",i,{once:!0});const n=Object.values(t).map(t=>t&&t.type&&Zt.has(t.type)?Pe([t],{signal:e}).then(t=>{let[e]=t;return r.push(e),e}):t),o=Object.keys(t);Promise.all(n).then(t=>t.reduce((t,e,s)=>(t[o[s]]=e,t),{})).then(s).catch(t=>{r.forEach(t=>{t.dispose&&t.dispose()}),i(t)}).finally(()=>{e&&e.removeEventListener("abort",i)})})},Fe=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce((e,s)=>(s in t&&(e[s]=t[s]),e),{})},Le=(t,e)=>Object.keys(t).reduce((s,i)=>(e(t[i],i,t)&&(s[i]=t[i]),s),{}),Ie=(t,e)=>parseFloat(Number(t).toFixed(e)),Re=t=>"matrix("+t.map(t=>Ie(t,rt.NUM_FRACTION_DIGITS)).join(" ")+")",Be=t=>!!t&&void 0!==t.toLive,We=t=>!!t&&"function"==typeof t.toObject,Xe=t=>!!t&&void 0!==t.offsetX&&"source"in t,Ye=t=>!!t&&"multiSelectionStacking"in t;function Ve(t){const e=t&&He(t);let s=0,i=0;if(!t||!e)return{left:s,top:i};let r=t;const n=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===e?(s=o.scrollLeft||n.scrollLeft||0,i=o.scrollTop||n.scrollTop||0):(s+=r.scrollLeft||0,i+=r.scrollTop||0),1!==r.nodeType||"fixed"!==r.style.position););return{left:s,top:i}}const He=t=>t.ownerDocument||null,ze=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},Ge=function(t,e,s){let{width:i,height:r}=s,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=i,t.height=r,n>1&&(t.setAttribute("width",(i*n).toString()),t.setAttribute("height",(r*n).toString()),e.scale(n,n))},Ne=(t,e)=>{let{width:s,height:i}=e;s&&(t.style.width="number"==typeof s?"".concat(s,"px"):s),i&&(t.style.height="number"==typeof i?"".concat(i,"px"):i)};function Ue(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=Et,t}class qe{constructor(t){$(this,"_originalCanvasStyle",void 0),$(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&void 0!==s.getContext?t:t&&gt().getElementById(t)||ue();var s;if(e.hasAttribute("data-fabric"))throw new ot("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;Ge(s,i,t,e)}setCSSDimensions(t){Ne(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&He(t),i={left:0,top:0};if(!s)return i;const r=(null===(e=ze(t))||void 0===e?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(r.borderLeftWidth,10)||0,i.top+=parseInt(r.borderTopWidth,10)||0,i.left+=parseInt(r.paddingLeft,10)||0,i.top+=parseInt(r.paddingTop,10)||0;let n={left:0,top:0};const o=s.documentElement;void 0!==t.getBoundingClientRect&&(n=t.getBoundingClientRect());const a=Ve(t);return{left:n.left+a.left-(o.clientLeft||0)+i.left,top:n.top+a.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){dt().dispose(this.lower.el),delete this.lower}}const Ke={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...bt]},Je=["objects"];class Ze extends(oe(ae)){get lowerCanvasEl(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.el}get contextContainer(){var t;return null===(t=this.elements.lower)||void 0===t?void 0:t.ctx}static getDefaults(){return Ze.ownDefaults}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?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}
vendor: 9,448 bytes, line 1
1),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new qe(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 r=super.insertAt(t,...s);return s.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(nt("warn","Canvas is trying to add an object that belongs to a different canvas.\nResulting 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?pt():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&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e=tt({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.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],r=ve(t,ye(i));i[0]=e,i[3]=e;const n=ve(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ie(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 ie(-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=he(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,s=ye(this.viewportTransform),i=ve({x:0,y:0},s),r=ve({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new ie(o.x,n.y),bl:new ie(n.x,o.y),br:o}}cancelRequestedRender(){var t;this.nextRenderHandle&&(t=this.nextRenderHandle,ft().cancelAnimationFrame(t),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")],r=this.viewportTransform,n=this["".concat(e,"Vpt")];if(!s&&!i)return;const o=Be(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,n&&t.transform(...r),o){t.transform(1,0,0,1,s.offsetX||0,s.offsetY||0);const e=s.gradientTransform||s.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:e}=this;this.skipOffscreen=n,n&&t.transform(...r),i.render(t),this.skipOffscreen=e,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 ie(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new ie(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new ie(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 ie(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new ie(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ve(this.getCenterPoint(),ye(this.viewportTransform))}_centerObject(t,e){t.setXY(e,Tt,Tt),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 tt(tt(tt({version:vt},Fe(this,e)),{},{objects:this._objects.filter(t=>!t.excludeFromExport).map(s=>this._toObject(s,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 r=t[e](s);return this.includeDefaultValues||(t.includeDefaultValues=!!i),r}__serializeBgOverlay(t,e){const s={},i=this.backgroundImage,r=this.overlayImage,n=this.backgroundColor,o=this.overlayColor;return Be(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),Be(o)?o.excludeFromExport||(s.overlay=o.toObject(e)):o&&(s.overlay=o),i&&!i.excludeFromExport&&(s.backgroundImage=this._toObject(i,t,e)),r&&!r.excludeFromExport&&(s.overlayImage=this._toObject(r,t,e)),s}toSVG(){let t=arguments.length>0&&void 0!==arguments[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,')" >\n')),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push("</g>\n"),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" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')}_setSVGHeader(t,e){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=rt.NUM_FRACTION_DIGITS,n=e.viewBox;let o;if(n)o='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const t=this.viewportTransform;o='viewBox="'.concat(Ie(-t[4]/t[0],r)," ").concat(Ie(-t[5]/t[3],r)," ").concat(Ie(this.width/t[0],r)," ").concat(Ie(this.height/t[3],r),'" ')}else o='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',s,'" ','height="',i,'" ',o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",vt,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(le()),'<clipPath id="'.concat(e.clipPathId,'" >\n').concat(e.toClipPathSVG(t.reviver),"</clipPath>\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(Be(e)){const s=this["".concat(t,"Vpt")],i=this.viewportTransform,r={isType:()=>!1,width:this.width/(s?i[0]:1),height:this.height/(s?i[3]:1)};return e.toSVG(r,{additionalTransform:s?Re(i):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=rt.fontPaths;
1this._objects.forEach(function e(s){t.push(s),ne(s)&&s._objects.forEach(e)}),t.forEach(t=>{if(!(i=t)||"function"!=typeof i._renderText)return;var i;const{styles:r,fontFamily:n}=t;!e[n]&&s[n]&&(e[n]=!0,r&&Object.values(r).forEach(t=>{Object.values(t).forEach(t=>{let{fontFamily:i=""}=t;!e[i]&&s[i]&&(e[i]=!0)})}))});const i=Object.keys(e).map(t=>"\t\t@font-face {\n\t\t\tfont-family: '".concat(t,"';\n\t\t\tsrc: url('").concat(s[t],"');\n\t\t}\n")).join("");return i?'\t<style type="text/css"><![CDATA[\n'.concat(i,"]]></style>\n"):""}_setSVGObjects(t,e){this.forEachObject(s=>{s.excludeFromExport||this._setSVGObject(t,s,e)})}_setSVGObject(t,e,s){t.push(e.toSVG(s))}_setSVGBgOverlayImage(t,e,s){const i=this[e];i&&!i.excludeFromExport&&i.toSVG&&t.push(i.toSVG(s))}_setSVGBgOverlayColor(t,e){const s=this["".concat(e,"Color")];if(s)if(Be(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Re(ye(this.viewportTransform)):"";t.push('<rect transform="'.concat(o," translate(").concat(r/2,",").concat(n/2,')" x="').concat(s.offsetX-r/2,'" y="').concat(s.offsetY-n/2,'" width="').concat("repeat-y"!==i&&"no-repeat"!==i||!Xe(s)?r:s.source.width,'" height="').concat("repeat-x"!==i&&"no-repeat"!==i||!Xe(s)?n:s.source.height,'" fill="url(#SVGID_').concat(s.id,')"></rect>\n'))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',s,'"',"></rect>\n")}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new ot("`json` is undefined"));const i="string"==typeof t?JSON.parse(t):t,{objects:r=[]}=i,n=et(i,Je),{backgroundImage:o,background:a,overlayImage:h,overlay:c,clipPath:l}=n,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Pe(r,{reviver:e,signal:s}),Ae({backgroundImage:o,backgroundColor:a,overlayImage:h,overlayColor:c,clipPath:l},{signal:s})]).then(t=>{let[e,s]=t;return this.clear(),this.add(...e),this.set(n),this.set(s),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=de(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:s=1,multiplier:i=1,enableRetinaScaling:r=!1}=t,n=i*(r?this.getRetinaScaling():1);return ge(this.toCanvasElement(n,t),e,s)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{format:e="png",quality:s=1,multiplier:i=1,enableRetinaScaling:r=!1}=t,n=i*(r?this.getRetinaScaling():1);return fe(this.toCanvasElement(n,t),e,s)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,{width:e,height:s,left:i,top:r,filter:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=(e||this.width)*t,a=(s||this.height)*t,h=this.getZoom(),c=this.width,l=this.height,u=this.skipControlsDrawing,d=h*t,g=this.viewportTransform,f=[d,0,0,d,(g[4]-(i||0))*t,(g[5]-(r||0))*t],p=this.enableRetinaScaling,m=de({width:o,height:a}),v=n?this._objects.filter(t=>n(t)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=o,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),v),this.viewportTransform=g,this.width=c,this.height=l,this.calcViewportBoundaries(),this.enableRetinaScaling=p,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),$t.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const s=()=>{this.destroy(),t(!0)};s.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=s:s()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}$(Ze,"ownDefaults",Ke);const $e=["touchstart","touchmove","touchend"],Qe=t=>$e.includes(t.type)||"touch"===t.pointerType,ts=t=>{t.preventDefault(),t.stopPropagation()},es=t=>{let e=0,s=0,i=0,r=0;for(let n=0,o=t.length;n<o;n++){const{x:o,y:a}=t[n];(o>
vendor: 6,464 bytes, line 1
1i||!n)&&(i=o),(o<e||!n)&&(e=o),(a>r||!n)&&(r=a),(a<s||!n)&&(s=a)}return{left:e,top:s,width:i-e,height:r-s}},ss=["translateX","translateY","scaleX","scaleY"],is=(t,e)=>{const s=be(e),{translateX:i,translateY:r,scaleX:n,scaleY:o}=s,a=et(s,ss),h=new ie(i,r);t.flipX=!1,t.flipY=!1,Object.assign(t,a),t.set({scaleX:n,scaleY:o}),t.setPositionByOrigin(h,Tt,Tt)},rs=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),ns=(t,e,s)=>{const i=t/2,r=e/2,n=[new ie(-i,-r),new ie(i,-r),new ie(-i,r),new ie(i,r)].map(t=>t.transform(s)),o=es(n);return new ie(o.width,o.height)},os=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:bt;return _e(ye(arguments.length>1&&void 0!==arguments[1]?arguments[1]:bt),t)},as=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:bt,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:bt;return t.transform(os(e,s))},hs=(t,e)=>{var s;const{transform:{target:i}}=e;null===(s=i.canvas)||void 0===s||s.fire("object:".concat(t),tt(tt({},e),{},{target:i})),i.fire(t,e)},cs={left:-.5,top:-.5,center:0,bottom:.5,right:.5},ls=t=>"string"==typeof t?cs[t]:t-.5,us="not-allowed";function ds(t){return ls(t.originX)===ls(Tt)&&ls(t.originY)===ls(Tt)}function gs(t){return.5-ls(t)}const fs=(t,e)=>t[e],ps=(t,e,s,i)=>({e:t,transform:e,pointer:new ie(s,i)});function ms(t,e){const s=t.getTotalAngle()+me(Math.atan2(e.y,e.x))+360;return Math.round(s%360/45)}function vs(t,e,s,i,r){var n;let{target:o,corner:a}=t;const h=o.controls[a],c=(null===(n=o.canvas)||void 0===n?void 0:n.getZoom())||1,l=o.padding/c,u=function(t,e,s,i){const r=t.getRelativeCenterPoint(),n=void 0!==s&&void 0!==i?t.translateToGivenOrigin(r,Tt,Tt,s,i):new ie(t.left,t.top);return(t.angle?e.rotate(-pe(t.angle),r):e).subtract(n)}(o,new ie(i,r),e,s);return u.x>=l&&(u.x-=l),u.x<=-l&&(u.x+=l),u.y>=l&&(u.y-=l),u.y<=l&&(u.y+=l),u.x-=h.offsetX,u.y-=h.offsetY,u}const ys=(t,e,s,i)=>{const{target:r,offsetX:n,offsetY:o}=e,a=s-n,h=i-o,c=!fs(r,"lockMovementX")&&r.left!==a,l=!fs(r,"lockMovementY")&&r.top!==h;return c&&r.set(Ot,a),l&&r.set(kt,h),(c||l)&&hs(Pt,ps(t,e,s,i)),c||l},_s=t=>t.replace(/\s+/g," "),xs={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"},Cs=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),bs=(t,e,s,i)=>{t/=255,e/=255,s/=255;const r=Math.max(t,e,s),n=Math.min(t,e,s);let o,a;const h=(r+n)/2;if(r===n)o=a=0;else{const i=r-n;switch(a=h>.5?i/(2-r-n):i/(r+n),r){case t:o=(e-s)/i+(e<s?6:0);break;case e:o=(s-t)/i+2;break;case s:o=(t-e)/i+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*h),i]},ws=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},Ss=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Ts=t=>{let[e,s,i,r=1]=t;const n=Math.round(.3*e+.59*s+.11*i);return[n,n,n,r]};class Os{constructor(t){if($(this,"isUnrecognised",!1),t)if(t instanceof Os)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,s,i,r=1]=t;this.setSource([e,s,i,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in xs&&(t=xs[t]),"transparent"===t?[255,255,255,0]:Os.sourceFromHex(t)||Os.sourceFromRgb(t)||Os.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(","),")")}
1toHsl(){const[t,e,s]=bs(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=bs(...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(Ss(t)).concat(Ss(e)).concat(Ss(s)).concat(Ss(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ts(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Ts(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof Os||(t=new Os(t));const e=this.getSource(),s=t.getSource(),[i,r,n]=e.map((t,e)=>Math.round(.5*t+.5*s[e]));return this.setSource([i,r,n,e[3]]),this}static fromRgb(t){return Os.fromRgba(t)}static fromRgba(t){return new Os(Os.sourceFromRgb(t))}static sourceFromRgb(t){const e=_s(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[t,s,i]=e.slice(1,4).map(t=>{const e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e});return[t,s,i,ws(e[4])]}}static fromHsl(t){return Os.fromHsla(t)}static fromHsla(t){return new Os(Os.sourceFromHsl(t))}static sourceFromHsl(t){const e=_s(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=(Os.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let n,o,a;if(0===i)n=o=a=r;else{const t=r<=.5?r*(i+1):r+i-r*i,e=2*r-t;n=Cs(e,t,s+1/3),o=Cs(e,t,s),a=Cs(e,t,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),ws(e[4])]}static fromHex(t){return new Os(Os.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(t=>t+t):e.match(/.{2}/g);const[i,r,n,o=255]=s.map(t=>parseInt(t,16));return[i,r,n,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),s=parseFloat(e);return e.includes("rad")?me(s):e.includes("turn")?360*s:s}}const ks=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wt;const s=/\D{0,2}$/.exec(t),i=parseFloat(t),r=rt.DPI;switch(null==s?void 0:s[0]){case"mm":return i*r/25.4;case"cm":return i*r/2.54;case"in":return i*r;case"pt":return i*r/72;case"pc":return i*r/72*12;case"em":return i*e;default:return i}},Ds=function(t,e){let s,i,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(e.toLive)s="url(#SVGID_".concat(e.id,")");else{const t=new Os(e),r=t.getAlpha();s=t.toRgb(),1!==r&&(i=r.toString())}else s="none";return r?"".concat(t,": ").concat(s,"; ").concat(i?"".concat(t,"-opacity: ").concat(i,"; "):""):"".concat(t,'="').concat(s,'" ').concat(i?"".concat(t,'-opacity="').concat(i,'" '):"")};class Ms{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):Et,r=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",h=void 0!==this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",l=t?"":this.getSvgFilter(),u=Ds(Nt,this.fill);return[Ds(Ut,this.stroke),"stroke-width: ",s,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",u,"fill-rule: ",e,"; ","opacity: ",h,";",l,c].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t?this.calcTransformMatrix():this.calcOwnMatrix(),i='transform="'.concat(Re(s));
vendor: 5,909 bytes, line 1
1return"".concat(i).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:s=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[this.getSvgTransform(!0,s),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:s,withShadow:i,additionalTransform:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e?"":'style="'.concat(this.getSvgStyles(),'" '),o=i?'style="'.concat(this.getSvgFilter(),'" '):"",a=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=a&&a.absolutePositioned,l=this.stroke,u=this.fill,d=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let p;a&&(a.clipPathId="CLIPPATH_".concat(le()),p='<clipPath id="'.concat(a.clipPathId,'" >\n').concat(a.toClipPathSVG(s),"</clipPath>\n")),c&&g.push("<g ",o,this.getSvgCommons()," >\n"),g.push("<g ",this.getSvgTransform(!1),c?"":o+this.getSvgCommons()," >\n");const m=[n,h,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,Be(u)&&g.push(u.toSVG(this)),Be(l)&&g.push(l.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push("</g>\n"),c&&g.push("</g>\n"),s?s(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Nt?' paint-order="'.concat(this.paintFirst,'" '):""}}function Es(t){return new RegExp("^("+t.join("|")+")\\b","i")}const js="textDecorationThickness",Ps=["fontSize","fontWeight","fontFamily","fontStyle"],As=["underline","overline","linethrough"],Fs=[...Ps,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Ls=[...Fs,...As,"textBackgroundColor","direction",js],Is=[...Ps,...As,Ut,"strokeWidth",Nt,"deltaY","textBackgroundColor",js],Rs={_reNewline:jt,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Ot,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Ot,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[js]:66.667},Bs="justify",Ws="justify-left",Xs="justify-right",Ys="justify-center";var Vs,Hs,zs;const Gs=String.raw(Vs||(Vs=st(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Ns=String.raw(Hs||(Hs=st(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),Us=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Gs+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Gs+"))?\\s+(.*)"),qs={cx:Ot,x:Ot,r:"radius",cy:kt,y:kt,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":js},Ks="font-size",Js="clip-path";Es(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Es(["symbol","image","marker","pattern","view","svg"]);const Zs=Es(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(zs||(zs=st(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Gs,Ns,Gs,Ns,Gs,Ns,Gs));const $s=new ie(1,0),Qs=new ie,ti=(t,e)=>t.rotate(e),ei=(t,e)=>new ie(e).subtract(t),si=t=>t.distanceFrom(Qs),ii=(t,e)=>Math.atan2(oi(t,e),ai(t,e)),ri=t=>t.eq(Qs)?t:t.scalarDivide(si(t)),ni=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ri(new ie(-t.y,t.x).scalarMultiply(e?1:-1))},oi=(t,e)=>t.x*e.y-t.y*e.x,ai=(t,e)=>t.x*e.x+t.y*e.y,hi=(t,e,s)=>{if(t.eq(e)||t.eq(s))return!0;const i=oi(e,s),r=oi(e,t),n=oi(s,t);return i>=0?r>=0&&n<=0:!(r<=0&&n>=0)},ci="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",li=new RegExp("(?:\\s|^)"+ci+ci+"("+Gs+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ui{constructor(t){const e="string"==typeof t?ui.parseShadow(t):t;Object.assign(this,ui.ownDefaults,e),this.id=le()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(li.exec(e)||[]).map(t=>parseFloat(t)||0);return{color:(e.replace(li,"")||"rgb(0,0,0)").trim(),offsetX:s,offsetY:i,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=ti(new ie(this.offsetX,this.offsetY),pe(-t.angle)),s=new Os(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*Ie((Math.abs(e.x)+this.blur)/t.width,rt.NUM_FRACTION_DIGITS)+20,r=100*Ie((Math.abs(e.y)+this.blur)/t.height,rt.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(i,'%" width="').concat(100+2*i,'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="').concat(Ie(this.blur?this.blur/2:0,rt.NUM_FRACTION_DIGITS),'"></feGaussianBlur>\n\t<feOffset dx="').concat(Ie(e.x,rt.NUM_FRACTION_DIGITS),'" dy="').concat(Ie(e.y,rt.NUM_FRACTION_DIGITS),'" result="oBlur" ></feOffset>
1\n\t<feFlood flood-color="').concat(s.toRgb(),'" flood-opacity="').concat(s.getAlpha(),'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n')}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=ui.ownDefaults;return this.includeDefaultValues?t:Le(t,(t,s)=>t!==e[s])}static async fromObject(t){return new this(t)}}$(ui,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),$(ui,"type","shadow"),Zt.setClass(ui,"shadow");const di=(t,e,s)=>Math.max(t,Math.min(e,s)),gi=[kt,Ot,Vt,Ht,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",zt,Gt],fi=[Nt,Ut,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],pi={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:Ot,originY:kt,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Nt,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},mi=(t,e,s,i)=>-s*Math.cos(t/i*_t)+s+e,vi=()=>!1;class yi{constructor(t){let{startValue:e,byValue:s,duration:i=500,delay:r=0,easing:n=mi,onStart:o=yt,onChange:a=yt,onComplete:h=yt,abort:c=vi,target:l}=t;$(this,"_state","pending"),$(this,"durationProgress",0),$(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=r,this.easing=n,this._onStart=o,this._onChange=a,this._onComplete=h,this._abort=c,this.target=l,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"aborted"===this._state||"completed"===this._state}start(){const t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>he(t),this.delay):he(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:r}=this.calculate(s);this.value=Object.freeze(i),this.valueProgress=r,"aborted"!==this._state&&(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),he(this.tick)))}register(){$t.push(this)}unregister(){$t.remove(this)}abort(){this._state="aborted",this.unregister()}}const _i=["startValue","endValue"];class xi extends yi{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(tt(tt({},et(t,_i)),{},{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 Ci=["startValue","endValue"];class bi extends yi{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(tt(tt({},et(t,Ci)),{},{startValue:e,byValue:s.map((t,s)=>t-e[s])}))}calculate(t){const e=this.startValue.map((e,s)=>this.easing(t,e,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const wi=["startValue","endValue","easing","onChange","onComplete","abort"],Si=(t,e,s,i)=>e+s*(1-Math.cos(t/i*_t)),Ti=t=>t&&((e,s,i)=>t(new Os(e).toRgba(),s,i));class Oi extends yi{constructor(t){let{startValue:e,endValue:s,easing:i=Si,onChange:r,onComplete:n,abort:
1o}=t,a=et(t,wi);const h=new Os(e).getSource(),c=new Os(s).getSource();super(tt(tt({},a),{},{startValue:h,byValue:c.map((t,e)=>t-h[e]),easing:i,onChange:Ti(r),onComplete:Ti(n),abort:Ti(o)}))}calculate(t){const[e,s,i,r]=this.startValue.map((e,s)=>this.easing(t,e,this.byValue[s],this.duration,s)),n=[...[e,s,i].map(Math.round),di(0,r,1)];return{value:n,valueProgress:n.map((t,e)=>0!==this.byValue[e]?Math.abs((t-this.startValue[e])/this.byValue[e]):0).find(t=>0!==t)||0}}}function ki(t){const e=(s=t,Array.isArray(s.startValue)||Array.isArray(s.endValue)?new bi(t):new xi(t));var s;return e.start(),e}class Di{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(t=>!this.includes(t))),this}static isPointContained(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]&&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 r=ei(e,s),n=ei(e,t).divide(r);return i?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){const s=new ie(t).setX(Math.min(t.x-1,...e.map(t=>t.x)));let i=0;for(let r=0;r<e.length;r++){const n=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,s);if(n.includes(t))return!0;i+=Number("Intersection"===n.status)}return i%2==1}static intersectLineLine(t,e,s,i){let r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];const o=e.x-t.x,a=e.y-t.y,h=i.x-s.x,c=i.y-s.y,l=t.x-s.x,u=t.y-s.y,d=h*u-c*l,g=o*u-a*l,f=c*o-h*a;if(0!==f){const e=d/f,s=g/f;return(r||0<=e&&e<=1)&&(n||0<=s&&s<=1)?new Di("Intersection").append(new ie(t.x+e*o,t.y+e*a)):new Di}if(0===d||0===g){const o=r||n||Di.isPointContained(t,s,i)||Di.isPointContained(e,s,i)||Di.isPointContained(s,t,e)||Di.isPointContained(i,t,e);return new Di(o?"Coincident":void 0)}return new Di("Parallel")}static intersectSegmentLine(t,e,s,i){return Di.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return Di.intersectLineLine(t,e,s,i,!1,!1)}static intersectLinePolygon(t,e,s){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const r=new Di,n=s.length;for(let o,a,h,c=0;c<n;c++){if(o=s[c],a=s[(c+1)%n],h=Di.intersectLineLine(t,e,o,a,i,!1),"Coincident"===h.status)return h;r.append(...h.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return Di.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new Di,i=t.length,r=[];for(let n=0;n<i;n++){const o=t[n],a=t[(n+1)%i],h=Di.intersectSegmentPolygon(o,a,e);"Coincident"===h.status?(r.push(h),s.append(o,a)):s.append(...h.points)}return r.length>0&&r.length===t.length?new Di("Coincident"):(s.points.length>0&&(s.status="Intersection"),s)}static intersectPolygonRectangle(t,e,s){const i=e.min(s),r=e.max(s),n=new ie(r.x,i.y),o=new ie(i.x,r.y);return Di.intersectPolygonPolygon(t,[i,n,r,o])}}class Mi extends ae{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?ve(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=ve(t,ye(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new ie(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.originX,s=arguments.length>2&&void 0!==arguments[2]?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()),r=[t,e,s,i];if(this.group){const t=this.group.calcTransformMatrix();return r.map(e=>ve(e,t))}return r}intersectsWithRect(t,e){return"Intersection"===Di.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Di.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||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:r,height:n}
vendor: 5,751 bytes, line 1
1=this.getBoundingRect();return s>=t.x&&s+r<=e.x&&i>=t.y&&i+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return Di.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)||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 es(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(Vt,t),this._set(Ht,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(null===(t=this.canvas)||void 0===t?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?me(Ce(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||bt.concat()}calcACoords(){const t=Se({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=we(e,s),r=_e(i,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:ve({x:-o,y:-a},r),tr:ve({x:o,y:-a},r),bl:ve({x:-o,y:a},r),br:ve({x:o,y:a},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&void 0!==arguments[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,ls(this.originX),ls(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&void 0!==arguments[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((t,e)=>t===s[e])?i.value:(this.group&&(e=_e(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},r=Ee(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new ie(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&&void 0!==arguments[0]?arguments[0]:{};const e=tt({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,r=0;this.strokeUniform&&(i=0,r=s);const n=e.width+i,o=e.height+i;let a;return a=0===e.skewX&&0===e.skewY?new ie(n*e.scaleX,o*e.scaleY):ns(n,o,Me(e)),a.scalarAdd(r)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const a=ls(i)-ls(e),h=ls(r)-ls(s);if(a||h){const t=this._getTransformedDimensions();n+=a*t.x,o+=h*t.y}return new ie(n,o)}translateToCenterPoint(t,e,s){if(e===Tt&&s===Tt)return t;const i=this.translateToGivenOrigin(t,e,s,Tt,Tt);return this.angle?i.rotate(pe(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,Tt,Tt,e,s);return this.angle?i.rotate(pe(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ve(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ie(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),r=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Ot,kt)}}const Ei=["type"],ji=["extraParam"];let Pi=class t extends Mi{static getDefaults(){return t.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){nt("warn","Setting type has no effect",t)}constructor(e){super(),$(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=ue(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=rt.maxCacheSideLimit,r=rt.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=rt.perfLimitSizeTotal)return e<r&&(t.width=r),s<r&&(t.height=r),t;const n=e/s,[o,a]=mt.limitDimsByArea(n),h=di(r,o,i),c=di(r,a,i);return e>h&&(t.zoomX/=e/h,t.width=h,t.capped=!0),s>c&&(t.zoomY/=s/c,t.height=c,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:Math.ceil(s+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:s,height:i,zoomX:r,zoomY:n,x:o,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),h=s!==t.width||i!==t.height,c=this.zoomX!==r||this.zoomY!==n;if(!t||!e)return!1;
1if(h||c){s!==t.width||i!==t.height?(t.width=s,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const h=o/2,c=a/2;return this.cacheTranslationX=Math.round(t.width/2-h)+h,this.cacheTranslationY=Math.round(t.height/2-c)+c,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,n),this.zoomX=r,this.zoomY=n,!0}return!1}setOptions(){let t=arguments.length>0&&void 0!==arguments[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 ie(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=be(this.calcTransformMatrix());return new ie(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:0===t?1e-4:t}_set(t,e){t!==Vt&&t!==Ht||(e=this._constrainScale(e)),t===Vt&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof ui||(e=new ui(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 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!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:r}=this,{width:n,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:r,width:n,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!(this.paintFirst===Ut&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}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,r=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=r}createClipPathLayer(t,e){const s=de(e),i=s.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=s,e.parentClipPaths.forEach(t=>{t.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const t=ye(this.calcTransformMatrix());i.transform(t[0],t[1],t[2],t[3],t[4],t[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&&void 0!==arguments[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(
1)),!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,Be(s)?"percentage"===s.gradientUnits||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&&(Be(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&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,s=this.canvas,i=this.getCanvasRetinaScaling(),[r,,,n]=(null==s?void 0:s.viewportTransform)||bt,o=r*i,a=n*i,h=e.nonScaling?new ie(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*rt.browserShadowBlurConstant*(o+a)*(h.x+h.y)/4,t.shadowOffsetX=e.offsetX*o*h.x,t.shadowOffsetY=e.offsetY*a*h.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!Be(e))return{offsetX:0,offsetY:0};const s=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,i,r):t.transform(1,0,0,1,i,r),s&&t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),{offsetX:i,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===Ut?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){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()),r=this.getCanvasRetinaScaling(),n=i.x/this.scaleX/r,o=i.y/this.scaleY/r,a=de({width:Math.ceil(n),height:Math.ceil(o)}),h=a.getContext("2d");h&&(h.beginPath(),h.moveTo(0,0),h.lineTo(n,0),h.lineTo(n,o),h.lineTo(0,o),h.closePath(),h.translate(n/2,o/2),h.scale(i.zoomX/this.scaleX/r,i.zoomY/this.scaleY/r),this._applyPatternGradientTransform(h,e),h.fillStyle=e.toLive(t),h.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/i.zoomX,r*this.scaleY/i.zoomY),t.strokeStyle=null!==(s=h.createPattern(a,"no-repeat"))&&void 0!==s?s:"")}_findCenterFromElement(){return new ie(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(Zt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=rs(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?pt():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new Ze(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&(t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)})(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&((t,e,s)=>{const i=os(e,s);is(t,_e(i,t.calcOwnMatrix()))})(this,this.getViewportTransform()),this.setCoords();const h=ue(),c=this.getBoundingRect(),l=this.shadow,u=new ie;if(l){const t=l.blur,e=l.nonScaling?new ie(1,1):this.getObjectScaling();u.x=2*Math.round(r(l.offsetX)+t)*r(e.x),u.y=2*Math.round(r(l.offsetY)+t)*r(e.y)}const d=c.width+u.x,g=c.height+u.y;h.width=Math.ceil(d),h.height=Math.ceil(g);const f=a(h);"jpeg"===t.format&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new ie(f.width/2,f.height/2),Tt,Tt);const p=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(o||1,t);return this.set("canvas",p),this.shadow=i,s&&(this.group=s),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ge(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return fe(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:t,y:e}=this.getRelativeCenterPoint();this.originX=Tt,this.originY=Tt,this.left=t,this.top=e}if(this.set("angle",t),e){const{x:t,y:e}=this.translateToOriginPoint(this.getRelativeCenterPoint(),s,i);this.left=t,this.top=e,this.originX=s,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){$t.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&dt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((t,s)=>{let[i,r]=s;return t[i]=this._animate(i,r,e),t},{})}_animate(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=t.split("."),r=this.constructor.colorProperties.includes(i[i.length-1]),{abort:n,startValue:o,onChange:a,onComplete:h}=s,c=tt(tt({},s),{},{target:this,startValue:null!=o?o:i.reduce((t,e)=>t[e],this),endValue:e,abort:null==n?void 0:n.bind(this),onChange:(t,e,s)=>{i.reduce((e,s,r)=>(r===i.length-1&&(e[s]=t),e[s]),this),a&&a(t,e,s)},onComplete:(t,e,s)=>{this.setCoords(),h&&h(t,e,s)}});return r?function(t){const e=new Oi(t);return e.start(),e}(c):ki(c)}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(0===e.length&&s.length>0&&this===s[s.length-1])return{fork:[],otherFork:[t,...s.slice(0,s.length-1)],common:[this]};for(let i,r=0;r<e.length;r++){if(i=e[r],i===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let n=0;n<s.length;n++){if(this===s[n])return{fork:[],otherFork:[t,...s.slice(0,n)],common:[this,...e]};if(i===s[n])return{fork:[this,...e.slice(0,r)],otherFork:[t,...s.slice(0,n)],common:e.slice(r)}}}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;
1if(e.otherFork.includes(this))return!1;const s=e.common[0]||this.canvas;if(!s)return;const i=e.fork.pop(),r=e.otherFork.pop(),n=s._objects.indexOf(i),o=s._objects.indexOf(r);return n>-1&&n>o}toObject(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]);let s;const i=rt.NUM_FRACTION_DIGITS,{clipPath:r,fill:n,stroke:o,shadow:a,strokeDashArray:h,left:c,top:l,originX:u,originY:d,width:g,height:f,strokeWidth:p,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:_,strokeMiterLimit:x,scaleX:C,scaleY:b,angle:w,flipX:S,flipY:T,opacity:O,visible:k,backgroundColor:D,fillRule:M,paintFirst:E,globalCompositeOperation:j,skewX:P,skewY:A}=this;r&&!r.excludeFromExport&&(s=r.toObject(e.concat("inverted","absolutePositioned")));const F=t=>Ie(t,i),L=tt(tt({},Fe(this,e)),{},{type:this.constructor.type,version:vt,originX:u,originY:d,left:F(c),top:F(l),width:F(g),height:F(f),fill:We(n)?n.toObject():n,stroke:We(o)?o.toObject():o,strokeWidth:F(p),strokeDashArray:h?h.concat():h,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:_,strokeMiterLimit:F(x),scaleX:F(C),scaleY:F(b),angle:F(w),flipX:S,flipY:T,opacity:F(O),shadow:a?a.toObject():a,visible:k,backgroundColor:D,fillRule:M,paintFirst:E,globalCompositeOperation:j,skewX:F(P),skewY:F(A)},s?{clipPath:s}:null);return this.includeDefaultValues?L:this._removeDefaultValues(L)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Le(t,(t,e)=>{if(e===Ot||e===kt||"type"===e)return!0;const i=s[e];return t!==i&&!(Array.isArray(t)&&Array.isArray(i)&&0===t.length&&0===i.length)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=et(t,Ei),s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:i}=s,r=et(s,ji);return Ae(e,r).then(t=>i?(delete t[i],new this(e[i],t)):new this(t))}static fromObject(t,e){return this._fromObject(t,e)}};$(Pi,"stateProperties",gi),$(Pi,"cacheProperties",fi),$(Pi,"ownDefaults",pi),$(Pi,"type","FabricObject"),$(Pi,"colorProperties",[Nt,Ut,"backgroundColor"]),$(Pi,"customProperties",[]),Zt.setClass(Pi),Zt.setClass(Pi,"object");const Ai=(t,e,s)=>(i,r,n,o)=>{const a=e(i,r,n,o);return a&&hs(t,tt(tt({},ps(i,r,n,o)),s)),a};function Fi(t){return(e,s,i,r)=>{const{target:n,originX:o,originY:a}=s,h=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(h,o,a),l=t(e,s,i,r);return n.setPositionByOrigin(c,s.originX,s.originY),l}}const Li=Ai(Rt,Fi((t,e,s,i)=>{const r=vs(e,e.originX,e.originY,s,i);if(ls(e.originX)===ls(Tt)||ls(e.originX)===ls(Mt)&&r.x<0||ls(e.originX)===ls(Ot)&&r.x>0){const{target:t}=e,s=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=ds(e)?2:1,n=t.width,o=Math.abs(r.x*i/t.scaleX)-s;return t.set("width",Math.max(o,1)),n!==t.width}return!1}));function Ii(t,e,s,i,r){i=i||{};const n=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=void 0!==i.transparentCorners?i.transparentCorners:r.transparentCorners,h=a?Ut:Nt,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor);let l,u=e,d=s;t.save(),t.fillStyle=i.cornerColor||r.cornerColor||"",t.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",n>o?(l=n,t.scale(1,o/n),d=s*n/o):o>n?(l=o,t.scale(n/o,1),u=e*o/n):l=n,t.beginPath(),t.arc(u,d,l/2,0,xt,!1),t[h](),c&&t.stroke(),t.restore()}function Ri(t,e,s,i,r){i=i||{};const n=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=void 0!==i.transparentCorners?i.transparentCorners:r.transparentCorners,h=a?Ut:Nt,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor),l=n/2,u=o/2;t.save(),t.fillStyle=i.cornerColor||r.cornerColor||"",t.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",t.translate(e,s);const d=r.getTotalAngle();t.rotate(pe(d)),t["".concat(h,"Rect")](-l,-u,n,o),c&&t.strokeRect(-l,-u,n,o),t.restore()}class Bi{constructor(t){$(this,"visible",!0),$(this,"actionName",Yt),$(this,"angle",0),$(this,"x",0),$(this,"y",0),$(this,"offsetX",0),$(this,"offsetY",0),$(this,"sizeX",0),$(this,"sizeY",0),$(this,"touchSizeX",0),$(this,"touchSizeY",0),$(this,"cursorStyle","crosshair"),$(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,s,i){var r;let{tl:n,tr:o,br:a,bl:h}=i;return(null===(r=e.canvas)||void 0===r?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&Di.isPointInPolygon(s,[n,o,a,h])}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 null!==(s=null===(i=t._controlsVisibility)||void 0===i?void 0:i[e])&&void 0!==s?s:this.visible}setVisibility(t,e,s){this.visible=t}
1positionHandler(t,e,s,i){return new ie(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=xe([we(s,i),Se({angle:t}),Te((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new ie(-.5,-.5).transform(o),tr:new ie(.5,-.5).transform(o),br:new ie(.5,.5).transform(o),bl:new ie(-.5,.5).transform(o)}}render(t,e,s,i,r){"circle"===((i=i||{}).cornerStyle||r.cornerStyle)?Ii.call(this,t,e,s,i,r):Ri.call(this,t,e,s,i,r)}}const Wi=(t,e,s)=>s.lockRotation?us:e.cursorStyle,Xi=Ai(Ft,Fi((t,e,s,i)=>{let{target:r,ex:n,ey:o,theta:a,originX:h,originY:c}=e;const l=r.translateToOriginPoint(r.getRelativeCenterPoint(),h,c);if(fs(r,"lockRotation"))return!1;const u=Math.atan2(o-l.y,n-l.x),d=Math.atan2(i-l.y,s-l.x);let g=me(d-u+a);if(r.snapAngle&&r.snapAngle>0){const t=r.snapAngle,e=r.snapThreshold||t,s=Math.ceil(g/t)*t,i=Math.floor(g/t)*t;Math.abs(g-i)<e?g=i:Math.abs(g-s)<e&&(g=s)}g<0&&(g=360+g),g%=360;const f=r.angle!==g;return r.angle=g,f}));function Yi(t,e){const s=e.canvas,i=t[s.uniScaleKey];return s.uniformScaling&&!i||!s.uniformScaling&&i}function Vi(t,e,s){const i=fs(t,"lockScalingX"),r=fs(t,"lockScalingY");if(i&&r)return!0;if(!e&&(i||r)&&s)return!0;if(i&&"x"===e)return!0;if(r&&"y"===e)return!0;const{width:n,height:o,strokeWidth:a}=t;return 0===n&&0===a&&"y"!==e||0===o&&0===a&&"x"!==e}const Hi=["e","se","s","sw","w","nw","n","ne","e"],zi=(t,e,s)=>{const i=Yi(t,s);if(Vi(s,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return us;const r=ms(s,e);return"".concat(Hi[r],"-resize")};function Gi(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=Yi(t,n);let h,c,l,u,d,g;if(Vi(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,l=e.scaleY*e.gestureScale;else{if(h=vs(e,e.originX,e.originY,s,i),d="y"!==o?Math.sign(h.x||e.signX||1):1,g="x"!==o?Math.sign(h.y||e.signY||1):1,e.signX||(e.signX=d),e.signY||(e.signY=g),fs(n,"lockScalingFlip")&&(e.signX!==d||e.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){const t=Math.abs(h.x)+Math.abs(h.y),{original:s}=e,i=t/(Math.abs(u.x*s.scaleX/n.scaleX)+Math.abs(u.y*s.scaleY/n.scaleY));c=s.scaleX*i,l=s.scaleY*i}else c=Math.abs(h.x*n.scaleX/u.x),l=Math.abs(h.y*n.scaleY/u.y);ds(e)&&(c*=2,l*=2),e.signX!==d&&"y"!==o&&(e.originX=gs(e.originX),c*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=gs(e.originY),l*=-1,e.signY=g)}const f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set(Vt,c),"y"===o&&n.set(Ht,l)):(!fs(n,"lockScalingX")&&n.set(Vt,c),!fs(n,"lockScalingY")&&n.set(Ht,l)),f!==n.scaleX||p!==n.scaleY}const Ni=Ai(At,Fi((t,e,s,i)=>Gi(t,e,s,i))),Ui=Ai(At,Fi((t,e,s,i)=>Gi(t,e,s,i,{by:"x"}))),qi=Ai(At,Fi((t,e,s,i)=>Gi(t,e,s,i,{by:"y"}))),Ki=["target","ex","ey","skewingSide"],Ji={x:{counterAxis:"y",scale:Vt,skew:zt,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Ht,skew:Gt,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Zi=["ns","nesw","ew","nwse"],$i=(t,e,s)=>{if(0!==e.x&&fs(s,"lockSkewingY"))return us;if(0!==e.y&&fs(s,"lockSkewingX"))return us;const i=ms(s,e)%4;return"".concat(Zi[i],"-resize")};function Qi(t,e,s,i,r){const{target:n}=s,{counterAxis:o,origin:a,lockSkewing:h,skew:c,flip:l}=Ji[t];if(fs(n,h))return!1;const{origin:u,flip:d}=Ji[o],g=ls(s[u])*(n[d]?-1:1),f=-Math.sign(g)*(n[l]?-1:1),p=-(0===n[c]&&vs(s,Tt,Tt,i,r)[t]>0||n[c]>0?1:-1)*f*.5+.5;return Ai(It,Fi((e,s,i,r)=>function(t,e,s){let{target:i,ex:r,ey:n,skewingSide:o}=e,a=et(e,Ki);const{skew:h}=Ji[t],c=s.subtract(new ie(r,n)).divide(new ie(i.scaleX,i.scaleY))[t],l=i[h],u=a[h],d=Math.tan(pe(u)),g="y"===t?i._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:i._getTransformedDimensions({scaleX:1,scaleY:1}).y,f=2*c*o/Math.max(g,1)+d,p=me(Math.atan(f));i.set(h,p);const m=l!==i[h];if(m&&"y"===t){const{skewX:t,scaleX:e}=i,s=i._getTransformedDimensions({skewY:l}),r=i._getTransformedDimensions(),n=0!==t?s.x/r.x:1;1!==n&&i.set(Vt,n*e)}return m}(t,s,new ie(i,r))))(e,tt(tt({},s),{},{[a]:p,skewingSide:f}),i,r)}const tr=(t,e,s,i)=>Qi("x",t,e,s,i),er=(t,e,s,i)=>Qi("y",t,e,s,i);function sr(t,e){return t[e.canvas.altActionKey]}const ir=(t,e,s)=>{const i=sr(t,s);return 0===e.x?i?zt:Ht:0===e.y?i?Gt:Vt:""},rr=(t,e,s)=>sr(t,s)?$i(0,e,s):zi(t,e,s),nr=(t,e,s,i)=>sr(t,e.target)?er(t,e,s,i):Ui(t,e,s,i),or=(t,e,s,i)=>sr(t,e.target)?tr(t,e,s,i):qi(t,e,s,i),ar=()=>({ml:new Bi({x:-.5,y:0,cursorStyleHandler:rr,actionHandler:nr,getActionName:ir}),mr:new Bi({x:.5,y:0,cursorStyleHandler:rr,actionHandler:nr,getActionName:ir}),mb:new Bi({x:0,y:.5,cursorStyleHandler:rr,actionHandler:or,getActionName:ir}),mt:new Bi({x:0,y:-.5,cursorStyleHandler:rr,actionHandler:or,getActionName:ir}),tl:new Bi({x:-.5,y:-.5,cursorStyleHandler:zi,actionHandler:Ni}),tr:new Bi({x:.5,y:-.5,cursorStyleHandler:zi,actionHandler:Ni}),bl:new Bi({x:-.5,y:.5,cursorStyleHandler:zi,actionHandler:Ni}),br:new Bi({x:.5,y:.5,cursorStyleHandler:zi,actionHandler:Ni}),mtr:new Bi({x:0,y:-.5,actionHandler:Xi,cursorStyleHandler:Wi,offsetY:-40,withConnection:!0,actionName:Lt})}),hr=()=>({mr:new Bi({x:.5,y:0,actionHandler:Li,cursorStyleHandler:rr,actionName:Rt}),ml:new Bi({x:-.5,y:0,actionHandler:Li,cursorStyleHandler:rr,actionName:Rt})}),cr=()=>tt(tt({},ar()),hr());class lr extends Pi{static getDefaults(){return tt(tt({},super.getDefaults()),lr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),lr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:ar()}}_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(Yt))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&&void 0!==arguments[1]&&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[r,n]=s[i],o=this.controls[r];if(o.shouldActivate(r,this,t,e?n.touchCorner:n.corner))return this.__corner=r,{key:r,control:o,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),s=we(e.x,e.y),i=Se({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=_e(s,i),n=_e(t,r),o=_e(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?be(this.calcTransformMatrix()):void 0;a&&(a.scaleX=Math.abs(a.scaleX),a.scaleY=Math.abs(a.scaleY));const h=this._calculateCurrentDimensions(a),c={};return this.forEachControl((t,e)=>{const s=t.positionHandler(h,o,this,t);c[e]=Object.assign(s,this._calcCornerCoords(t,s))}),c}_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)}
1drawSelectionBackground(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(pe(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&&void 0!==arguments[2]?arguments[2]:{};const i=tt({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&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:s,hasControls:i}=this,r=tt({hasBorders:s,hasControls:i},e),n=this.getViewportTransform(),o=r.hasBorders,a=r.hasControls,h=_e(n,this.calcTransformMatrix()),c=be(h);t.save(),t.translate(c.translateX,c.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(c.angle-=180),t.rotate(pe(this.group?c.angle:this.angle)),o&&this.drawBorders(t,c,e),a&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const t=ns(this.width,this.height,Me(e)),s=this.isStrokeAccountedForInDimensions()?re:(this.strokeUniform?(new ie).scalarAdd(this.canvas?this.canvas.getZoom():1):new ie(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=t.add(s).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,r)=>{i.withConnection&&i.getVisibility(this,r)&&(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&&void 0!==arguments[1]?arguments[1]:{};t.save();const s=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:r,cornerColor:n}=this,o=tt({cornerStrokeColor:i,cornerDashArray:r,cornerColor:n},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((e,s)=>{if(e.getVisibility(this,s)){const i=this.oCoords[s];e.render(t,i.x,i.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&&void 0!==arguments[0]?arguments[0]:{};Object.entries(t).forEach(t=>{let[e,s]=t;return this.setControlVisible(e,s)})}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,r=this.height+4;return e.clearRect(-i/2,-r/2,i,r),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 ur(t,e){return e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{"constructor"!==s&&Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),t}$(lr,"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",hoverCurs
1or:null,moveCursor:null});class dr extends lr{}ur(dr,[Ms]),Zt.setClass(dr),Zt.setClass(dr,"object");class gr{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ie(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ie(1/this.options.scaleX,1/this.options.scaleY):new ie(1,1)}createSideVector(t,e){const s=ei(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 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){const e=new ie(t);return e.y+=e.x*Math.tan(pe(this.options.skewY)),e.x+=e.y*Math.tan(pe(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const fr=new ie;class pr extends gr{static getOrthogonalRotationFactor(t,e){const s=e?ii(t,e):(t=>ii($s,t))(t);return Math.abs(s)<_t?-1:1}constructor(t,e,s,i){super(i),$(this,"AB",void 0),$(this,"AC",void 0),$(this,"alpha",void 0),$(this,"bisector",void 0),this.A=new ie(t),this.B=new ie(e),this.C=new ie(s),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ii(this.AB,this.AC),this.bisector=ri(ti(this.AB.eq(fr)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=ni(i),n=pr.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%xt==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),r=this.options.strokeUniform?si(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return si(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new ie(pr.getOrthogonalRotationFactor(this.bisector),pr.getOrthogonalRotationFactor(new ie(this.bisector.y,this.bisector.x)));return[new ie(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ie(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(i=>{hi(i,t,e)&&s.push(this.A.add(i))}),s}projectRoundWithSkew(t,e){const s=[],{skewX:i,skewY:r,scaleX:n,scaleY:o,strokeUniform:a}=this.options,h=new ie(Math.tan(pe(i)),Math.tan(pe(r))),c=this.strokeProjectionMagnitude,l=a?c/o/Math.sqrt(1/o**2+1/n**2*h.y**2):c/Math.sqrt(1+h.y**2),u=new ie(Math.sqrt(Math.max(c**2-l**2,0)),l),d=a?c/Math.sqrt(1+h.x**2*(1/o)**2/(1/n+1/n*h.x*h.y)**2):c/Math.sqrt(1+h.x**2/(1+h.x*h.y)**2),g=new ie(d,Math.sqrt(Math.max(c**2-d**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t)).forEach(i=>{hi(i,t,e)&&s.push(this.applySkew(this.A).add(i))}),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%xt==0,s=this.applySkew(this.A),i=t[e?0:2].subtract(s),r=t[e?1:0].subtract(s),n=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=oi(i,n)>0,a=o?i:r,h=o?r:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(a,h)):t.push(...this.projectRoundNoSkew(a,h)),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 mr extends gr{constructor(t,e,s){super(s),this.A=new ie(t),this.T=new ie(e)}calcOrthogonalProjection(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(ni(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 ie(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 pr(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ie(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(ri(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(s);t.push(i.add(e),i.subtract(e))}return t.map(t=>this.applySkew(t))}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 vr=t=>{const e={};return Object.keys(t).forEach(s=>{e[s]={}
1,Object.keys(t[s]).forEach(i=>{e[s][i]=tt({},t[s][i])})}),e};let yr;const _r=t=>{if(yr||yr||(yr="Intl"in ft()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),yr){const e=yr.segment(t);return Array.from(e).map(t=>{let{segment:e}=t;return e})}return xr(t)},xr=t=>{const e=[];for(let s,i=0;i<t.length;i++)!1!==(s=Cr(t,i))&&e.push(s);return e},Cr=(t,e)=>{const s=t.charCodeAt(e);if(isNaN(s))return"";if(s<55296||s>57343)return t.charAt(e);if(55296<=s&&s<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";const s=t.charCodeAt(e+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";const i=t.charCodeAt(e-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},br=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textDecorationThickness!==e.textDecorationThickness||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||s&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},wr=(t,e)=>{const s=e.split("\n"),i=[];let r=-1,n={};t=vr(t);for(let o=0;o<s.length;o++){const e=_r(s[o]);if(t[o])for(let s=0;s<e.length;s++){r++;const e=t[o][s];e&&Object.keys(e).length>0&&(br(n,e,!0)?i.push({start:r,end:r+1,style:e}):i[i.length-1].end++),n=e||{}}else r+=e.length,n={}}return i},Sr=(t,e)=>{if(!Array.isArray(t))return vr(t);const s=e.split(jt),i={};let r=-1,n=0;for(let o=0;o<s.length;o++){const e=_r(s[o]);for(let s=0;s<e.length;s++)r++,t[n]&&t[n].start<=r&&r<t[n].end&&(i[o]=i[o]||{},i[o][s]=tt({},t[n].style),r===t[n].end-1&&n++)}return i},Tr=["display","transform",Nt,"fill-opacity","fill-rule","opacity",Ut,"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 Or(t,e){const s=t.nodeName,i=t.getAttribute("class"),r=t.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+s,"i"),e=e.replace(o,""),r&&e.length&&(o=new RegExp("#"+r+n,"i"),e=e.replace(o,"")),i&&e.length){const t=i.split(" ");for(let s=t.length;s--;)o=new RegExp("\\."+t[s]+n,"i"),e=e.replace(o,"")}return 0===e.length}function kr(t,e){let s=!0;const i=Or(t,e.pop());return i&&e.length&&(s=function(t,e){let s,i=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)i&&(s=e.pop()),i=Or(t=t.parentElement,s);return 0===e.length}(t,e)),i&&s&&0===e.length}const Dr=t=>{var e;return null!==(e=qs[t])&&void 0!==e?e:t},Mr=new RegExp("(".concat(Gs,")"),"gi");var Er,jr,Pr,Ar,Fr,Lr,Ir;const Rr="(".concat(Gs,")"),Br=String.raw(Er||(Er=st(["(skewX)(",")"],["(skewX)\\(","\\)"])),Rr),Wr=String.raw(jr||(jr=st(["(skewY)(",")"],["(skewY)\\(","\\)"])),Rr),Xr=String.raw(Pr||(Pr=st(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Rr,Rr,Rr),Yr=String.raw(Ar||(Ar=st(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Rr,Rr),Vr=String.raw(Fr||(Fr=st(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Rr,Rr),Hr=String.raw(Lr||(Lr=st(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Rr,Rr,Rr,Rr,Rr,Rr),zr="(?:".concat(Hr,"|").concat(Vr,"|").concat(Xr,"|").concat(Yr,"|").concat(Br,"|").concat(Wr,")"),Gr="(?:".concat(zr,"*)"),Nr=String.raw(Ir||(Ir=st(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Gr),Ur=new RegExp(Nr),qr=new RegExp(zr),Kr=new RegExp(zr,"g");function Jr(t){const e=[];if(!(t=(t=>_s(t.replace(Mr," $1 ").replace(/,/gi," ")))(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!Ur.test(t))return[...bt];for(const s of t.matchAll(Kr)){const t=qr.exec(s[0]);if(!t)continue;let i=bt;const r=t.filter(t=>!!t),[,n,...o]=r,[a,h,c,l,u,d]=o.map(t=>parseFloat(t));switch(n){case"translate":i=we(a,h);break;case Lt:i=Se({angle:a},{x:h,y:c});break;case Yt:i=Te(a,h);break;case zt:i=ke(a);break;case Gt:i=De(a);break;case"matrix":i=[a,h,c,l,u,d]}e.push(i)}return xe(e)}function Zr(t,e,s,i){const r=Array.isArray(e);let n,o=e;if(t!==Nt&&t!==Ut||e!==Et){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===Et?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=s&&s.transformMatrix?_e(s.transformMatrix,Jr(e)):Jr(e);
1else if("visible"===t)o=e!==Et&&"hidden"!==e,s&&!1===s.visible&&(o=!1);else if("opacity"===t)o=parseFloat(e),s&&void 0!==s.opacity&&(o*=s.opacity);else if("textAnchor"===t)o="start"===e?Ot:"end"===e?Mt:Tt;else if("charSpacing"===t||t===js)n=ks(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(Nt),s=e.indexOf(Ut);o=Nt,(t>-1&&s>-1&&s<t||-1===t&&s>-1)&&(o=Ut)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(ks):ks(e,i)}}else o="";return!r&&isNaN(n)?o:n}const $r={stroke:"strokeOpacity",fill:"fillOpacity"};function Qr(t,e,s){if(!t)return{};let i,r={},n=wt;t.parentNode&&Zs.test(t.parentNode.nodeName)&&(r=Qr(t.parentElement,e,s),r.fontSize&&(i=n=ks(r.fontSize)));const o=tt(tt(tt({},e.reduce((e,s)=>{const i=t.getAttribute(s);return i&&(e[s]=i),e},{})),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s={};for(const i in e)kr(t,i.split(" "))&&(s=tt(tt({},s),e[i]));return s}(t,s)),function(t){const e={},s=t.getAttribute("style");return s?("string"==typeof s?function(t,e){t.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;const[s,i]=t.split(":");e[s.trim().toLowerCase()]=i.trim()})}(s,e):(i=s,r=e,Object.entries(i).forEach(t=>{let[e,s]=t;void 0!==s&&(r[e.toLowerCase()]=s)})),e):e;var i,r}(t));o[Js]&&t.setAttribute(Js,o[Js]),o[Ks]&&(i=ks(o[Ks],n),o[Ks]="".concat(i));const a={};for(const c in o){const t=Dr(c),e=Zr(t,o[c],r,i);a[t]=e}a&&a.font&&function(t,e){const s=t.match(Us);if(!s)return;const i=s[1],r=s[3],n=s[4],o=s[5],a=s[6];i&&(e.fontStyle=i),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),n&&(e.fontSize=ks(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}(a.font,a);const h=tt(tt({},r),a);return Zs.test(t.nodeName)?h:function(t){const e=dr.getDefaults();return Object.entries($r).forEach(s=>{let[i,r]=s;if(void 0===t[r]||""===t[i])return;if(void 0===t[i]){if(!e[i])return;t[i]=e[i]}if(0===t[i].indexOf("url("))return;const n=new Os(t[i]);t[i]=n.setAlpha(Ie(n.getAlpha()*t[r],2)).toRgba()}),t}(h)}const tn=["left","top","width","height","visible"],en=["rx","ry"];class sn extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),sn.ownDefaults)}constructor(t){super(),Object.assign(this,sn.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,r=-s/2,n=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,s/2):0,a=0!==n||0!==o;t.beginPath(),t.moveTo(i+n,r),t.lineTo(i+e-n,r),a&&t.bezierCurveTo(i+e-St*n,r,i+e,r+St*o,i+e,r+o),t.lineTo(i+e,r+s-o),a&&t.bezierCurveTo(i+e,r+s-St*o,i+e-St*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),a&&t.bezierCurveTo(i+St*n,r+s,i,r+s-St*o,i,r+s-o),t.lineTo(i,r+o),a&&t.bezierCurveTo(i,r+St*o,i+St*n,r,i+n,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...en,...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,'" />\n')]}static async fromElement(t,e,s){const i=Qr(t,this.ATTRIBUTE_NAMES,s),{left:r=0,top:n=0,width:o=0,height:a=0,visible:h=!0}=i,c=et(i,tn);return new this(tt(tt(tt({},e),c),{},{left:r,top:n,width:o,height:a,visible:Boolean(h&&o&&a)}))}}$(sn,"type","Rect"),$(sn,"cacheProperties",[...fi,...en]),$(sn,"ownDefaults",{rx:0,ry:0}),$(sn,"ATTRIBUTE_NAMES",[...Tr,"x","y","rx","ry","width","height"]),Zt.setClass(sn),Zt.setSVGClass(sn);const rn="initialization",nn="added",on="removed",an="imperative",hn=(t,e)=>{const{strokeUniform:s,strokeWidth:i,width:r,height:n,group:o}=e,a=o&&o!==t?os(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),l=s&&c?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:bt,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:bt;return t.transform(os(e,s),!0)}(new ie(i,i),void 0,t.calcTransformMatrix()):re,u=!s&&c?i:0,d=ns(r+u,n+u,xe([a,e.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(d),h.add(d)]};class cn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===rn||e===an||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==rn&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===an&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=es(t.map(t=>hn(i,t)).reduce((t,e)=>t.concat(e),[])),h=new ie(o,a),c=new ie(r,n).add(h.scalarDivide(2));if(s===rn){const t=this.getInitialSize(e,{size:h,center:c});return{center:c,relativeCorrection:new ie(0,0),size:t}}return{center:c.transform(i.calcOwnMatrix()),size:h}}}$(cn,"type","strategy");class ln extends cn{shouldPerformLayout(t){return!0}}
1$(ln,"type","fit-content"),Zt.setClass(ln);const un=["strategy"],dn=["target","strategy","bubbles","prevStrategy"],gn="layoutManager";class fn{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ln;$(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=tt(tt({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[qt,Pt,Rt,Ft,At,It,Xt,Bt,Wt].map(e=>t.on(e,t=>this.performLayout(e===qt?{type:"object_modified",trigger:e,e:t,target:s}:{type:"object_modifying",trigger:e,e:t,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(t=>t()),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===rn||s===nn?this.subscribeTargets(t):s===on&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),s===an&&t.deep){const s=et(t,un);e.forEachObject(t=>t.layoutManager&&t.layoutManager.performLayout(tt(tt({},s),{},{bubbles:!1,target:t})))}}getLayoutResult(t){const{target:e,strategy:s,type:i}=t,r=s.calcLayoutResult(t,e.getObjects());if(!r)return;const n=i===rn?new ie:e.getRelativeCenterPoint(),{center:o,correction:a=new ie,relativeCorrection:h=new ie}=r,c=n.subtract(o).add(a).transform(i===rn?bt:ye(e.calcOwnMatrix()),!0).add(h);return{result:r,prevCenter:n,nextCenter:o,offset:c}}commitLayout(t,e){const{target:s}=t,{result:{size:i},nextCenter:r}=e;var n,o;s.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===rn?s.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+i.x*ls(s.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+i.y*ls(s.originY)}):(s.setPositionByOrigin(r,Tt,Tt),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:r,prevStrategy:n}=t,o=et(t,dn),{canvas:a}=s;s.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:s});const h=s.parent;r&&null!=h&&h.layoutManager&&((o.path||(o.path=[])).push(s),h.layoutManager.performLayout(tt(tt({},o),{},{target:h}))),s.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(t=>t.forEach(t=>t())),t.clear()}toObject(){return{type:gn,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}Zt.setClass(fn,gn);const pn=["type","objects","layoutManager"];class mn extends fn{performLayout(){}}class vn extends(oe(dr)){static getDefaults(){return tt(tt({},super.getDefaults()),vn.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),$(this,"_activeObjects",[]),$(this,"__objectSelectionTracker",void 0),$(this,"__objectSelectionDisposer",void 0),Object.assign(this,vn.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(t=>{this.enterGroup(t,!1)}),this.layoutManager=null!==(s=e.layoutManager)&&void 0!==s?s:new fn,this.layoutManager.performLayout({type:rn,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(nt("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(nt("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((t,e,s)=>this.canEnterGroup(t)&&s.indexOf(t)===e)}add(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];const i=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...i);return this._onAfterObjectsChange(nn,i),r}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 r=this._filterObjectsBeforeEnteringGroup(s),n=super.insertAt(t,...r);return this._onAfterObjectsChange(nn,r),n}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(on,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),"canvas"===t&&s!==e&&(this._objects||[]).forEac
1h(s=>{s._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 t=i.indexOf(s);t>-1&&(i.splice(t,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&&is(t,_e(ye(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||(is(t,_e(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=dr.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 r=0;r<this._objects.length;r++){var i;const e=this._objects[r];null!==(i=this.canvas)&&void 0!==i&&i.preserveObjectStacking&&e.group!==this?(t.save(),t.transform(...ye(this.calcTransformMatrix())),e.render(t),t.restore()):e.group===this&&e.render(t)}this._drawClipPath(t,this.clipPath,s)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(tt({target:this,type:an},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const s=this.includeDefaultValues;return this._objects.filter(function(t){return!t.excludeFromExport}).map(function(i){const r=i.includeDefaultValues;i.includeDefaultValues=s;const n=i[t||"toObject"](e);return i.includeDefaultValues=r,n})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.layoutManager.toObject();return tt(tt(tt({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||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=sn.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"," >\n"],s=this._createSVGBgRect(t);s&&e.push("\t\t",s);for(let i=0;i<this._objects.length;i++)e.push("\t\t",this._objects[i].toSVG(t));return e.push("</g>\n"),e}getSvgStyles(){const t=void 0!==this.opacity&&1!==this.opacity?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],s=this._createSVGBgRect(t);s&&e.push("\t",s);for(let i=0;i<this._objects.length;i++)e.push("\t",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:s,objects:i=[],layoutManager:r}=t,n=et(t,pn);return Promise.all([Pe(i,e),Ae(n,e)]).then(t=>{let[e,s]=t;const i=new this(e,tt(tt(tt({},n),s),{},{layoutManager:new mn}));if(r){const t=Zt.getClass(r.type),e=Zt.getClass(r.strategy);i.layoutManager=new t(new e)}else i.layoutManager=new fn;return i.layoutManager.subscribeTargets({type:rn,target:i,targets:i.getObjects()}),i.setCoords(),i})}}$(vn,"type","Group"),$(vn,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),Zt.setClass(vn);const yn="\\s*,?\\s*",_n="".concat(yn,"(").concat(Gs,")"),xn="".concat(_n).concat(_n).concat(_n).concat(yn,"([01])").concat(yn,"([01])").concat(_n).concat(_n),Cn={m:"l",M:"L"},bn=(t,e,s,i,r,n,o,a,h,c,l)=>
vendor: 8,021 bytes, line 1
1{const u=ee(t),d=se(t),g=ee(e),f=se(e),p=s*r*g-i*n*f+o,m=i*r*g+s*n*f+a;return["C",c+h*(-s*r*d-i*n*u),l+h*(-i*r*d+s*n*u),p+h*(s*r*f+i*n*g),m+h*(i*r*f-s*n*g),p,m]},wn=(t,e,s,i)=>{const r=Math.atan2(e,t),n=Math.atan2(i,s);return n>=r?n-r:2*Math.PI-(r-n)};function Sn(t,e,s,i,r,n,o,a){let h;if(rt.cachesBoundsOfCurve&&(h=[...arguments].join(),mt.boundsOfCurveCache[h]))return mt.boundsOfCurveCache[h];const c=Math.sqrt,l=Math.abs,u=[],d=[[0,0],[0,0]];let g=6*t-12*s+6*r,f=-3*t+9*s-9*r+3*o,p=3*s-3*t;for(let x=0;x<2;++x){if(x>0&&(g=6*e-12*i+6*n,f=-3*e+9*i-9*n+3*a,p=3*i-3*e),l(f)<1e-12){if(l(g)<1e-12)continue;const t=-p/g;0<t&&t<1&&u.push(t);continue}const t=g*g-4*p*f;if(t<0)continue;const s=c(t),r=(-g+s)/(2*f);0<r&&r<1&&u.push(r);const o=(-g-s)/(2*f);0<o&&o<1&&u.push(o)}let m=u.length;const v=m,y=kn(t,e,s,i,r,n,o,a);for(;m--;){const{x:t,y:e}=y(u[m]);d[0][m]=t,d[1][m]=e}d[0][v]=t,d[1][v]=e,d[0][v+1]=o,d[1][v+1]=a;const _=[new ie(Math.min(...d[0]),Math.min(...d[1])),new ie(Math.max(...d[0]),Math.max(...d[1]))];return rt.cachesBoundsOfCurve&&(mt.boundsOfCurveCache[h]=_),_}const Tn=(t,e,s)=>{let[i,r,n,o,a,h,c,l]=s;const u=((t,e,s,i,r,n,o)=>{if(0===s||0===i)return[];let a=0,h=0,c=0;const l=Math.PI,u=o*Ct,d=se(u),g=ee(u),f=.5*(-g*t-d*e),p=.5*(-g*e+d*t),m=s**2,v=i**2,y=p**2,_=f**2,x=m*v-m*y-v*_;let C=Math.abs(s),b=Math.abs(i);if(x<0){const t=Math.sqrt(1-x/(m*v));C*=t,b*=t}else c=(r===n?-1:1)*Math.sqrt(x/(m*y+v*_));const w=c*C*p/b,S=-c*b*f/C,T=g*w-d*S+.5*t,O=d*w+g*S+.5*e;let k=wn(1,0,(f-w)/C,(p-S)/b),D=wn((f-w)/C,(p-S)/b,(-f-w)/C,(-p-S)/b);0===n&&D>0?D-=2*l:1===n&&D<0&&(D+=2*l);const M=Math.ceil(Math.abs(D/l*2)),E=[],j=D/M,P=8/3*Math.sin(j/4)*Math.sin(j/4)/Math.sin(j/2);let A=k+j;for(let F=0;F<M;F++)E[F]=bn(k,A,g,d,C,b,T,O,P,a,h),a=E[F][5],h=E[F][6],k=A,A+=j;return E})(c-t,l-e,r,n,a,h,o);for(let d=0,g=u.length;d<g;d++)u[d][1]+=t,u[d][2]+=e,u[d][3]+=t,u[d][4]+=e,u[d][5]+=t,u[d][6]+=e;return u},On=(t,e,s,i)=>Math.sqrt((s-t)**2+(i-e)**2),kn=(t,e,s,i,r,n,o,a)=>h=>{const c=h**3,l=3*(g=h)**2*(1-g),u=(t=>3*t*(1-t)**2)(h),d=(t=>(1-t)**3)(h);var g;return new ie(o*c+r*l+s*u+t*d,a*c+n*l+i*u+e*d)},Dn=t=>t**2,Mn=t=>2*t*(1-t),En=t=>(1-t)**2,jn=(t,e,s,i,r,n,o,a)=>h=>{const c=Dn(h),l=Mn(h),u=En(h),d=3*(u*(s-t)+l*(r-s)+c*(o-r)),g=3*(u*(i-e)+l*(n-i)+c*(a-n));return Math.atan2(g,d)},Pn=(t,e,s,i,r,n)=>o=>{const a=Dn(o),h=Mn(o),c=En(o);return new ie(r*a+s*h+t*c,n*a+i*h+e*c)},An=(t,e,s,i,r,n)=>o=>{const a=1-o,h=2*(a*(s-t)+o*(r-s)),c=2*(a*(i-e)+o*(n-i));return Math.atan2(c,h)},Fn=(t,e,s)=>{let i=new ie(e,s),r=0;for(let n=1;n<=100;n+=1){const e=t(n/100);r+=On(i.x,i.y,e.x,e.y),i=e}return r},Ln=t=>{let e,s,i=0,r=0,n=0,o=0,a=0;const h=[];for(const c of t){const t={x:r,y:n,command:c[0],length:0};switch(c[0]){case"M":s=t,s.x=o=r=c[1],s.y=a=n=c[2];break;case"L":s=t,s.length=On(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=kn(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s=t,s.iterator=e,s.angleFinder=jn(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s.length=Fn(e,r,n),r=c[5],n=c[6];break;case"Q":e=Pn(r,n,c[1],c[2],c[3],c[4]),s=t,s.iterator=e,s.angleFinder=An(r,n,c[1],c[2],c[3],c[4]),s.length=Fn(e,r,n),r=c[3],n=c[4];break;case"Z":s=t,s.destX=o,s.destY=a,s.length=On(r,n,o,a),r=o,n=a}i+=s.length,h.push(s)}return h.push({length:i,x:r,y:n}),h},In=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ln(t),i=0;for(;e-s[i].length>0&&i<s.length-2;)e-=s[i].length,i++;const r=s[i],n=e/r.length,o=t[i];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return tt(tt({},new ie(r.x,r.y).lerp(new ie(r.destX,r.destY),n)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return tt(tt({},new ie(r.x,r.y).lerp(new ie(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-r.y,o[1]-r.x)});case"C":case"Q":return((t,e)=>{let s,i=0,r=0,n={x:t.x,y:t.y},o=tt({},n),a=.01,h=0;const c=t.iterator,l=t.angleFinder;for(;r<e&&a>1e-4;)o=c(i),h=i,s=On(n.x,n.y,o.x,o.y),s+r>e?(i-=a,a/=2):(n=o,i+=a,r+=s);return tt(tt({},o),{},{angle:l(h)})})(r,e)}},Rn=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Bn=new RegExp(xn,"g"),Wn=new RegExp(Gs,"gi"),Xn={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7};function Yn(t,e){const s=t.style;s&&e&&("string"==typeof e?s.cssText+=";"+e:Object.entries(e).forEach(t=>{let[e,i]=t;return s.setProperty(e,i)}))}class Vn extends qe{constructor(t){let{allowTouchScrolling:e=!1,containerClass:s=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),$(this,"upper",void 0),$(this,"container",void 0);const{el:i}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const n=this.createContainerElement();n.classList.add(s),i.parentNode&&i.parentNode.replaceChild(n,i),n.append(i,r),this.container=n}createUpperCanvas(){const{el:t}=this.lower,e=ue();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=gt().createElement("div");return t.setAttribute("data-fabric","wrapper"),Yn(t,{position:"relative"}),Ue(t),t}applyCanvasStyle(t,e){const{styles:s,allowTouchScrolling:i}=e;Yn(t,tt(tt({},s),{},{"touch-action":i?"manipulation":Et})),Ue(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;Ge(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Ne(this.upper.el,t),Ne(this.container,t)}cleanupDOM(t){const e=this.container,{el:s}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(s),e.parentNode&&e.parentNode.replaceChild(s,e)}dispose(){super.dispose(),dt().dispose(this.upper.el),delete this.upper,delete this.container}}class Hn extends Ze{constructor(){super(...arguments),$(this,"targets",[]),$(this,"_hoveredTargets",[]),$(this,"_currentTransform",null),$(this,"_groupSelector",null),$(this,"contextTopDirty",!1)}static getDefaults(){return tt(tt({},super.getDefaults()),Hn.ownDefaults)}get upperCanvasEl(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.el}get contextTop(){var t;return null===(t=this.elements.upper)||void 0===t?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Vn(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),s=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=s,this.pixelFindContext.scale(e,e)}
1isTargetTransparent(t,e,s){const i=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+i,-s+i),r.transform(...this.viewportTransform);const n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=n,r.restore();const o=Math.round(i*this.getRetinaScaling());return((t,e,s,i)=>{const r=2*(i=Math.round(i))+1,{data:n}=t.getImageData(e-i,s-i,r,r);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0})(r,o,o,o)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(e=>!!e&&!0===t[e]):t[e])}_shouldClearSelection(t,e){const s=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&s.length>1&&-1===s.indexOf(e)&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,s){if(!t)return;let i;return e===Yt||e===Vt||e===Ht||e===Rt?i=this.centeredScaling||t.centeredScaling:e===Lt&&(i=this.centeredRotation||t.centeredRotation),i?!s:s}_getOriginFromCorner(t,e){const s={x:t.originX,y:t.originY};return e?(["ml","tl","bl"].includes(e)?s.x=Mt:["mr","tr","br"].includes(e)&&(s.x=Ot),["tl","mt","tr"].includes(e)?s.y=Dt:["bl","mb","br"].includes(e)&&(s.y=kt),s):s}_setupCurrentTransform(t,e,s){var i;const r=e.group?as(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:o}=e.getActiveControl()||{},a=s&&o?null===(i=o.getActionHandler(t,e,o))||void 0===i?void 0:i.bind(o):ys,h=((t,e,s,i)=>{if(!e||!t)return"drag";const r=i.controls[e];return r.getActionName(s,r,i)})(s,n,t,e),c=t[this.centeredKey],l=this._shouldCenterTransform(e,h,c)?{x:Tt,y:Tt}:this._getOriginFromCorner(e,n),u={target:e,action:h,actionHandler:a,actionPerformed:!1,corner:n,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:l.x,originY:l.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:pe(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:c,original:tt(tt({},rs(e)),{},{originX:l.x,originY:l.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ie(e,s).transform(this.viewportTransform),o=new ie(e+i,s+r).transform(this.viewportTransform),a=this.selectionLineWidth/2;let h=Math.min(n.x,o.x),c=Math.min(n.y,o.y),l=Math.max(n.x,o.x),u=Math.max(n.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(h,c,l-h,u-c)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,h+=a,c+=a,l-=a,u-=a,dr.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(h,c,l-h,u-c))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),s=this._activeObject,i=this.getActiveObjects();if(this.targets=[],s&&i.length>=1){if(s.findControl(e,Qe(t)))return s;if(i.length>1&&this.searchPossibleTargets([s],e))return s;if(s===this.searchPossibleTargets([s],e)){if(this.preserveObjectStacking){const i=this.targets;this.targets=[];const r=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&r&&r!==s?(this.targets=i,s):r}return s}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let s=t.getCoords();const i=this.getZoom(),r=t.padding/i;if(r){const[t,e,i,n]=s,o=Math.atan2(e.y-t.y,e.x-t.x),a=ee(o)*r,h=se(o)*r,c=a+h,l=a-h;s=[new ie(t.x-l,t.y-c),new ie(e.x+c,e.y-l),new ie(i.x+l,i.y+c),new ie(n.x-c,n.y+l)]}return Di.isPointInPolygon(e,s)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,as(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;
1if(!this.isTargetTransparent(t,e.x,e.y))return!0}return!1}_searchPossibleTargets(t,e){let s=t.length;for(;s--;){const i=t[s];if(this._checkTarget(i,e)){if(ne(i)&&i.subTargetCheck){const t=this._searchPossibleTargets(i._objects,e);t&&this.targets.push(t)}return i}}}searchPossibleTargets(t,e){const s=this._searchPossibleTargets(t,e);if(s&&ne(s)&&s.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const s=t[e];if(!ne(s)||!s.interactive)return s}return t[0]}return s}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=this.upperCanvasEl,i=s.getBoundingClientRect();let r=(t=>{const e=Ve(t.target),s=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ie(s.clientX+e.left,s.clientY+e.top)})(t),n=i.width||0,o=i.height||0;n&&o||(kt in i&&Dt in i&&(o=Math.abs(i.top-i.bottom)),Mt in i&&Ot in i&&(n=Math.abs(i.right-i.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=as(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const h=0===n||0===o?new ie(1,1):new ie(s.width/n,s.height/o);return r.multiply(h)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ue(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ye(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let s=!1,i=!1;const r=this.getActiveObjects(),n=[],o=[];t.forEach(t=>{r.includes(t)||(s=!0,t.fire("deselected",{e:e,target:t}),o.push(t))}),r.forEach(i=>{t.includes(i)||(s=!0,i.fire("selected",{e:e,target:i}),n.push(i))}),t.length>0&&r.length>0?(i=!0,s&&this.fire("selection:updated",{e:e,selected:n,deselected:o})):r.length>0?(i=!0,this.fire("selection:created",{e:e,selected:n})):t.length>0&&(i=!0,this.fire("selection:cleared",{e:e,deselected:o})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){const s=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(s,e),i}_setActiveObject(t,e){const s=this._activeObject;return!(s===t||!this._discardActiveObject(e,t)&&this._activeObject||t.onSelect({e:e})||(this._activeObject=t,Ye(t)&&s!==t&&t.set("canvas",this),t.setCoords(),0))}_discardActiveObject(t,e){const s=this._activeObject;return!!s&&!s.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===s&&this.endCurrentTransform(t),Ye(s)&&s===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),s=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[s]});const i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,s=e.target,i={e:t,target:s,transform:e,action:e.action};s._scaling&&(s._scaling=!1),s.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),s.fire(qt,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ye(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,s){const i=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,s);return t.set(i),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ye(e)&&this._activeObject===e){const s=Fe(t,["angle","flipX","flipY",Ot,Vt,Ht,zt,Gt,kt]);return((t,e)=>{is(t,_e(e,t.calcOwnMatrix()))})(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}$(Hn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCurs
1or:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class zn{constructor(t){$(this,"targets",[]),$(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},s=t.upperCanvasEl;s.addEventListener("click",e),this.__disposer=()=>s.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),te(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;(null===(e=this.target)||void 0===e?void 0:e.isEditing)&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Gn=["target","oldTarget","fireCanvas","e"],Nn={passive:!1},Un=(t,e)=>{const s=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:s,scenePoint:i,pointer:s,absolutePointer:i}},qn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return t.addEventListener(...s)},Kn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return t.removeEventListener(...s)},Jn={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class Zn extends Hn{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),$(this,"_isClick",void 0),$(this,"textEditingManager",new zn(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(qn,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(ze(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,Nn),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel,{passive:!1}),t(s,"contextmenu",this._onContextMenu),t(s,"click",this._onClick),t(s,"dblclick",this._onClick),t(s,"dragstart",this._onDragStart),t(s,"dragend",this._onDragEnd),t(s,"dragover",this._onDragOver),t(s,"dragenter",this._onDragEnter),t(s,"dragleave",this._onDragLeave),t(s,"drop",this._onDrop),this.enablePointerEvents||t(s,"touchstart",this._onTouchStart,Nn)}removeListeners(){this.addOrRemove(Kn,"remove");const t=this._getEventPrefix(),e=He(this.upperCanvasEl);Kn(e,"".concat(t,"up"),this._onMouseUp),Kn(e,"touchend",this._onTouchEnd,Nn),Kn(e,"".concat(t,"move"),this._onMouseMove,Nn),Kn(e,"touchmove",this._onMouseMove,Nn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,s=tt({e:t},Un(this,t));this.fire("mouse:out",tt(tt({},s),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",tt({},s)),this._hoveredTargets.forEach(t=>{this.fire("mouse:out",tt(tt({},s),{},{target:t})),t&&t.fire("mouseout",tt({},s))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",tt({e:t},Un(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const s={e:t,target:e};return this.fire("dragstart",s),e.fire("dragstart",s),void qn(this.upperCanvasEl,"drag",this._onDragProgress)}ts(t)}_renderDragEffects(t,e,s){let i=!1;const r=this._dropTarget;r&&r!==e&&r!==s&&(r.clearContextTop(),i=!0),null==e||e.clearContextTop(),s!==e&&(null==s||s.clearContextTop());const n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(
vendor: 4,524 bytes, line 1
1),i=!0),s&&(n.save(),s.transform(n),s.renderDropTargetEffect(t),n.restore(),i=!0),n.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==Et,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};Kn(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",i),this._dragSource&&this._dragSource.fire("dragend",i),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:s,targets:i}=this.findDragTargets(t),r=this._dragSource,n={e:t,target:s,subTargets:i,dragSource:r,canDrop:!1,dropTarget:void 0};let o;this.fire(e,n),this._fireEnterLeaveEvents(s,n),s&&(s.canDrop(t)&&(o=s),s.fire(e,n));for(let a=0;a<i.length;a++){const s=i[a];s.canDrop(t)&&(o=s),s.fire(e,n)}this._renderDragEffects(t,r,o),this._dropTarget=o}_onDragEnter(t){const{target:e,targets:s}=this.findDragTargets(t),i={e:t,target:e,subTargets:s,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(e,i)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:s}=this.findDragTargets(t),i=this._basicEventHandler("drop:before",tt({e:t,target:e,subTargets:s,dragSource:this._dragSource},Un(this,t)));i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){const e=this.findTarget(t),s=this.targets||[],i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:s});return this.stopContextMenu&&ts(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),2==e&&"dblclick"===t.type&&this._handleEvent(t,"dblclick"),3==e&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const s=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||s&&this._target===s)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const i=this.upperCanvasEl,r=this._getEventPrefix(),n=He(i);qn(n,"touchend",this._onTouchEnd,Nn),e&&qn(n,"touchmove",this._onMouseMove,Nn),Kn(i,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,s=this._getEventPrefix();Kn(e,"".concat(s,"move"),this._onMouseMove,Nn);const i=He(e);qn(i,"".concat(s,"up"),this._onMouseUp),qn(i,"".concat(s,"move"),this._onMouseMove,Nn)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=He(this.upperCanvasEl);Kn(s,"touchend",this._onTouchEnd,Nn),Kn(s,"touchmove",this._onMouseMove,Nn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{qn(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,s=this._getEventPrefix();if(this._isMainEvent(t)){const t=He(this.upperCanvasEl);Kn(t,"".concat(s,"up"),this._onMouseUp),Kn(t,"".concat(s,"move"),this._onMouseMove,Nn),qn(e,"".concat(s,"move"),this._onMouseMove,Nn)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");
1const s=this._currentTransform,i=this._isClick,r=this._target,{button:n}=t;if(n)return(this.fireMiddleClick&&1===n||this.fireRightClick&&2===n)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,a,h=!1;if(s&&(this._finalizeCurrentTransform(t),h=s.actionPerformed),!i){const e=r===this._activeObject;this.handleSelection(t),h||(h=this._shouldRender(r)||!e&&r===this._activeObject)}if(r){const e=r.findControl(this.getViewportPoint(t),Qe(t)),{key:i,control:n}=e||{};if(a=i,r.selectable&&r!==this._activeObject&&"up"===r.activeOn)this.setActiveObject(r,t),h=!0;else if(n){const e=n.getMouseUpHandler(t,r,n);e&&(o=this.getScenePoint(t),e.call(n,t,s,o.x,o.y))}r.isMoving=!1}if(s&&(s.target!==r||s.corner!==a)){const e=s.target&&s.target.controls[s.corner],i=e&&e.getMouseUpHandler(t,s.target,e);o=o||this.getScenePoint(t),i&&i.call(e,t,s,o.x,o.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),h?this.requestRenderAll():i||null!==(e=this._activeObject)&&void 0!==e&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:s,subTargets:i=[]}=e;this.fire(t,e),s&&s.fire(t,e);for(let r=0;r<i.length;r++)i[r]!==s&&i[r].fire(t,e);return e}_handleEvent(t,e,s){const i=this._target,r=this.targets||[],n=tt(tt(tt({e:t,target:i,subTargets:r},Un(this,t)),{},{transform:this._currentTransform},"up:before"===e||"up"===e?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),"down:before"===e||"down"===e?s:{});this.fire("mouse:".concat(e),n),i&&i.fire("mouse".concat(e),n);for(let o=0;o<r.length;o++)r[o]!==i&&r[o].fire("mouse".concat(e),n)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,s=!!e&&e===this._activeObject;const{button:i}=t;if(i)return(this.fireMiddleClick&&1===i||this.fireRightClick&&2===i)&&this._handleEvent(t,"down",{alreadySelected:s}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t))return;if(this._currentTransform)return;let r=this._shouldRender(e),n=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,n=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(s=!!e&&e===this._activeObject,e){e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);const i=e.findControl(this.getViewportPoint(t),Qe(t));if(e===this._activeObject&&(i||!n)){this._setupCurrentTransform(t,e,s);const r=i?i.control:void 0,n=this.getScenePoint(t),o=r&&r.getMouseDownHandler(t,e,r);o&&o.call(r,t,this._currentTransform,n.x,n.y)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:s}),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=as(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}
1__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const s=this.getScenePoint(t);e.deltaX=s.x-e.x,e.deltaY=s.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const e=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const s=this._hoveredTarget,i=this._hoveredTargets,r=this.targets,n=Math.max(i.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:s,fireCanvas:!0});for(let o=0;o<n;o++)r[o]===e||i[o]&&i[o]===s||this.fireSyntheticInOutEvents("mouse",{e:t,target:r[o],oldTarget:i[o]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const s=this._draggedoverTarget,i=this._hoveredTargets,r=this.targets,n=Math.max(i.length,r.length);this.fireSyntheticInOutEvents("drag",tt(tt({},e),{},{target:t,oldTarget:s,fireCanvas:!0}));for(let o=0;o<n;o++)this.fireSyntheticInOutEvents("drag",tt(tt({},e),{},{target:r[o],oldTarget:i[o]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:s,oldTarget:i,fireCanvas:r,e:n}=e,o=et(e,Gn);const{targetIn:a,targetOut:h,canvasIn:c,canvasOut:l}=Jn[t],u=i!==s;if(i&&u){const t=tt(tt({},o),{},{e:n,target:i,nextTarget:s},Un(this,n));r&&this.fire(l,t),i.fire(h,t)}if(s&&u){const t=tt(tt({},o),{},{e:n,target:s,previousTarget:i},Un(this,n));r&&this.fire(c,t),s.fire(a,t)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),s=this._currentTransform,i=s.target,r=i.group?as(e,void 0,i.group.calcTransformMatrix()):e;s.shiftKey=t.shiftKey,s.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,s,r),s.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,s){const{action:i,actionHandler:r,target:n}=e,o=!!r&&r(t,e,s.x,s.y);o&&n.setCoords(),"drag"===i&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let s=e.hoverCursor||this.hoverCursor;const i=Ye(this._activeObject)?this._activeObject:null,r=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(r){const s=r.control;this.setCursor(s.cursorStyleHandler(t,s,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(t=>{s=t.hoverCursor||s}),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=Ye(s);if(s&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(s!==e||i)&&(i||!e.isDescendantOf(s)&&!s.isDescendantOf(e))&&!e.onSelect({e:t})&&!s.getActiveControl()){if(i){const i=s.getObjects();if(e===s){const s=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(i,s)||this.searchPossibleTargets(this._objects,s))||!e.selectable)return!1}e.group===s?(s.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],1===s.size()&&this._setActiveObject(s.item(0),t)):(s.multiSelectAdd(e),this._hoveredTarget=s,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(i,t)}else{s.isEditing&&s.exitEditing();const i=new(Zt.getClass("ActiveSelection"))([],{canvas:this});i.multiSelectAdd(s,e),this._hoveredTarget=i,this._setActiveObject(i,t),this._fireSelectionEvents([s],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ie(e,s),o=n.add(new ie(i,r)),a=n.min(o),h=n.max(o).subtract(a),c=this.collectObjects({left:a.x,top:a.y,width:h.x,height:h.y},{includeIntersecting:!this.selectionFullyContained}),l=n.eq(o)?c[0]?[c[0]]:[]:c.length>1?c.filter(e=>!e.onSelect({e:t})).reverse():c;if(1===l.length)this.setActiveObject(l[0],t);else if(l.length>1){const e=Zt.getClass("ActiveSelection");this.setActiveObject(new e(l,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:s}=this.elements;s.ctx=void 0;const i=super.toCanvasElement(t,e);return s.ctx=s.el.getContext("2d"),i}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const $n={x1:0,y1:0,x2:0,y2:0},Qn=tt(tt({},$n),{},{r1:0,r2:0}),to=(t,e)=>isNaN(t)&&"number"==typeof e?e:t;function eo(t){return t&&/%$/.test(t)&&Number.isFinite(parseFloat(t))}function so(t,e){const s="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(eo(t)?100:1):NaN;return di(0,to(s,e),1)}const io=/\s*;\s*/,ro=/\s*:\s*/;function no(t,e){let s,i;const r=t.getAttribute("style");if(r){const t=r.split(io);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(ro).map(t=>t.trim());"stop-color"===r?s=n:"stop-opacity"===r&&(i=n)}}const n=new Os(s||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:so(t.getAttribute("offset"),0),color:n.toRgb(),opacity:to(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function oo(t,e){const s=[],i=t.getElementsByTagName("stop"),r=so(e,1);for(let n=i.length;n--;)s.push(no(i[n],r));return s}function ao(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function ho(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function co(t,e){return t.getAttribute(e)}function lo(t,e){return function(t,e){let s,{width:i,height:r,gradientUnits:n}=e;return Object.entries(t).reduce((t,e)=>{let[o,a]=e;if("Infinity"===a)s=1;else if("-Infinity"===a)s=0;else{const t="string"==typeof a;s=t?parseFloat(a):a,t&&eo(a)&&(s*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(s*=i),"y1"!==o&&"y2"!==o||(s*=r)))}return t[o]=s,t},{})}("linear"===ao(t)?{x1:co(s=t,"x1")||0,y1:co(s,"y1")||0,x2:co(s,"x2")||"100%",y2:co(s,"y2")||0}:function(t){return{x1:co(t,"fx")||co(t,"cx")||"50%",y1:co(t,"fy")||co(t,"cy")||"50%",r1:0,x2:co(t,"cx")||"50%",y2:co(t,"cy")||"50%",r2:co(t,"r")||"50%"}}(t),tt(tt({},e),{},{gradientUnits:ho(t)}));var s}class uo{constructor(t){const{type:e="linear",gradientUnits:s="pixels",coords:i={},colorStops:r=[],offsetX:n=0,offsetY:o=0,gradientTransform:a,id:h}=t||{};Object.assign(this,{type:e,gradientUnits:s,coords:tt(tt({}
1,"radial"===e?Qn:$n),i),colorStops:r,offsetX:n,offsetY:o,gradientTransform:a,id:h?"".concat(h,"_").concat(le()):le()})}addColorStop(t){for(const e in t){const s=new Os(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return tt(tt({},Fe(this,t)),{},{type:this.type,coords:tt({},this.coords),colorStops:this.colorStops.map(t=>tt({},t)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=[],i=this.gradientTransform?this.gradientTransform.concat():bt.concat(),r="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map(t=>tt({},t)).sort((t,e)=>t.offset-e.offset);let o=-this.offsetX,a=-this.offsetY;var h;"objectBoundingBox"===r?(o/=t.width,a/=t.height):(o+=t.width/2,a+=t.height/2),(h=t)&&"function"==typeof h._renderPathCommands&&"percentage"!==this.gradientUnits&&(o-=t.pathOffset.x,a-=t.pathOffset.y),i[4]-=o,i[5]-=a;const c=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Re(i),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:i,y2:r}=this.coords;s.push("<linearGradient ",c,' x1="',t,'" y1="',e,'" x2="',i,'" y2="',r,'">\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:i,y2:r,r1:o,r2:a}=this.coords,h=o>a;s.push("<radialGradient ",c,' cx="',h?t:i,'" cy="',h?e:r,'" r="',h?o:a,'" fx="',h?i:t,'" fy="',h?r:e,'">\n'),h&&(n.reverse(),n.forEach(t=>{t.offset=1-t.offset}));const l=Math.min(o,a);if(l>0){const t=l/Math.max(o,a);n.forEach(e=>{e.offset+=t*(1-e.offset)})}}return n.forEach(t=>{let{color:e,offset:i,opacity:r}=t;s.push("<stop ",'offset="',100*i+"%",'" style="stop-color:',e,void 0!==r?";stop-opacity: "+r:";",'"/>\n')}),s.push("linear"===this.type?"</linearGradient>":"</radialGradient>","\n"),s.join("")}toLive(t){const{x1:e,y1:s,x2:i,y2:r,r1:n,r2:o}=this.coords,a="linear"===this.type?t.createLinearGradient(e,s,i,r):t.createRadialGradient(e,s,n,i,r,o);return this.colorStops.forEach(t=>{let{color:e,opacity:s,offset:i}=t;a.addColorStop(i,void 0!==s?new Os(e).setAlpha(s).toRgba():e)}),a}static async fromObject(t){const{colorStops:e,gradientTransform:s}=t;return new this(tt(tt({},t),{},{colorStops:e?e.map(t=>tt({},t)):void 0,gradientTransform:s?[...s]:void 0}))}static fromElement(t,e,s){const i=ho(t),r=e._findCenterFromElement();return new this(tt({id:t.getAttribute("id")||void 0,type:ao(t),coords:lo(t,{width:s.viewBoxWidth||s.width,height:s.viewBoxHeight||s.height}),colorStops:oo(t,s.opacity),gradientUnits:i,gradientTransform:Jr(t.getAttribute("gradientTransform")||"")},"pixels"===i?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}$(uo,"type","Gradient"),Zt.setClass(uo,"gradient"),Zt.setClass(uo,"linear"),Zt.setClass(uo,"radial");const go=["type","source","patternTransform"];class fo{get type(){return"pattern"}set type(t){nt("warn","Setting type has no effect",t)}constructor(t){$(this,"repeat","repeat"),$(this,"offsetX",0),$(this,"offsetY",0),$(this,"crossOrigin",""),this.id=le(),Object.assign(this,t)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{repeat:e,crossOrigin:s}=this;return tt(tt({},Fe(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:s,offsetX:Ie(this.offsetX,rt.NUM_FRACTION_DIGITS),offsetY:Ie(this.offsetY,rt.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:s}=t;const{source:i,repeat:r,id:n}=this,o=to(this.offsetX/e,0),a=to(this.offsetY/s,0),h="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):to(i.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):to(i.height/s,0);return['<pattern id="SVGID_'.concat(n,'" x="').concat(o,'" y="').concat(a,'" width="').concat(h,'" height="').concat(c,'">'),'<image x="0" y="0" width="'.concat(i.width,'" height="').concat(i.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join("\n")}static async fromObject(t,e){let{type:s,source:i,patternTransform:r}=t,n=et(t,go);const o=await je(i,tt(tt({},e),{},{crossOrigin:n.crossOrigin}));return new this(tt(tt({},n),{},{patternTransform:r&&r.slice(0),source:o}))}}$(fo,"type","Pattern"),Zt.setClass(fo),Zt.setClass(fo,"pattern");const po=["path","left","top"],mo=["d"];class vo extends dr{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:s,left:i,top:r}=e,n=et(e,po);super(),Object.assign(this,vo.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),"number"==typeof i&&this.set(Ot,i),"number"==typeof r&&this.set(kt,r)}_setPath(t,e){this.path=(t=>{let e=0,s=0,i=0,r=0;const n=[];let o,a=0,h=0;for(const c of t){const t=[...c];let l;switch(t[0]){case"l":t[1]+=e,t[2]+=s;case"L":e=t[1],s=t[2],l=["L",e,s];break;case"h":t[1]+=e;case"H":e=t[1],l=["L",e,s];break;case"v":t[1]+=s;case"V":s=t[1],l=["L",e,s];break;case"m":t[1]+=e,t[2]+=s;case"M":e=t[1],s=t[2],i=t[1],r=t[2],l=["M",e,s];break;case"c":t[1]+=e,t[2]+=s,t[3]+=e,t[4]+=s,t[5]+=e,t[6]+=s;case"C":a=t[3],h=t[4],e=t[5],s=t[6],l=["C",t[1],t[2],a,h,e,s];break;case"s":t[1]+=e,t[2]+=s,t[3]+=e,t[4]+=s;
1case"S":"C"===o?(a=2*e-a,h=2*s-h):(a=e,h=s),e=t[3],s=t[4],l=["C",a,h,t[1],t[2],e,s],a=l[3],h=l[4];break;case"q":t[1]+=e,t[2]+=s,t[3]+=e,t[4]+=s;case"Q":a=t[1],h=t[2],e=t[3],s=t[4],l=["Q",a,h,e,s];break;case"t":t[1]+=e,t[2]+=s;case"T":"Q"===o?(a=2*e-a,h=2*s-h):(a=e,h=s),e=t[1],s=t[2],l=["Q",a,h,e,s];break;case"a":t[6]+=e,t[7]+=s;case"A":Tn(e,s,t).forEach(t=>n.push(t)),e=t[6],s=t[7];break;case"z":case"Z":e=i,s=r,l=["Z"]}l?(n.push(l),o=l[0]):o=""}return n})(Array.isArray(t)?t:(t=>{var e;const s=[],i=null!==(e=t.match(Rn))&&void 0!==e?e:[];for(const r of i){const t=r[0];if("z"===t||"Z"===t){s.push([t]);continue}const e=Xn[t.toLowerCase()];let i=[];if("a"===t||"A"===t){Bn.lastIndex=0;for(let t=null;t=Bn.exec(r);)i.push(...t.slice(1))}else i=r.match(Wn)||[];for(let r=0;r<i.length;r+=e){const n=new Array(e),o=Cn[t];n[0]=r>0&&o?o:t;for(let t=0;t<e;t++)n[t+1]=parseFloat(i[r+t]);s.push(n)}}return s})(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ie(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,s=-this.pathOffset.y;t.beginPath();for(const i of this.path)switch(i[0]){case"L":t.lineTo(i[1]+e,i[2]+s);break;case"M":t.moveTo(i[1]+e,i[2]+s);break;case"C":t.bezierCurveTo(i[1]+e,i[2]+s,i[3]+e,i[4]+s,i[5]+e,i[6]+s);break;case"Q":t.quadraticCurveTo(i[1]+e,i[2]+s,i[3]+e,i[4]+s);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),{},{path:this.path.map(t=>t.slice())})}toDatalessObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=((t,e)=>t.map(t=>t.map((t,s)=>0===s||void 0===e?t:Ie(t,e)).join(" ")).join(" "))(this.path,rt.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,'" stroke-linecap="round" />\n')]}_getOffsetTransform(){const t=rt.NUM_FRACTION_DIGITS;return" translate(".concat(Ie(-this.pathOffset.x,t),", ").concat(Ie(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:s,pathOffset:i}=this._calcDimensions();this.set({width:e,height:s,pathOffset:i}),t&&this.setPositionByOrigin(i,Tt,Tt)}_calcBoundsFromPath(){const t=[];let e=0,s=0,i=0,r=0;for(const n of this.path)switch(n[0]){case"L":i=n[1],r=n[2],t.push({x:e,y:s},{x:i,y:r});break;case"M":i=n[1],r=n[2],e=i,s=r;break;case"C":t.push(...Sn(i,r,n[1],n[2],n[3],n[4],n[5],n[6])),i=n[5],r=n[6];break;case"Q":t.push(...Sn(i,r,n[1],n[2],n[1],n[2],n[3],n[4])),i=n[3],r=n[4];break;case"Z":i=e,r=s}return es(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return tt(tt({},t),{},{pathOffset:new ie(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,s){const i=Qr(t,this.ATTRIBUTE_NAMES,s),{d:r}=i;return new this(r,tt(tt(tt({},et(i,mo)),e),{},{left:void 0,top:void 0}))}}$(vo,"type","Path"),$(vo,"cacheProperties",[...fi,"path","fillRule"]),$(vo,"ATTRIBUTE_NAMES",[...Tr,"d"]),Zt.setClass(vo),Zt.setSVGClass(vo);const yo=["left","top","radius"],_o=["radius","startAngle","endAngle","counterClockwise"];class xo extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),xo.ownDefaults)}constructor(t){super(),Object.assign(this,xo.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,pe(this.startAngle),pe(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(Vt)}getRadiusY(){return this.get("radius")*this.get(Ht)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([..._o,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),'" />\n'];{const{radius:e}=this,s=pe(this.startAngle),i=pe(this.endAngle),r=ee(s)*e,n=se(s)*e,o=ee(i)*e,a=se(i)*e,h=t>180?1:0,c=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(n," A ").concat(e," ").concat(e," 0 ").concat(h," ").concat(c," ").concat(o," ").concat(a,'" '),"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,s){const i=Qr(t,this.ATTRIBUTE_NAMES,s),{left:r=0,top:n=0,radius:o=0}
1=i;return new this(tt(tt({},et(i,yo)),{},{radius:o,left:r-o,top:n-o}))}static fromObject(t){return super._fromObject(t)}}$(xo,"type","Circle"),$(xo,"cacheProperties",[...fi,..._o]),$(xo,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),$(xo,"ATTRIBUTE_NAMES",["cx","cy","r",...Tr]),Zt.setClass(xo),Zt.setSVGClass(xo);const Co=["x1","y1","x2","y2"],bo=["x1","y1","x2","y2"],wo=["x1","x2","y1","y2"];class So extends dr{constructor(){let[t,e,s,i]=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,So.ownDefaults),this.setOptions(r),this.x1=t,this.x2=s,this.y1=e,this.y2=i,this._setWidthHeight();const{left:n,top:o}=r;"number"==typeof n&&this.set(Ot,n),"number"==typeof o&&this.set(kt,o)}_setWidthHeight(){const{x1:t,y1:e,x2:s,y2:i}=this;this.width=Math.abs(s-t),this.height=Math.abs(i-e);const{left:r,top:n,width:o,height:a}=es([{x:t,y:e},{x:s,y:i}]),h=new ie(r+o/2,n+a/2);this.setPositionByOrigin(h,Tt,Tt)}_set(t,e){return super._set(t,e),wo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const s=t.strokeStyle;var i;Be(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null!==(i=this.stroke)&&void 0!==i?i:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=s}_findCenterFromElement(){return new ie((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:s,y2:i,width:r,height:n}=this,o=t<=e?-1:1,a=s<=i?-1:1;return{x1:o*r/2,x2:o*-r/2,y1:a*n/2,y2:a*-n/2}}_toSVG(){const{x1:t,x2:e,y1:s,y2:i}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(s,'" x2="').concat(e,'" y2="').concat(i,'" />\n')]}static async fromElement(t,e,s){const i=Qr(t,this.ATTRIBUTE_NAMES,s),{x1:r=0,y1:n=0,x2:o=0,y2:a=0}=i;return new this([r,n,o,a],et(i,Co))}static fromObject(t){let{x1:e,y1:s,x2:i,y2:r}=t,n=et(t,bo);return this._fromObject(tt(tt({},n),{},{points:[e,s,i,r]}),{extraParam:"points"})}}$(So,"type","Line"),$(So,"cacheProperties",[...fi,...wo]),$(So,"ATTRIBUTE_NAMES",Tr.concat(wo)),Zt.setClass(So),Zt.setSVGClass(So);class To extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),To.ownDefaults)}constructor(t){super(),Object.assign(this,To.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,s=this.height/2;t.beginPath(),t.moveTo(-e,s),t.lineTo(0,-s),t.lineTo(e,s),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}$(To,"type","Triangle"),$(To,"ownDefaults",{width:100,height:100}),Zt.setClass(To),Zt.setSVGClass(To);const Oo=["rx","ry"];class ko extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),ko.ownDefaults)}constructor(t){super(),Object.assign(this,ko.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(Vt)}getRy(){return this.get("ry")*this.get(Ht)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...Oo,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,'" />\n')]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,xt,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=Qr(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}$(ko,"type","Ellipse"),$(ko,"cacheProperties",[...fi,...Oo]),$(ko,"ownDefaults",{rx:0,ry:0}),$(ko,"ATTRIBUTE_NAMES",[...Tr,"cx","cy","rx","ry"]),Zt.setClass(ko),Zt.setSVGClass(ko);const Do=["left","top"],Mo={exactBoundingBox:!1};class Eo extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),Eo.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),$(this,"strokeDiff",void 0),Object.assign(this,Eo.ownDefaults),this.setOptions(e),this.points=t;const{left:s,top:i}=e;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof s&&this.set(Ot,s),"number"==typeof i&&this.set(kt,i)}isOpen(){return!0}_projectStrokeOnPoints(t){return function(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=[];if(0===t.length)return i;const r=t.reduce((t,e)=>(t[t.length-1].eq(e)||t.push(new ie(e)),t),[new ie(t[0])]);if(1===r.length)s=!0;else if(!s){const t=r[0],e=((t,e)=>{for(let s=t.length-1;s>=0;s--)if(e(t[s]))return s;return-1})(r,e=>!e.eq(t));r.splice(e+1)}return r.forEach((t,r,n)=>{let o,a;0===r?(a=n[1],o=s?t:n[n.length-1]):r===n.length-1?(o=n[r-1],a=s?t:n[0]):(o=n[r-1],a=n[r+1]),s&&1===n.length?i.push(...new mr(t,t,e).project()):!s||0!==r&&r!==n.length-1?i.push(...new pr(t,o,a,e).project()):i.push(...new mr(t,0===r?a:o,e).project())}),i}(this.points,t,this.isOpen())}_calcDimensions(t){t=tt({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(t=>t.projectedPoint):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new ie,strokeOffset:new ie,strokeDiff:new ie};const s=es(e),i=Me(tt(tt({},t),{},{scaleX:1,scaleY:1}
1)),r=es(this.points.map(t=>ve(t,i,!0))),n=new ie(this.scaleX,this.scaleY);let o=s.left+s.width/2,a=s.top+s.height/2;return this.exactBoundingBox&&(o-=a*Math.tan(pe(this.skewX)),a-=o*Math.tan(pe(this.skewY))),tt(tt({},s),{},{pathOffset:new ie(o,a),strokeOffset:new ie(r.left,r.top).subtract(new ie(s.left,s.top)).multiply(n),strokeDiff:new ie(s.width,s.height).subtract(new ie(r.width,r.height)).multiply(n)})}_findCenterFromElement(){const t=es(this.points);return new ie(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:s,width:i,height:r,pathOffset:n,strokeOffset:o,strokeDiff:a}=this._calcDimensions();this.set({width:i,height:r,pathOffset:n,strokeOffset:o,strokeDiff:a}),t&&this.setPositionByOrigin(new ie(e+i/2,s+r/2),Tt,Tt)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ie(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.exactBoundingBox){let n;if(Object.keys(t).some(t=>this.strokeUniform||this.constructor.layoutProperties.includes(t))){var e,s;const{width:i,height:r}=this._calcDimensions(t);n=new ie(null!==(e=t.width)&&void 0!==e?e:i,null!==(s=t.height)&&void 0!==s?s:r)}else{var i,r;n=new ie(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new ie(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const s=this.initialized&&this[t]!==e,i=super._set(t,e);return this.exactBoundingBox&&s&&((t===Vt||t===Ht)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),i}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),{},{points:this.points.map(t=>{let{x:e,y:s}=t;return{x:e,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,s=this.pathOffset.y,i=rt.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r<n;r++)t.push(Ie(this.points[r].x-e,i),",",Ie(this.points[r].y-s,i)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),'" />\n')]}_render(t){const e=this.points.length,s=this.pathOffset.x,i=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-s,this.points[0].y-i);for(let r=0;r<e;r++){const e=this.points[r];t.lineTo(e.x-s,e.y-i)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,s){return new this(function(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),s=[];for(let i=0;i<e.length;i+=2)s.push({x:parseFloat(e[i]),y:parseFloat(e[i+1])});return s}(t.getAttribute("points")),tt(tt({},et(Qr(t,this.ATTRIBUTE_NAMES,s),Do)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}$(Eo,"ownDefaults",Mo),$(Eo,"type","Polyline"),$(Eo,"layoutProperties",[zt,Gt,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),$(Eo,"cacheProperties",[...fi,"points"]),$(Eo,"ATTRIBUTE_NAMES",[...Tr]),Zt.setClass(Eo),Zt.setSVGClass(Eo);class jo extends Eo{isOpen(){return!1}}$(jo,"ownDefaults",Mo),$(jo,"type","Polygon"),Zt.setClass(jo),Zt.setSVGClass(jo);class Po extends dr{isEmptyStyles(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;const e=void 0===t?this.styles:{line:this.styles[t]};for(const s in e)for(const t in e[s])for(const i in e[s][t])return!1;return!0}styleHas(t,e){if(!this.styles)return!1;if(void 0!==e&&!this.styles[e])return!1;const s=void 0===e?this.styles:{0:this.styles[e]};for(const i in s)for(const e in s[i])if(void 0!==s[i][e][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let s,i,r=0,n=!0,o=0;for(const a in e){s=0;for(const o in e[a]){const h=e[a][o]||{};r++,void 0!==h[t]?(i?h[t]!==i&&(n=!1):i=h[t],h[t]===this[t]&&delete h[t]):n=!1,0!==Object.keys(h).length?s++:delete e[a][o]}0===s&&delete e[a]}for(let a=0;a<this._textLines.length;a++)o+=this._textLines[a].length;n&&r===o&&(this[t]=i,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let s,i,r;for(i in e){for(r in s=e[i],s)delete s[r][t],0===Object.keys(s[r]).length&&delete s[r];0===Object.keys(s).length&&delete e[i]}}_extendStyles(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t);this._getLineStyle(s)||this._setLineStyle(s);const r=Le(tt(tt({},this._getStyleDeclaration(s,i)),e),t=>void 0!==t);this._setStyleDeclaration(s,i,r)}getSelectionStyles(t,e,s){const i=[];for(let r=t;r<(e||t);r++)i.push(this.getStyleAtPosition(r,s));return i}getStyleAtPosition(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(s,i):this._getStyleDeclaration(s,i)}setSelectionStyles(t,e,s){for(let i=e;i<(s||e);i++)this._extendStyles(i,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var s;const i=this.styles&&this.styles[t];return i&&null!==(s=i[e])&&void 0!==s?s:{}}getCompleteStyleDeclaration(t,e){return tt(tt({},Fe(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,s){this.styles[t][e]=s}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}$(Po,"_styleProperties",Is);const Ao=/  +/g,Fo=/"/g;function Lo(t,e,s,i,r){return"\t\t".concat(function(t,e){let{left:s,top:i,width:r,height:n}=e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:rt.NUM_FRACTION_DIGITS;const a=Ds(Nt,t,!1),[h,c,l,u]=[s,i,r,n].map(t=>Ie(t,o));return"<rect ".concat(a,' x="').concat(h,'" y="').concat(c,'" width="').concat(l,'" height="').concat(u,'"></rect>')}(t,{left:e,top:s,width:i,height:r}),"\n")}const Io=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Ro;class Bo extends Po{static getDefaults(){return tt(tt({},super.getDefaults()),Bo.ownDefaults)}constructor(t,e){super(),$(this,"__charBounds",[]),Object.assign(this,Bo.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Ln(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Bs)&&this.enlargeSpace
vendor: 4,547 bytes, line 1
1s()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let a=0,h=this._textLines.length;a<h;a++)if((this.textAlign===Bs||a!==h-1&&!this.isEndOfWrapping(a))&&(i=0,r=this._textLines[a],e=this.getLineWidth(a),e<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){s=o.length,t=(this.width-e)/s;for(let e=0;e<=r.length;e++)n=this.__charBounds[a][e],this._reSpaceAndTab.test(r[e])?(n.width+=t,n.kernedWidth+=t,n.left+=i,i+=t):n.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const s=e?this._unwrappedTextLines:this._textLines;let i;for(i=0;i<s.length;i++){if(t<=s[i].length)return{lineIndex:i,charIndex:t};t-=s[i].length+this.missingNewlineOffset(i,e)}return{lineIndex:i-1,charIndex:s[i-1].length<t?s[i-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===Ut?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,s){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case Tt:t.textBaseline="middle";break;case"ascender":t.textBaseline=kt;break;case"descender":t.textBaseline=Dt}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;e<s;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,s,i,r,n){this._renderChars(t,e,s,i,r,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,s=this._getLeftOffset();let i=this._getTopOffset();for(let r=0,n=this._textLines.length;r<n;r++){const e=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){i+=e;continue}const n=this._textLines[r].length,o=this._getLineLeftOffset(r);let a,h,c=0,l=0,u=this.getValueOfPropertyAt(r,0,"textBackgroundColor");const d=this.getHeightOfLineImpl(r);for(let g=0;g<n;g++){const e=this.__charBounds[r][g];h=this.getValueOfPropertyAt(r,g,"textBackgroundColor"),this.path?(t.save(),t.translate(e.renderLeft,e.renderTop),t.rotate(e.angle),t.fillStyle=h,h&&t.fillRect(-e.width/2,-d*(1-this._fontSizeFraction),e.width,d),t.restore()):h!==u?(a=s+o+l,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=u,u&&t.fillRect(a,i,c,d),l=e.left,c=e.width,u=h):c+=e.kernedWidth}h&&!this.path&&(a=s+o+l,"rtl"===this.direction&&(a=this.width-a-c),t.fillStyle=h,t.fillRect(a,i,c,d)),i+=e}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,s,i){const r=mt.getFontCache(e),n=this._getFontDeclaration(e),o=s?s+t:t,a=s&&n===this._getFontDeclaration(i),h=e.fontSize/this.CACHE_FONT_SIZE;let c,l,u,d;if(s&&r.has(s)&&(u=r.get(s)),r.has(t)&&(d=c=r.get(t)),a&&r.has(o)&&(l=r.get(o),d=l-u),void 0===c||void 0===u||void 0===l){const i=function(){if(!Ro){const t=de({width:0,height:0});Ro=t.getContext("2d")}return Ro}();this._setTextStyles(i,e,!0),void 0===c&&(d=c=i.measureText(t).width,r.set(t,c)),void 0===u&&a&&s&&(u=i.measureText(s).width,r.set(s,u)),a&&void 0===l&&(l=i.measureText(o).width,r.set(o,l),d=l-u)}return{width:c*h,kernedWidth:d*h}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,s,i=0;const r=this.pathSide===Mt,n=this.path,o=this._textLines[t],a=o.length,h=new Array(a);this.__charBounds[t]=h;for(let c=0;c<a;c++){const r=o[c];s=this._getGraphemeBox(r,t,c,e),h[c]=s,i+=s.kernedWidth,e=r}if(h[a]={left:s?s.left+s.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let t=0;const e=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case Ot:t=r?e-i:0;break;case Tt:t=(e-i)/2;break;case Mt:t=r?0:e-i}t+=this.pathStartOffset*(r?-1:1);for(let i=r?a-1:0;r?i>=0:i<a;r?i--:i++)s=h[i],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,s),t+=s.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){const s=t+e.kernedWidth/2,i=this.path,r=In(i.path,s,i.segmentsInfo);
1e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===Mt?Math.PI:0)}_getGraphemeBox(t,e,s,i,r){const n=this.getCompleteStyleDeclaration(e,s),o=i?this.getCompleteStyleDeclaration(e,s-1):{},a=this._measureChar(t,n,i,o);let h,c=a.kernedWidth,l=a.width;0!==this.charSpacing&&(h=this._getWidthOfCharSpacing(),l+=h,c+=h);const u={width:l,left:0,height:n.fontSize,kernedWidth:c,deltaY:n.deltaY};if(s>0&&!r){const t=this.__charBounds[e][s-1];u.left=t.left+t.width+a.kernedWidth-a.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let s=this.getHeightOfChar(t,0);for(let i=1,r=this._textLines[t].length;i<r;i++)s=Math.max(this.getHeightOfChar(t,i),s);return e[t]=s*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,s=this._textLines.length;e<s;e++)t+=e===s-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return"ltr"===this.direction?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let s=0;const i=this._getLeftOffset(),r=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++)this._renderTextLine(e,t,this._textLines[n],i+this._getLineLeftOffset(n),r+s+this.getHeightOfLineImpl(n),n),s+=this.getHeightOfLine(n);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Nt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,s,i,r,n){const o=this.textAlign.includes(Bs),a=this.path,h=!o&&0===this.charSpacing&&this.isEmptyStyles(n)&&!a,c="ltr"===this.direction,l="ltr"===this.direction?1:-1,u=e.direction;let d,g,f,p,m,v="",y=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",c?"ltr":"rtl"),e.direction=c?"ltr":"rtl",e.textAlign=c?Ot:Mt),r-=this.getHeightOfLineImpl(n)*this._fontSizeFraction,h)return this._renderChar(t,e,n,0,s.join(""),i,r),void e.restore();for(let _=0,x=s.length-1;_<=x;_++)p=_===x||this.charSpacing||a,v+=s[_],f=this.__charBounds[n][_],0===y?(i+=l*(f.kernedWidth-f.width),y+=f.width):y+=f.kernedWidth,o&&!p&&this._reSpaceAndTab.test(s[_])&&(p=!0),p||(d=d||this.getCompleteStyleDeclaration(n,_),g=this.getCompleteStyleDeclaration(n,_+1),p=br(d,g,!1)),p&&(a?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,n,_,v,-y/2,0),e.restore()):(m=i,this._renderChar(t,e,n,_,v,m,r)),v="",d=g,i+=l*y,y=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,s=this.height+this.strokeWidth,i=de({width:e,height:s}),r=i.getContext("2d");return i.width=e,i.height=s,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,s),r.lineTo(0,s),r.closePath(),r.translate(e/2,s/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(i,"no-repeat")}handleFiller(t,e,s){let i,r;return Be(s)?"percentage"===s.gradientUnits||s.gradientTransform||s.patternTransform?(i=-this.width/2,r=-this.height/2,t.translate(i,r),t[e]=this._applyPatternGradientTransformText(s),{offsetX:i,offsetY:r}):(t[e]=s.toLive(t),this._applyPatternGradientTransform(t,s)):(t[e]=s,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:s,strokeWidth:i}=e;return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",s)}_setFillStyles(t,e){let{fill:s}=e;return this.handleFiller(t,"fillStyle",s)}_renderChar(t,e,s,i,r,n,o){const a=this._getStyleDeclaration(s,i),h=this.getCompleteStyleDeclaration(s,i),c="fillText"===t&&h.fill,l="strokeText"===t&&h.stroke&&h.strokeWidth;if(l||c){if(e.save(),e.font=this._getFontDeclaration(h),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(o+=a.deltaY),c){const t=this._setFillStyles(e,h);e.fillText(r,n-t.offsetX,o-t.offsetY)}if(l){const t=this._setStrokeStyles(e,h);e.strokeText(r,n-t.offsetX,o-t.offsetY)}
1e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,s){const i=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),n=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),o={fontSize:r*s.size,deltaY:n+r*s.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),s=this.width-e,i=this.textAlign,r=this.direction,n=this.isEndOfWrapping(t);let o=0;return i===Bs||i===Ys&&!n||i===Xs&&!n||i===Ws&&!n?0:(i===Tt&&(o=s/2),i===Mt&&(o=s),i===Ys&&(o=s/2),i===Xs&&(o=s),"rtl"===r&&(i===Mt||i===Bs||i===Xs?o=0:i===Ot||i===Ws?o=-s:i!==Tt&&i!==Ys||(o=-s/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,s){var i;return null!==(i=this._getStyleDeclaration(t,e)[s])&&void 0!==i?i:this[s]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let s=this._getTopOffset();const i=this._getLeftOffset(),r=this.path,n=this._getWidthOfCharSpacing(),o="linethrough"===e?.5:"overline"===e?1:0,a=this.offsets[e];for(let h=0,c=this._textLines.length;h<c;h++){const c=this.getHeightOfLine(h);if(!this[e]&&!this.styleHas(e,h)){s+=c;continue}const l=this._textLines[h],u=c/this.lineHeight,d=this._getLineLeftOffset(h);let g=0,f=0,p=this.getValueOfPropertyAt(h,0,e),m=this.getValueOfPropertyAt(h,0,Nt),v=this.getValueOfPropertyAt(h,0,js),y=p,_=m,x=v;const C=s+u*(1-this._fontSizeFraction);let b=this.getHeightOfChar(h,0),w=this.getValueOfPropertyAt(h,0,"deltaY");for(let s=0,n=l.length;s<n;s++){const n=this.__charBounds[h][s];y=this.getValueOfPropertyAt(h,s,e),_=this.getValueOfPropertyAt(h,s,Nt),x=this.getValueOfPropertyAt(h,s,js);const c=this.getHeightOfChar(h,s),l=this.getValueOfPropertyAt(h,s,"deltaY");if(r&&y&&_){const e=this.fontSize*x/1e3;t.save(),t.fillStyle=m,t.translate(n.renderLeft,n.renderTop),t.rotate(n.angle),t.fillRect(-n.kernedWidth/2,a*c+l-o*e,n.kernedWidth,e),t.restore()}else if((y!==p||_!==m||c!==b||x!==v||l!==w)&&f>0){const e=this.fontSize*v/1e3;let s=i+d+g;"rtl"===this.direction&&(s=this.width-s-f),p&&m&&v&&(t.fillStyle=m,t.fillRect(s,C+a*b+w-o*e,f,e)),g=n.left,f=n.width,p=y,v=x,m=_,b=c,w=l}else f+=n.kernedWidth}let S=i+d+g;"rtl"===this.direction&&(S=this.width-S-f),t.fillStyle=_;const T=this.fontSize*x/1e3;y&&_&&x&&t.fillRect(S,C+a*b+w-o*T,f-n,T),s+=c}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:s=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const n=t.includes("'")||t.includes('"')||t.includes(",")||Bo.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,s,"".concat(r?this.CACHE_FONT_SIZE:i,"px"),n].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return _r(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=["\n"];let r=[];for(let n=0;n<e.length;n++)s[n]=this.graphemeSplit(e[n]),r=r.concat(s[n],i);return r.pop(),{_unwrappedLines:s,lines:e,graphemeText:r,graphemeLines:s}}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject([...Ls,...t])),{},{styles:wr(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:s}=this.constructor;super.set(t,e);let i=!1,r=!1;if("object"==typeof t)for(const n in t)"path"===n&&this.setPathInfo(),i=i||s.includes(n),r=r||"path"===n;else i=s.includes(t),r="path"===t;return r&&this.setPathInfo(),i&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,s){const i=Qr(t,Bo.ATTRIBUTE_NAMES,s),r=tt(tt({}
vendor: 9,784 bytes, line 1
1,e),i),{textAnchor:n=Ot,textDecoration:o="",dx:a=0,dy:h=0,top:c=0,left:l=0,fontSize:u=wt,strokeWidth:d=1}=r,g=et(r,Io),f=new this(_s(t.textContent||"").trim(),tt({left:l+a,top:c+h,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:u},g)),p=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*p,v=f.getScaledHeight()+m;let y=0;return n===Tt&&(y=f.getScaledWidth()/2),n===Mt&&(y=f.getScaledWidth()),f.set({left:f.left-y,top:f.top-(v-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:d}),f}static fromObject(t){return this._fromObject(tt(tt({},t),{},{styles:Sr(t.styles||{},t.text)}),{extraParam:"text"})}}$(Bo,"textLayoutProperties",Fs),$(Bo,"cacheProperties",[...fi,...Ls]),$(Bo,"ownDefaults",Rs),$(Bo,"type","Text"),$(Bo,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),$(Bo,"ATTRIBUTE_NAMES",Tr.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),ur(Bo,[class extends Ms{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){const e=this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0}),s=this.path;return s?e+s._createBaseSVGMarkup(s._toSVG(),{reviver:t,withShadow:!0,additionalTransform:Re(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(t){let{textBgRects:e,textSpans:s}=t;const i=this.getSvgTextDecoration(this);return[e.join(""),'\t\t<text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(Fo,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"","rtl"===this.direction?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",s.join(""),"</text>\n"]}_getSVGTextAndBg(t,e){const s=[],i=[];let r,n=t;this.backgroundColor&&i.push(...Lo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)r=this._getLineLeftOffset(o),"rtl"===this.direction&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,e+r,n),this._setSVGTextLineText(s,o,e+r,n),n+=this.getHeightOfLine(o);return{textSpans:s,textBgRects:i}}_createTextCharSpan(t,e,s,i,r){const n=rt.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(Ao)),a=o?'style="'.concat(o,'"'):"",h=e.deltaY,c=h?' dy="'.concat(Ie(h,n),'" '):"",{angle:l,renderLeft:u,renderTop:d,width:g}=r;let f="";if(void 0!==u){const t=g/2;l&&(f=' rotate="'.concat(Ie(me(l),n),'"'));const e=Se({angle:me(l)});e[4]=u,e[5]=d;const r=new ie(-t,0).transform(e);s=r.x,i=r.y}return'<tspan x="'.concat(Ie(s,n),'" y="').concat(Ie(i,n),'" ').concat(c).concat(f).concat(a,">").concat((t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))(t),"</tspan>")}_setSVGTextLineText(t,e,s,i){const r=this.getHeightOfLine(e),n=this.textAlign.includes(Bs),o=this._textLines[e];let a,h,c,l,u,d="",g=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,p=o.length-1;f<=p;f++)u=f===p||this.charSpacing||this.path,d+=o[f],c=this.__charBounds[e][f],0===g?(s+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,f),h=this.getCompleteStyleDeclaration(e,f+1),u=br(a,h,!0)),u&&(l=this._getStyleDeclaration(e,f),t.push(this._createTextCharSpan(d,l,s,i,c)),d="",a=h,"rtl"===this.direction?s-=g:s+=g,g=0)}_setSVGTextLineBg(t,e,s,i){const r=this._textLines[e],n=this.getHeightOfLine(e)/this.lineHeight;let o,a=0,h=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let l=0;l<r.length;l++){const{left:r,width:u,kernedWidth:d}=this.__charBounds[e][l];o=this.getValueOfPropertyAt(e,l,"textBackgroundColor"),o!==c?(c&&t.push(...Lo(c,s+h,i,a,n)),h=r,a=u,c=o):a+=d}o&&t.push(...Lo(c,s+h,i,a,n))}_getSVGLineTopOffset(t){let e,s=0;for(e=0;e<t;e++)s+=this.getHeightOfLine(e);const i=this.getHeightOfLine(e);return{lineTop:s,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(t){return"".concat(super.getSvgStyles(t)," text-decoration-thickness: ").concat(Ie(this.textDecorationThickness*this.getObjectScaling().y/10,rt.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(t,e){const{fontFamily:s,strokeWidth:i,stroke:r,fill:n,fontSize:o,fontStyle:a,fontWeight:h,deltaY:c,textDecorationThickness:l,linethrough:u,overline:d,underline:g}=t,f=this.getSvgTextDecoration({underline:null!=g?g:this.underline,overline:null!=d?d:this.overline,linethrough:null!=u?u:this.linethrough}),p=l||this.textDecorationThickness;return[r?Ds(Ut,r):"",i?"stroke-width: ".concat(i,"; "):"",s?"font-family: ".concat(s.includes("'")||s.includes('"')?s:"'".concat(s,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",h?"font-weight: ".concat(h,"; "):"",f?"text-decoration: ".concat(f,"; text-decoration-thickness: ").concat(Ie(p*this.getObjectScaling().y/10,rt.NUM_FRACTION_DIGITS),"%; "):"",n?Ds(Nt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter(e=>t[e.replace("-","")]).join(" ")}}]),Zt.setClass(Bo),Zt.setSVGClass(Bo);class Wo{constructor(t){$(this,"target",void 0),$(this,"__mouseDownInPlace",!1),$(this,"__dragStartFired",!1),$(this,"__isDraggingOver",!1),$(this,"__dragStartSelection",void 0),$(this,"__dragImageDisposer",void 0),$(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(t=>t()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,s=e.getSelectionStartFromPointer(t);return e.isEditing&&s>=e.selectionStart&&s<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var s;let{selectionStart:i,selectionEnd:r}=e;const n=this.target,o=n.canvas,a=new ie(n.flipX?-1:1,n.flipY?-1:1),h=n._getCursorBoundaries(i),c=new ie(h.left+h.leftOffset,h.top+h.topOffset).multiply(a).transform(n.calcTransformMatrix()),l=o.getScenePoint(t).subtract(c),u=n.getCanvasRetinaScaling(),d=n.getBoundingRect(),g=c.subtract(new ie(d.left,d.top)),f=o.viewportTransform,p=g.add(l).transform(f,!0),m=n.backgroundColor,v=vr(n.styles);n.backgroundColor="";const y={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(y,0,i),n.setSelectionStyles(y,r,n.text.length),n.dirty=!0;const _=n.toCanvasElement({enableRetinaScaling:o.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=m,n.styles=v,n.dirty=!0,Yn(_,{position:"fixed",left:"".concat(-_.width,"px"),border:Et,width:"".concat(_.width/u,"px"),height:"".concat(_.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{_.remove()},He(t.target||this.target.hiddenTextarea).body.appendChild(_),null===(s=t.dataTransfer)||void 0===s||s.setDragImage(_,p.x,p.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,s=this.isActive();if(s&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},i=e._text.slice(s.selectionStart,s.selectionEnd).join(""),r=tt({text:e.text,value:i},s);t.dataTransfer.setData("text/plain",i),t.dataTransfer.setData("application/fabric",JSON.stringify({value:i,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,r)}return e.abortCursorAnimation(),s}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),s=this.__dragStartSelection;return e<s.selectionStart||e>s.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e:e}=t;const s=this.targetCanDrop(e);!this.__isDraggingOver&&s&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e:e}=t,s=this.targetCanDrop(e);!this.__isDraggingOver&&s?this.__isDraggingOver=!0:this.__isDraggingOver&&!s&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:s}=t,i=s.defaultPrevented;this.__isDraggingOver=!1,s.preventDefault();let r=null===(e=s.dataTransfer)||void 0===e?void 0:e.getData("text/plain");if(r&&!i){const e=this.target,i=e.canvas;let n=e.getSelectionStartFromPointer(s);const{styles:o}=s.dataTransfer.types.includes("application/fabric")?JSON.parse(s.dataTransfer.getData("application/fabric")):{},a=r[Math.max(0,r.length-1)],h=0;
1if(this.__dragStartSelection){const t=this.__dragStartSelection.selectionStart,s=this.__dragStartSelection.selectionEnd;n>t&&n<=s?n=t:n>s&&(n-=s-t),e.removeChars(t,s),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[n])||n===e._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(r,o,n),i.setActiveObject(e),e.enterEditing(s),e.selectionStart=Math.min(n+h,e._text.length),e.selectionEnd=Math.min(e.selectionStart+r.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(Xt,{index:n+h,action:"drop"}),i.fire("text:changed",{target:e}),i.contextTopDirty=!0,i.requestRenderAll()}}dragEndHandler(t){let{e:e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var s;const t=this.target,i=this.target.canvas,{selectionStart:r,selectionEnd:n}=this.__dragStartSelection,o=(null===(s=e.dataTransfer)||void 0===s?void 0:s.dropEffect)||Et;o===Et?(t.selectionStart=r,t.selectionEnd=n,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===o&&(t.removeChars(r,n),t.selectionStart=t.selectionEnd=r,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(Xt,{index:r,action:"dragend"}),i.fire("text:changed",{target:t}),i.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Xo=/[ \n\.,;!\?\-]/;class Yo extends Bo{constructor(){super(...arguments),$(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:s,delay:i,onComplete:r}=t;return ki({startValue:this._currentCursorOpacity,endValue:e,duration:s,delay:i,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;null===(t=this._currentTickCompleteState)||void 0===t||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,s=t-1;if(this._reSpace.test(this._text[s]))for(;this._reSpace.test(this._text[s]);)e++,s--;for(;/\S/.test(this._text[s])&&s>-1;)e++,s--;return t-e}findWordBoundaryRight(t){let e=0,s=t;if(this._reSpace.test(this._text[s]))for(;this._reSpace.test(this._text[s]);)e++,s++;for(;/\S/.test(this._text[s])&&s<this._text.length;)e++,s++;return t+e}findLineBoundaryLeft(t){let e=0,s=t-1;for(;!/\n/.test(this._text[s])&&s>-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s<this._text.length;)e++,s++;return t+e}searchWordBoundary(t,e){const s=this._text;let i=t>0&&this._reSpace.test(s[t])&&(-1===e||!jt.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&i<s.length&&!Xo.test(r);)i+=e,r=s[i];return-1===e&&Xo.test(r)&&i++,i}selectWord(t){var e;t=null!==(e=t)&&void 0!==e?e:this.selectionStart;const s=this.searchWordBoundary(t,-1),i=Math.max(s,this.searchWordBoundary(t,1));this.selectionStart=s,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=null!==(e=t)&&void 0!==e?e:this.selectionStart;const s=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=s,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;He(e).activeElement!==e&&e.focus();const s=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;(s===this.__selectionStartOnMouseDown&&i!==r||i!==s&&r!==s)&&(s>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=s):(this.selectionStart=s,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}
vendor: 7,705 bytes, line 1
1_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,s){const i=s.slice(0,t),r=this.graphemeSplit(i).length;if(t===e)return{selectionStart:r,selectionEnd:r};const n=s.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(n).length}}fromGraphemeToStringSelection(t,e,s){const i=s.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+s.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),s=this.get2DCursorLocation(t),i=s.lineIndex,r=s.charIndex,n=this.getValueOfPropertyAt(i,r,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.getCanvasRetinaScaling(),h=this.canvas.upperCanvasEl,c=h.width/a,l=h.height/a,u=c-n,d=l-n,g=new ie(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ie(h.clientWidth/c,h.clientHeight/l));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>d&&(g.y=d),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(n,"px"),charHeight:n}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(qt),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:n}=this.get2DCursorLocation(e,!0);if(s!==r){if(this.styles[s])for(let t=i;t<this._unwrappedTextLines[s].length;t++)delete this.styles[s][t];if(this.styles[r])for(let t=n;t<this._unwrappedTextLines[r].length;t++){const e=this.styles[r][t];e&&(this.styles[s]||(this.styles[s]={}),this.styles[s][i+t-n]=e)}for(let t=s+1;t<=r;t++)delete this.styles[t];this.shiftLineStyles(r,s-r)}else if(this.styles[s]){const t=this.styles[s],e=n-i;for(let s=i;s<n;s++)delete t[s];for(const i in this.styles[s]){const s=parseInt(i,10);s>=n&&(t[s-e]=t[i],delete t[i])}}}shiftLineStyles(t,e){const s=Object.assign({},this.styles);for(const i in this.styles){const r=parseInt(i,10);r>t&&(this.styles[r+e]=s[r],s[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,s,i){const r={},n=this._unwrappedTextLines[t].length,o=n===e;let a=!1;s||(s=1),this.shiftLineStyles(t,s);const h=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const l in this.styles[t]){const s=parseInt(l,10);s>=e&&(a=!0,r[s-e]=this.styles[t][l],o&&0===e||delete this.styles[t][l])}let c=!1;for(a&&!o&&(this.styles[t+s]=r,c=!0),(c||n>e)&&s--;s>0;)i&&i[s-1]?this.styles[t+s]={0:tt({},i[s-1])}:h?this.styles[t+s]={0:tt({},h)}:delete this.styles[t+s],s--;this._forceClearCache=!0}insertCharStyleObject(t,e,s,i){this.styles||(this.styles={});const r=this.styles[t],n=r?tt({},r):{};s||(s=1);for(const a in n){const t=parseInt(a,10);t>=e&&(r[t+s]=n[t],n[t-s]||delete r[t])}if(this._forceClearCache=!0,i){for(;s--;)Object.keys(i[s]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+s]=tt({},i[s]));return}if(!r)return;const o=r[e?e-1:1];for(;o&&s--;)this.styles[t][e+s]=tt({},o)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let a=0;a<t.length;a++)"\n"===t[a]?(o++,r[o]=0):r[o]++;for(r[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,r[0],s),s=s&&s.slice(r[0]+1)),o&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+r[0],o),n=1;n<o;n++)r[n]>0?this.insertCharStyleObject(i.lineIndex+n,0,r[n],s):s&&this.styles[i.lineIndex+n]&&s[0]&&(this.styles[i.lineIndex+n][0]=s[0]),s=s&&s.slice(r[n]+1);r[n]>0&&this.insertCharStyleObject(i.lineIndex+n,0,r[n],s)}removeChars(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s;i>s&&this.removeStyleFromTo(s,i);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,s,e),this._text=[...this._text.slice(0,s),...r,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,s){s<=t?(e===t?this._selectionDirection=Ot:this._selectionDirection===Mt&&(this._selectionDirection=Ot,this.selectionEnd=t),this.selectionStart=s):s>t&&s<e?this._selectionDirection===Mt?this.selectionEnd=s:this.selectionStart=s:(e===t?this._selectionDirection=Mt:this._selectionDirection===Ot&&(this._selectionDirection=Mt,this.selectionStart=e),this.selectionEnd=s)}}class Vo extends Yo{initHiddenTextarea(){const t=this.canvas&&He(this.canvas.getElement())||gt(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(t=>{let[s,i]=t;return e.setAttribute(s,i)});const{top:s,left:i,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(s,";
1 left: ").concat(i,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(t=>{let[s,i]=t;return e.addEventListener(s,this[i].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:s,selectionStart:i,selectionEnd:r}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const n=()=>{this.updateFromTextArea(),this.fire(Xt),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void n();const o=this._splitTextIntoLines(s).graphemeText,a=this._text.length,h=o.length,c=this.selectionStart,l=this.selectionEnd,u=c!==l;let d,g,f,p,m=h-a;const v=this.fromStringToGraphemeSelection(i,r,s),y=c>v.selectionStart;u?(g=this._text.slice(c,l),m+=l-c):h<a&&(g=y?this._text.slice(l+m,l):this._text.slice(c,c-m));const _=o.slice(v.selectionEnd-m,v.selectionEnd);if(g&&g.length&&(_.length&&(d=this.getSelectionStyles(c,c+1,!1),d=_.map(()=>d[0])),u?(f=c,p=l):y?(f=l-g.length,p=l):(f=l,p=l+g.length),this.removeStyleFromTo(f,p)),_.length){const{copyPasteData:t}=dt();e&&_.join("")===t.copiedText&&!rt.disableStyleCopyPaste&&(d=t.copiedTextStyle),this.insertNewStyleBlock(_,c,d)}n()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:s,selectionEnd:i}=e;this.compositionStart=s,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=dt();t.copiedText=this.getSelectedText(),rt.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let s,i=this._getLineLeftOffset(t);return e>0&&(s=this.__charBounds[t][e-1],i+=s.left+s.width),i}getDownCursorOffset(t,e){const s=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(s),r=i.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-s;const n=i.charIndex,o=this._getWidthBeforeCursor(r,n),a=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(n).length+a+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const s=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(s),r=i.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-s;const n=i.charIndex,o=this._getWidthBeforeCursor(r,n),a=this._getIndexOnLine(r-1,o),h=this._textLines[r].slice(0,n),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-h.length+(1-c)}_getIndexOnLine(t,e){const s=this._textLines[t];let i,r,n=this._getLineLeftOffset(t),o=0;for(let a=0,h=s.length;a<h;a++)if(i=this.__charBounds[t][a].width,n+=i,n>e){r=!0;const t=n-i,s=n,h=Math.abs(t-e);o=Math.abs(s-e)<h?a:a-1;break}return r||(o=s.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const s=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===Mt);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),0!==s){const t=this.text.length;this.selectionStart=di(0,this.selectionStart,t),this.selectionEnd=di(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Ot?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,s){let i;
vendor: 14,496 bytes, line 1
1if(t.altKey)i=this["findWordBoundary".concat(s)](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===s?-1:1,!0;i=this["findLineBoundary".concat(s)](this[e])}return void 0!==i&&this[e]!==i&&(this[e]=i,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Ot,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Mt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=Ot,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const s="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[s](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Ot&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Mt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Mt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ho=t=>!!t.button;class zo extends Vo{constructor(){super(...arguments),$(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new Wo(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e:e,alreadySelected:s}=t;this.canvas&&this.editable&&!Ho(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),s&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=s||this.isEditing)))}mouseUpHandler(t){let{e:e,transform:s}=t;const i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||s&&s.actionPerformed||Ho(e)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),s=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(s,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(ye(this.calcTransformMatrix())).add(new ie(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let h=0;h<this._textLines.length&&s<=e.y;h++)s+=this.getHeightOfLine(h),r=h,h>0&&(i+=this._textLines[h-1].length+this.missingNewlineOffset(h-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let h=0;h<o;h++){const t=n+a[h].kernedWidth;if(e.x<=t){Math.abs(e.x-t)<=Math.abs(e.x-n)&&i++;break}n=t,i++}return Math.min(this.flipX?o-i:i,this._text.length)}}const Go="moveCursorUp",No="moveCursorDown",Uo="moveCursorLeft",qo="moveCursorRight",Ko="exitEditing",Jo=(t,e)=>{const s=e.getRetinaScaling();t.setTransform(s,0,0,s,0,0);const i=e.viewportTransform;t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},Zo=tt({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:Ko,27:Ko,33:Go,34:No,35:qo,36:Uo,37:Uo,38:Go,39:qo,40:No},keysMapRtl:{9:Ko,27:Ko,33:Go,34:No,35:Uo,36:qo,37:qo,38:Go,39:Uo,40:No},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class $o extends zo{static getDefaults(){return tt(tt({},super.getDefaults()),$o.ownDefaults)}get type(){const t=super.type;return"itext"===t?"i-text":t}constructor(t,e){super(t,tt(tt({},$o.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof Zn&&this.canvas.textEditingManager.remove(this),e instanceof Zn&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart||0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionEnd,s=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,s)}setSelectionStyles(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionStart||0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,s)}get2DCursorLocation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const s=super.toCanvasElement(t);return this.isEditing=e,s}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),s=this.findAncestorsWithClipPath(),i=s.length>0;let r,n=t;if(i){r=de(t.canvas),n=r.getContext("2d"),Jo(n,this.canvas);const e=this.calcTransformMatrix();n.transform(e[0],e[1],e[2],e[3],e[4],e[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(n,e):this.renderCursor(n,e),i)for(const o of s){const e=o.clipPath,s=de(t.canvas),i=s.getContext("2d");if(Jo(i,this.canvas),!e.absolutePositioned){const t=o.calcTransformMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5])}e.transform(i),e.drawObject(i,!0,{}),this.drawClipPathOnCache(n,e,s)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const s=this._getLeftOffset(),i=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:s,top:i,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,s=0;const{charIndex:i,lineIndex:r}=this.get2DCursorLocation(t);for(let h=0;h<r;h++)e+=this.getHeightOfLine(h);const n=this._getLineLeftOffset(r),o=this.__charBounds[r][i];o&&(s=o.left),0!==this.charSpacing&&i===this._textLines[r].length&&(s-=this._getWidthOfCharSpacing());const a={top:e,left:n+(s>0?s:0)};return"rtl"===this.direction&&(this.textAlign===Mt||this.textAlign===Bs||this.textAlign===Xs?a.left*=-1:this.textAlign===Ot||this.textAlign===Ws?a.left=n-(s>0?s:0):this.textAlign!==Tt&&this.textAlign!==Ys||(a.left=n-(s>0?s:0))),a}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getCursorBoundaries(t);const s=this.get2DCursorLocation(t),i=s.lineIndex,r=s.charIndex>0?s.charIndex-1:0,n=this.getValueOfPropertyAt(i,r,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/o,h=this.getValueOfPropertyAt(i,r,"deltaY"),c=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:c+e.top+h,width:a,height:n}}_renderCursor(t,e,s){const{color:i,opacity:r,left:n,top:o,width:a,height:h}=this.getCursorRenderingData(s,e);t.fillStyle=i,t.globalAlpha=r,t.fillRect(n,o,a,h)}renderSelection(t,e){const s={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,s,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,s){const i=e.selectionStart,r=e.selectionEnd,n=this.textAlign.includes(Bs),o=this.get2DCursorLocation(i),a=this.get2DCursorLocation(r),h=o.lineIndex,c=a.lineIndex,l=o.charIndex<0?0:o.charIndex,u=a.charIndex<0?0:a.charIndex;for(let d=h;d<=c;d++){const e=this._getLineLeftOffset(d)||0;let i=this.getHeightOfLine(d),r=0,o=0,a=0;if(d===h&&(o=this.__charBounds[h][l].left),d>=h&&d<c)a=n&&!this.isEndOfWrapping(d)?this.width:this.getLineWidth(d)||5;else if(d===c)if(0===u)a=this.__charBounds[c][u].left;else{const t=this._getWidthOfCharSpacing();a=this.__charBounds[c][u-1].left+this.__charBounds[c][u-1].width-t}r=i,(this.lineHeight<1||d===c&&this.lineHeight>1)&&(i/=this.lineHeight);let g=s.left+e+o,f=i,p=0;const m=a-o;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",f=1,p=i):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===Mt||this.textAlign===Bs||this.textAlign===Xs?g=this.width-g-m:this.textAlign===Ot||this.textAlign===Ws?g=s.left+e-a:this.textAlign!==Tt&&this.textAlign!==Ys||(g=s.left+e-a)),t.fillRect(g,s.top+s.topOffset+p,m,f),s.topOffset+=r}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Nt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}$($o,"ownDefaults",Zo),$($o,"type","IText"),Zt.setClass($o),Zt.setClass($o,"i-text");class Qo extends $o{static getDefaults(){return tt(tt({},super.getDefaults()),Qo.ownDefaults)}constructor(t,e){super(t,tt(tt({},Qo.ownDefaults),e))}static createControls(){return{controls:cr()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Bs)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n<t.graphemeLines.length;n++)"\n"===t.graphemeText[i]&&n>0?(s=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&n>0&&(s++,i++),r[n]={line:e,offset:s},i+=t.graphemeLines[n].length,s+=t.graphemeLines[n].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,s=0,i=t+1,r=!1;const n=this._styleMap[t],o=this._styleMap[t+1];n&&(t=n.line,s=n.offset),o&&(i=o.line,r=i===t,e=o.offset);const a=void 0===t?this.styles:{line:this.styles[t]};for(const h in a)for(const t in a[h]){const i=parseInt(t,10);if(i>=s&&(!r||i<e))for(const e in a[h][t])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const s=this._styleMap[t];if(!s)return{};t=s.line,e=s.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,s){const i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,s)}_deleteStyleDeclaration(t,e){const s=this._styleMap[t];super._deleteStyleDeclaration(s.line,s.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const s=this.getGraphemeDataForRender(t),i=[];for(let r=0;r<s.wordsData.length;r++)i.push(...this._wrapLine(r,e,s));return this.isWrapping=!1,i}getGraphemeDataForRender(t){const e=this.splitByGrapheme,s=e?"":" ";let i=0;return{wordsData:t.map((t,r)=>{let n=0;const o=e?this.graphemeSplit(t):this.wordSplit(t);return 0===o.length?[{word:[],width:0}]:o.map(t=>{const o=e?[t]:this.graphemeSplit(t),a=this._measureWord(o,r,n);return i=Math.max(a,i),n+=o.length+s.length,{word:o,width:a}})}),largestWordWidth:i}}_measureWord(t,e){let s,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=0;for(let n=0,o=t.length;n<o;
1n++)r+=this._getGraphemeBox(t[n],e,n+i,s,!0).kernedWidth,s=t[n];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,s){let{largestWordWidth:i,wordsData:r}=s,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=this._getWidthOfCharSpacing(),a=this.splitByGrapheme,h=[],c=a?"":" ";let l=0,u=[],d=0,g=0,f=!0;e-=n;const p=Math.max(e,i,this.dynamicMinWidth),m=r[t];let v;for(d=0,v=0;v<m.length;v++){const{word:e,width:s}=m[v];d+=e.length,l+=g+s-o,l>p&&!f?(h.push(u),u=[],l=s,f=!0):l+=o,f||a||u.push(c),u=u.concat(e),g=a?0:this._measureWord([c],t,d),d++,f=!1}return v&&h.push(u),i+n>this.dynamicMinWidth&&(this.dynamicMinWidth=i-o+n),h}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),s=this._wrapText(e.lines,this.width),i=new Array(s.length);for(let r=0;r<s.length;r++)i[r]=s[r].join("");return e.lines=i,e.graphemeLines=s,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const s=parseInt(e,10);if(this._textLines[s]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}$(Qo,"type","Textbox"),$(Qo,"textLayoutProperties",[...$o.textLayoutProperties,"width"]),$(Qo,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),Zt.setClass(Qo);class ta extends cn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:s}=t,{clipPath:i,group:r}=s;if(!i||!this.shouldPerformLayout(t))return;const{width:n,height:o}=es(hn(s,i)),a=new ie(n,o);if(i.absolutePositioned)return{center:as(i.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:a};{const r=i.getRelativeCenterPoint().transform(s.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:s=new ie,correction:i=new ie}=this.calcBoundingBox(e,t)||{};return{center:s.add(r),correction:i.subtract(r),size:a}}return{center:s.getRelativeCenterPoint().add(r),size:a}}}}$(ta,"type","clip-path"),Zt.setClass(ta);class ea extends cn{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new ie(s.width||i.x,s.height||i.y)}}$(ea,"type","fixed"),Zt.setClass(ea);class sa extends fn{subscribeTargets(t){const e=t.target;t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})})}unsubscribeTargets(t){const e=t.target,s=e.getObjects();t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{!s.some(e=>e.parent===t)&&t.layoutManager.unsubscribeTargets({target:t,targets:[e]})})}}class ia extends vn{static getDefaults(){return tt(tt({},super.getDefaults()),ia.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,ia.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:null!=r?r:new sa})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];"selection-order"===this.multiSelectionStacking?this.add(...e):e.forEach(t=>{const e=this._objects.findIndex(e=>e.isInFrontOf(t)),s=-1===e?this.size():e;this.insertAt(s,t)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(nt("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const s=new Set;e.forEach(t=>{const{parent:e}=t;e&&s.add(e)}
vendor: 5,065 bytes, line 1
1),t===on?s.forEach(t=>{t._onAfterObjectsChange(nn,e)}):s.forEach(t=>{t._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,s){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const i=tt(tt({hasControls:!1},s),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,i);super._renderControls(t,e),t.restore()}}$(ia,"type","ActiveSelection"),$(ia,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),Zt.setClass(ia),Zt.setClass(ia,"activeSelection");class ra{constructor(){$(this,"resources",{})}applyFilters(t,e,s,i,r){const n=r.getContext("2d");if(!n)return;n.drawImage(e,0,0,s,i);const o={sourceWidth:s,sourceHeight:i,imageData:n.getImageData(0,0,s,i),originalEl:e,originalImageData:n.getImageData(0,0,s,i),canvasEl:r,ctx:n,filterBackend:this};t.forEach(t=>{t.applyTo(o)});const{imageData:a}=o;return a.width===s&&a.height===i||(r.width=a.width,r.height=a.height),n.putImageData(a,0,0),o}}class na{constructor(){let{tileSize:t=rt.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};$(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),$(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const s=de({width:t,height:e}),i=s.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=s,this.gl=i)}applyFilters(t,e,s,i,r,n){const o=this.gl,a=r.getContext("2d");if(!o||!a)return;let h;n&&(h=this.getCachedTexture(n,e));const c={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:s,sourceHeight:i,destinationWidth:s,destinationHeight:i,context:o,sourceTexture:this.createTexture(o,s,i,h?void 0:e),targetTexture:this.createTexture(o,s,i),originalTexture:h||this.createTexture(o,s,i,h?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},l=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,l),t.forEach(t=>{t&&t.applyTo(c)}),function(t){const e=t.targetCanvas,s=e.width,i=e.height,r=t.destinationWidth,n=t.destinationHeight;s===r&&i===n||(e.width=r,e.height=n)}(c),this.copyGLTo2D(o,c),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(c.sourceTexture),o.deleteTexture(c.targetTexture),o.deleteFramebuffer(l),a.setTransform(1,0,0,1,0,0),c}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,s,i,r){const{NEAREST:n,TEXTURE_2D:o,RGBA:a,UNSIGNED_BYTE:h,CLAMP_TO_EDGE:c,TEXTURE_MAG_FILTER:l,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:d,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(o,f),t.texParameteri(o,l,r||n),t.texParameteri(o,u,r||n),t.texParameteri(o,d,c),t.texParameteri(o,g,c),i?t.texImage2D(o,0,a,a,h,i):t.texImage2D(o,0,a,e,s,0,a,h,null),f}getCachedTexture(t,e,s){const{textureCache:i}=this;if(i[t])return i[t];{const r=this.createTexture(this.gl,e.width,e.height,e,s);return r&&(i[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const s=t.canvas,i=e.targetCanvas,r=i.getContext("2d");if(!r)return;r.translate(0,i.height),r.scale(1,-1);const n=s.height-i.height;r.drawImage(s,0,n,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){const s=e.targetCanvas.getContext("2d"),i=e.destinationWidth,r=e.destinationHeight,n=i*r*4;if(!s)return;const o=new Uint8Array(this.imageBuffer,0,n),a=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,i,r,t.RGBA,t.UNSIGNED_BYTE,o);const h=new ImageData(a,i,r);s.putImageData(h,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const s=t.getExtension("WEBGL_debug_renderer_info");if(s){const i=t.getParameter(s.UNMASKED_RENDERER_WEBGL),r=t.getParameter(s.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let oa;function aa(){return!oa&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(oa=function(){const{WebGLProbe:t}=dt();return t.queryWebGL(ue()),rt.enableGLFiltering&&t.isSupported(rt.textureSize)?new na({tileSize:rt.textureSize}):new ra}()),oa}const ha=["filters","resizeFilter","src","crossOrigin","type"],ca=["cropX","cropY"];class la extends dr{static getDefaults(){return tt(tt({},super.getDefaults()),la.ownDefaults)}constructor(t,e){super(),$(this,"_lastScaleX",1),$(this,"_lastScaleY",1),$(this,"_filterScalingX",1),$(this,"_filterScalingY",1),this.filters=[],Object.assign(this,la.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(le()),this.setElement("string"==typeof t?(this.canvas&&He(this.canvas.getElement())||gt()).getElementById(t):t,e)}getElement(){return this._element}
1setElement(t){var e;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(s),null===(e=t.classList)||void 0===e||e.add(la.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=aa(!1);e instanceof na&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&dt().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||0===this.strokeWidth)return;const e=this.width/2,s=this.height/2;t.beginPath(),t.moveTo(-e,-s),t.lineTo(e,-s),t.lineTo(e,s),t.lineTo(-e,s),t.lineTo(-e,-s),t.closePath()}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=[];return this.filters.forEach(t=>{t&&e.push(t.toObject())}),tt(tt({},super.toObject([...ca,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,s=-this.width/2,i=-this.height/2;let r=[],n=[],o="",a="";if(!e)return[];if(this.hasCrop()){const t=le();r.push('<clipPath id="imageCrop_'+t+'">\n','\t<rect x="'+s+'" y="'+i+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t<image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(s-this.cropX,'" y="').concat(i-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(a).concat(o,"></image>\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t<rect x="'.concat(s,'" y="').concat(i,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),'" />\n')],this.fill=t}return r=this.paintFirst!==Nt?r.concat(n,t):r.concat(t,n),r}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return je(t,{crossOrigin:e,signal:s}).then(t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,s=this.getTotalObjectScaling(),i=s.x,r=s.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||i>e&&r>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,void(this._lastScaleY=r);const o=de(n),{width:a,height:h}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,aa().applyFilters([t],n,a,h,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.filters||[];if(t=t.filter(t=>t&&!t.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,s=e.naturalWidth||e.width,i=e.naturalHeight||e.height;if(this._element===this._originalElement){const t=de({width:s,height:i});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,s,i),this._lastScaleX=1,this._lastScaleY=1);aa().applyFilters(t,this._originalElement,s,i,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const s=this._filterScalingX,i=this._filterScalingY,r=this.width,n=this.height,o=Math.max(this.cropX,0),a=Math.max(this.cropY,0),h=e.naturalWi
1dth||e.width,c=e.naturalHeight||e.height,l=o*s,u=a*i,d=Math.min(r*s,h-l),g=Math.min(n*i,c-u),f=-r/2,p=-n/2,m=Math.min(r,h/s-o),v=Math.min(n,c/i-a);e&&t.drawImage(e,l,u,d,g,f,p,m,v)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s=this.getOriginalSize();this.width=t||s.width,this.height=e||s.height}parsePreserveAspectRatioAttribute(){const t=(t=>{const[e,s]=t.trim().split(" "),[i,r]=(n=e)&&n!==Et?[n.slice(1,4),n.slice(5,8)]:n===Et?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:s||"meet",alignX:i,alignY:r}})(this.preserveAspectRatio||""),e=this.width,s=this.height,i={width:e,height:s};let r,n=this._element.width,o=this._element.height,a=1,h=1,c=0,l=0,u=0,d=0;return!t||t.alignX===Et&&t.alignY===Et?(a=e/n,h=s/o):("meet"===t.meetOrSlice&&(a=h=((t,e)=>Math.min(e.width/t.width,e.height/t.height))(this._element,i),r=(e-n*a)/2,"Min"===t.alignX&&(c=-r),"Max"===t.alignX&&(c=r),r=(s-o*h)/2,"Min"===t.alignY&&(l=-r),"Max"===t.alignY&&(l=r)),"slice"===t.meetOrSlice&&(a=h=((t,e)=>Math.max(e.width/t.width,e.height/t.height))(this._element,i),r=n-e/a,"Mid"===t.alignX&&(u=r/2),"Max"===t.alignX&&(u=r),r=o-s/h,"Mid"===t.alignY&&(d=r/2),"Max"===t.alignY&&(d=r),n=e/a,o=s/h)),{width:n,height:o,scaleX:a,scaleY:h,offsetLeft:c,offsetTop:l,cropX:u,cropY:d}}static fromObject(t,e){let{filters:s,resizeFilter:i,src:r,crossOrigin:n,type:o}=t,a=et(t,ha);return Promise.all([je(r,tt(tt({},e),{},{crossOrigin:n})),s&&Pe(s,e),i&&Pe([i],e),Ae(a,e)]).then(t=>{let[e,s=[],[i]=[],n={}]=t;return new this(e,tt(tt({},a),{},{src:r,filters:s,resizeFilter:i},n))})}static fromURL(t){let{crossOrigin:e=null,signal:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return je(t,{crossOrigin:e,signal:s}).then(t=>new this(t,i))}static async fromElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;const i=Qr(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"]||i.href,e,i).catch(t=>(nt("log","Unable to parse Image",t),null))}}$(la,"type","Image"),$(la,"cacheProperties",[...fi,...ca]),$(la,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),$(la,"CSS_CANVAS","canvas-img"),$(la,"ATTRIBUTE_NAMES",[...Tr,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),Zt.setClass(la),Zt.setSVGClass(la),Es(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const ua=Bt,da=t=>function(e,s,i){const{points:r,pathOffset:n}=i;return new ie(r[t]).subtract(n).transform(_e(i.getViewportTransform(),i.calcTransformMatrix()))},ga=(t,e,s,i)=>{const{target:r,pointIndex:n}=e,o=r,a=as(new ie(s,i),void 0,o.calcOwnMatrix());return o.points[n]=a.add(o.pathOffset),o.setDimensions(),o.set("dirty",!0),!0},fa=(t,e)=>function(s,i,r,n){const o=i.target,a=new ie(o.points[(t>0?t:o.points.length)-1]),h=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()),c=e(s,tt(tt({},i),{},{pointIndex:t}),r,n),l=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(h);return o.left-=l.x,o.top-=l.y,c},pa=t=>Ai(ua,fa(t,ga)),ma=(t,e,s)=>{const{path:i,pathOffset:r}=t,n=i[e];return new ie(n[s]-r.x,n[s+1]-r.y).transform(_e(t.getViewportTransform(),t.calcTransformMatrix()))};function va(t,e,s){const{commandIndex:i,pointIndex:r}=this;return ma(s,i,r)}function ya(t,e,s,i){const{target:r}=e,{commandIndex:n,pointIndex:o}=this,a=((t,e,s,i,r)=>{const{path:n,pathOffset:o}=t,a=n[(i>0?i:n.length)-1],h=new ie(a[r],a[r+1]),c=h.subtract(o).transform(t.calcOwnMatrix()),l=as(new ie(e,s),void 0,t.calcOwnMatrix());n[i][r]=l.x+o.x,n[i][r+1]=l.y+o.y,t.setDimensions();const u=h.subtract(t.pathOffset).transform(t.calcOwnMatrix()).subtract(c);return t.left-=u.x,t.top-=u.y,t.set("dirty",!0),!0})(r,s,i,n,o);return hs(this.actionName,tt(tt({},ps(t,e,s,i)),{},{commandIndex:n,pointIndex:o})),a}class _a extends Bi{constructor(t){super(t)}render(t,e,s,i,r){const n=tt(tt({},i),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,s,n,r)}}class xa extends _a{constructor(t){super(t)}render(t,e,s,i,r){const{path:n}=r,{commandIndex:o,pointIndex:a,connectToCommandIndex:h,connectToPointIndex:c}=this;t.save(),t.strokeStyle=this.controlStroke,this.connectionDashArray&&t.setLineDash(this.connectionDashArray);const[l]=n[o],u=ma(r,h,c);if("Q"===l){const i=ma(r,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,s)}else t.moveTo(e,s);
1t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,s,i,r)}}const Ca=(t,e,s,i,r,n)=>new(s?xa:_a)(tt(tt({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:va,actionHandler:ya,connectToCommandIndex:r,connectToPointIndex:n},i),s?i.controlPointStyle:i.pointStyle));var ba=Object.freeze({__proto__:null,changeWidth:Li,createObjectDefaultControls:ar,createPathControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};let i="M";return t.path.forEach((t,r)=>{const n=t[0];switch("Z"!==n&&(s["c_".concat(r,"_").concat(n)]=Ca(r,t.length-2,!1,e)),n){case"C":s["c_".concat(r,"_C_CP_1")]=Ca(r,1,!0,e,r-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),s["c_".concat(r,"_C_CP_2")]=Ca(r,3,!0,e,r,5);break;case"Q":s["c_".concat(r,"_Q_CP_1")]=Ca(r,1,!0,e,r,3)}i=n}),s},createPolyActionHandler:pa,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};for(let i=0;i<("number"==typeof t?t:t.points.length);i++)s["p".concat(i)]=new Bi(tt({actionName:ua,positionHandler:da(i),actionHandler:pa(i)},e));return s},createPolyPositionHandler:da,createResizeControls:hr,createTextboxDefaultControls:cr,dragHandler:ys,factoryPolyActionHandler:fa,getLocalPoint:vs,polyActionHandler:ga,renderCircleControl:Ii,renderSquareControl:Ri,rotationStyleHandler:Wi,rotationWithSnapping:Xi,scaleCursorStyleHandler:zi,scaleOrSkewActionName:ir,scaleSkewCursorStyleHandler:rr,scalingEqually:Ni,scalingX:Ui,scalingXOrSkewingY:nr,scalingY:qi,scalingYOrSkewingX:or,skewCursorStyleHandler:$i,skewHandlerX:tr,skewHandlerY:er,wrapWithFireEvent:Ai,wrapWithFixedAnchor:Fi});const wa=t=>void 0!==t.webgl,Sa="precision highp float",Ta="\n    ".concat(Sa,";\n    varying vec2 vTexCoord;\n    uniform sampler2D uTexture;\n    void main() {\n      gl_FragColor = texture2D(uTexture, vTexCoord);\n    }"),Oa=["type"],ka=["type"],Da=new RegExp(Sa,"g");class Ma{get type(){return this.constructor.type}constructor(){let t=et(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Oa);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Ta}getVertexSource(){return"\n    attribute vec2 aPosition;\n    varying vec2 vTexCoord;\n    void main() {\n      vTexCoord = aPosition;\n      gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n    }"}createProgram(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getFragmentSource(),s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:i="highp"}}=dt();"highp"!==i&&(e=e.replace(Da,Sa.replace("highp",i)));const r=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),o=t.createProgram();if(!r||!n||!o)throw new ot("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ot("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new ot("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.attachShader(o,r),t.attachShader(o,n),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new ot('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(o)));const a=this.getUniformLocations(t,o)||{};return a.uStepW=t.getUniformLocation(o,"uStepW"),a.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:this.getAttributeLocations(t,o),uniformLocations:a}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const s=this.constructor.uniformLocations,i={};for(let r=0;r<s.length;r++)i[s[r]]=t.getUniformLocation(e,s[r]);return i}sendAttributeData(t,e,s){const i=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const s=t.destinationWidth,i=t.destinationHeight;
vendor: 5,743 bytes, line 1
1t.sourceWidth===s&&t.sourceHeight===i||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,s,i)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){wa(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,s=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(s.program),this.sendAttributeData(e,s.attributeLocations,t.aPosition),e.uniform1f(s.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(s.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,s.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,s){t.activeTexture(s),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:s}=t,i=de({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return tt({type:this.type},t.reduce((t,e)=>(t[e]=this[e],t),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(et(t,ka))}}$(Ma,"type","BaseFilter"),$(Ma,"uniformLocations",[]);const Ea={multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",difference:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"\n    if (uColor.r < 0.5) {\n      gl_FragColor.r *= 2.0 * uColor.r;\n    } else {\n      gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n    }\n    if (uColor.g < 0.5) {\n      gl_FragColor.g *= 2.0 * uColor.g;\n    } else {\n      gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n    }\n    if (uColor.b < 0.5) {\n      gl_FragColor.b *= 2.0 * uColor.b;\n    } else {\n      gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n    }\n    ",tint:"\n    gl_FragColor.rgb *= (1.0 - uColor.a);\n    gl_FragColor.rgb += uColor.rgb;\n    "};class ja extends Ma{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return"\n      precision highp float;\n      uniform sampler2D uTexture;\n      uniform vec4 uColor;\n      varying vec2 vTexCoord;\n      void main() {\n        vec4 color = texture2D(uTexture, vTexCoord);\n        gl_FragColor = color;\n        if (color.a > 0.0) {\n          ".concat(Ea[this.mode],"\n        }\n      }\n      ")}applyTo2d(t){let{imageData:{data:e}}=t;const s=new Os(this.color).getSource(),i=this.alpha,r=s[0]*i,n=s[1]*i,o=s[2]*i,a=1-i;for(let h=0;h<e.length;h+=4){const t=e[h],s=e[h+1],i=e[h+2];let c,l,u;switch(this.mode){case"multiply":c=t*r/255,l=s*n/255,u=i*o/255;break;case"screen":c=255-(255-t)*(255-r)/255,l=255-(255-s)*(255-n)/255,u=255-(255-i)*(255-o)/255;break;case"add":c=t+r,l=s+n,u=i+o;break;case"difference":c=Math.abs(t-r),l=Math.abs(s-n),u=Math.abs(i-o);break;case"subtract":c=t-r,l=s-n,u=i-o;break;case"darken":c=Math.min(t,r),l=Math.min(s,n),u=Math.min(i,o);break;case"lighten":c=Math.max(t,r),l=Math.max(s,n),u=Math.max(i,o);break;case"overlay":c=r<128?2*t*r/255:255-2*(255-t)*(255-r)/255,l=n<128?2*s*n/255:255-2*(255-s)*(255-n)/255,u=o<128?2*i*o/255:255-2*(255-i)*(255-o)/255;break;case"exclusion":c=r+t-2*r*t/255,l=n+s-2*n*s/255,u=o+i-2*o*i/255;break;case"tint":c=r+t*a,l=n+s*a,u=o+i*a}e[h]=c,e[h+1]=l,e[h+2]=u}}sendUniformData(t,e){const s=new Os(this.color).getSource();s[0]=this.alpha*s[0]/255,s[1]=this.alpha*s[1]/255,s[2]=this.alpha*s[2]/255,s[3]=this.alpha,t.uniform4fv(e.uColor,s)}}$(ja,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),$(ja,"type","BlendColor"),$(ja,"uniformLocations",["uColor"]),Zt.setClass(ja);const Pa={multiply:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform sampler2D uImage;\n    uniform vec4 uColor;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      vec4 color2 = texture2D(uImage, vTexCoord2);\n      color.rgba *= color2.rgba;\n      gl_FragColor = color;\n    }\n    ",mask:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform sampler2D uImage;\n    uniform vec4 uColor;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      vec4 color2 = texture2D(uImage, vTexCoord2);\n      color.a = color2.a;\n      gl_FragColor = color;\n    }\n    "},Aa=["type","image"];class Fa extends Ma{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Pa[this.mode]}getVertexSource(){return"\n    attribute vec2 aPosition;\n    varying vec2 vTexCoord;\n    varying vec2 vTexCoord2;\n    uniform mat3 uTransformMatrix;\n    void main() {\n      vTexCoord = aPosition;
1\n      vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n      gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n    }\n    "}applyToWebGL(t){const e=t.context,s=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,s,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:s}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/s,1]}applyTo2d(t){let{imageData:{data:e,width:s,height:i},filterBackend:{resources:r}}=t;const n=this.image;r.blendImage||(r.blendImage=ue());const o=r.blendImage,a=o.getContext("2d");o.width!==s||o.height!==i?(o.width=s,o.height=i):a.clearRect(0,0,s,i),a.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),a.drawImage(n.getElement(),0,0,s,i);const h=a.getImageData(0,0,s,i).data;for(let c=0;c<e.length;c+=4){const t=e[c],s=e[c+1],i=e[c+2],r=e[c+3],n=h[c],o=h[c+1],a=h[c+2],l=h[c+3];switch(this.mode){case"multiply":e[c]=t*n/255,e[c+1]=s*o/255,e[c+2]=i*a/255,e[c+3]=r*l/255;break;case"mask":e[c+3]=l}}}sendUniformData(t,e){const s=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,s)}toObject(){return tt(tt({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:s,image:i}=t,r=et(t,Aa);return la.fromObject(i,e).then(t=>new this(tt(tt({},r),{},{image:t})))}}$(Fa,"type","BlendImage"),$(Fa,"defaults",{mode:"multiply",alpha:1}),$(Fa,"uniformLocations",["uTransformMatrix","uImage"]),Zt.setClass(Fa);class La extends Ma{getFragmentSource(){return"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform vec2 uDelta;\n    varying vec2 vTexCoord;\n    const float nSamples = 15.0;\n    vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n    float random(vec3 scale) {\n      /* use the fragment position for a different seed per-pixel */\n      return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n    }\n    void main() {\n      vec4 color = vec4(0.0);\n      float totalC = 0.0;\n      float totalA = 0.0;\n      float offset = random(v3offset);\n      for (float t = -nSamples; t <= nSamples; t++) {\n        float percent = (t + offset - 0.5) / nSamples;\n        vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);\n        float weight = 1.0 - abs(percent);\n        float alpha = weight * sample.a;\n        color.rgb += sample.rgb * alpha;\n        color.a += alpha;\n        totalA += weight;\n        totalC += alpha;\n      }\n      gl_FragColor.rgb = color.rgb / totalC;\n      gl_FragColor.a = color.a / totalA;\n    }\n  "}
vendor: 4,459 bytes, line 1
1applyTo(t){wa(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:s,height:i}}=t;this.aspectRatio=s/i,this.horizontal=!0;let r=this.getBlurValue()*s;const n=new Uint8ClampedArray(e),o=4*s;for(let a=0;a<e.length;a+=4){let t=0,s=0,i=0,h=0,c=0;const l=a-a%o,u=l+o;for(let n=-14;n<15;n++){const o=n/15,d=4*Math.floor(r*o),g=1-Math.abs(o);let f=a+d;f<l?f=l:f>u&&(f=u);const p=e[f+3]*g;t+=e[f]*p,s+=e[f+1]*p,i+=e[f+2]*p,h+=p,c+=g}n[a]=t/h,n[a+1]=s/h,n[a+2]=i/h,n[a+3]=h/c}this.horizontal=!1,r=this.getBlurValue()*i;for(let a=0;a<n.length;a+=4){let t=0,s=0,i=0,h=0,c=0;const l=a%o,u=n.length-o+l;for(let e=-14;e<15;e++){const d=e/15,g=Math.floor(r*d)*o,f=1-Math.abs(d);let p=a+g;p<l?p=l:p>u&&(p=u);const m=n[p+3]*f;t+=n[p]*m,s+=n[p+1]*m,i+=n[p+2]*m,h+=m,c+=f}e[a]=t/h,e[a+1]=s/h,e[a+2]=i/h,e[a+3]=h/c}}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return 0===this.blur}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:s}=this;return e?s>1&&(t=1/s):s<1&&(t=s),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}$(La,"type","Blur"),$(La,"defaults",{blur:0}),$(La,"uniformLocations",["uDelta"]),Zt.setClass(La);class Ia extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uBrightness;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color.rgb += uBrightness;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const s=Math.round(255*this.brightness);for(let i=0;i<e.length;i+=4)e[i]+=s,e[i+1]+=s,e[i+2]+=s}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}$(Ia,"type","Brightness"),$(Ia,"defaults",{brightness:0}),$(Ia,"uniformLocations",["uBrightness"]),Zt.setClass(Ia);const Ra={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ba extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  varying vec2 vTexCoord;\n  uniform mat4 uColorMatrix;\n  uniform vec4 uConstants;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color *= uColorMatrix;\n    color += uConstants;\n    gl_FragColor = color;\n  }"}applyTo2d(t){const e=t.imageData.data,s=this.matrix,i=this.colorsOnly;for(let r=0;r<e.length;r+=4){const t=e[r],n=e[r+1],o=e[r+2];if(e[r]=t*s[0]+n*s[1]+o*s[2]+255*s[4],e[r+1]=t*s[5]+n*s[6]+o*s[7]+255*s[9],e[r+2]=t*s[10]+n*s[11]+o*s[12]+255*s[14],!i){const i=e[r+3];e[r]+=i*s[3],e[r+1]+=i*s[8],e[r+2]+=i*s[13],e[r+3]=t*s[15]+n*s[16]+o*s[17]+i*s[18]+255*s[19]}}}sendUniformData(t,e){const s=this.matrix,i=[s[0],s[1],s[2],s[3],s[5],s[6],s[7],s[8],s[10],s[11],s[12],s[13],s[15],s[16],s[17],s[18]],r=[s[4],s[9],s[14],s[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,i),t.uniform4fv(e.uConstants,r)}toObject(){return tt(tt({},super.toObject()),{},{matrix:[...this.matrix]})}}function Wa(t,e){var s;const i=($(s=class extends Ba{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),$(s,"defaults",{colorsOnly:!1,matrix:e}),s);return Zt.setClass(i,t),i}$(Ba,"type","ColorMatrix"),$(Ba,"defaults",Ra),$(Ba,"uniformLocations",["uColorMatrix","uConstants"]),Zt.setClass(Ba),Wa("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),Wa("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),Wa("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),Wa("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),Wa("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),Wa("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),Wa("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Xa extends Ma{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){wa(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEac
1h(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(t=>Zt.getClass(t.type).fromObject(t,e))).then(t=>new this({subFilters:t}))}}$(Xa,"type","Composed"),Zt.setClass(Xa);class Ya extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uContrast;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n    color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n    gl_FragColor = color;\n  }"}isNeutralState(){return 0===this.contrast}applyTo2d(t){let{imageData:{data:e}}=t;const s=Math.floor(255*this.contrast),i=259*(s+255)/(255*(259-s));for(let r=0;r<e.length;r+=4)e[r]=i*(e[r]-128)+128,e[r+1]=i*(e[r+1]-128)+128,e[r+2]=i*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}$(Ya,"type","Contrast"),$(Ya,"defaults",{contrast:0}),$(Ya,"uniformLocations",["uContrast"]),Zt.setClass(Ya);const Va={Convolute_3_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[9];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 3.0; h+=1.0) {\n        for (float w = 0.0; w < 3.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_3_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[9];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 3.0; h+=1.0) {\n        for (float w = 0.0; w < 3.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_5_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[25];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 5.0; h+=1.0) {\n        for (float w = 0.0; w < 5.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_5_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[25];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 5.0; h+=1.0) {\n        for (float w = 0.0; w < 5.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_7_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[49];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 7.0; h+=1.0) {\n        for (float w = 0.0; w < 7.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_7_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[49];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 7.0; h+=1.0) {\n        for (float w = 0.0; w < 7.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    ",Convolute_9_1:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[81];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 0);\n      for (float h = 0.0; h < 9.0; h+=1.0) {\n        for (float w = 0.0; w < 9.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n          color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n        }\n      }\n      gl_FragColor = color;\n    }\n    ",Convolute_9_0:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform float uMatrix[81];\n    uniform float uStepW;\n    uniform float uStepH;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = vec4(0, 0, 0, 1);\n      for (float h = 0.0; h < 9.0; h+=1.0) {\n        for (float w = 0.0; w < 9.0; w+=1.0) {\n          vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n          color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n        }\n      }\n      float alpha = texture2D(uTexture, vTexCoord).a;\n      gl_FragColor = color;\n      gl_FragColor.a = alpha;\n    }\n    "};
vendor: 15,114 bytes, line 1
1class Ha extends Ma{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Va[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,s=e.data,i=this.matrix,r=Math.round(Math.sqrt(i.length)),n=Math.floor(r/2),o=e.width,a=e.height,h=t.ctx.createImageData(o,a),c=h.data,l=this.opaque?1:0;let u,d,g,f,p,m,v,y,_,x,C,b,w;for(C=0;C<a;C++)for(x=0;x<o;x++){for(p=4*(C*o+x),u=0,d=0,g=0,f=0,w=0;w<r;w++)for(b=0;b<r;b++)v=C+w-n,m=x+b-n,v<0||v>=a||m<0||m>=o||(y=4*(v*o+m),_=i[w*r+b],u+=s[y]*_,d+=s[y+1]*_,g+=s[y+2]*_,l||(f+=s[y+3]*_));c[p]=u,c[p+1]=d,c[p+2]=g,c[p+3]=l?s[p+3]:f}t.imageData=h}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return tt(tt({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}$(Ha,"type","Convolute"),$(Ha,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),$(Ha,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),Zt.setClass(Ha);const za="Gamma";class Ga extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform vec3 uGamma;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    vec3 correction = (1.0 / uGamma);\n    color.r = pow(color.r, correction.r);\n    color.g = pow(color.g, correction.g);\n    color.b = pow(color.b, correction.b);\n    gl_FragColor = color;\n    gl_FragColor.rgb *= color.a;\n  }\n"}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const s=this.gamma,i=1/s[0],r=1/s[1],n=1/s[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const o=this.rgbValues;for(let a=0;a<256;a++)o.r[a]=255*Math.pow(a/255,i),o.g[a]=255*Math.pow(a/255,r),o.b[a]=255*Math.pow(a/255,n);for(let a=0;a<e.length;a+=4)e[a]=o.r[e[a]],e[a+1]=o.g[e[a+1]],e[a+2]=o.b[e[a+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:za,gamma:this.gamma.concat()}}}$(Ga,"type",za),$(Ga,"defaults",{gamma:[1,1,1]}),$(Ga,"uniformLocations",["uGamma"]),Zt.setClass(Ga);const Na={average:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 color = texture2D(uTexture, vTexCoord);\n      float average = (color.r + color.b + color.g) / 3.0;\n      gl_FragColor = vec4(average, average, average, color.a);\n    }\n    ",lightness:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform int uMode;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 col = texture2D(uTexture, vTexCoord);\n      float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n      gl_FragColor = vec4(average, average, average, col.a);\n    }\n    ",luminosity:"\n    precision highp float;\n    uniform sampler2D uTexture;\n    uniform int uMode;\n    varying vec2 vTexCoord;\n    void main() {\n      vec4 col = texture2D(uTexture, vTexCoord);\n      float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n      gl_FragColor = vec4(average, average, average, col.a);\n    }\n    "};class Ua extends Ma{applyTo2d(t){let{imageData:{data:e}}=t;for(let s,i=0;i<e.length;i+=4){const t=e[i],r=e[i+1],n=e[i+2];switch(this.mode){case"average":s=(t+r+n)/3;break;case"lightness":s=(Math.min(t,r,n)+Math.max(t,r,n))/2;break;case"luminosity":s=.21*t+.72*r+.07*n}e[i+2]=e[i+1]=e[i]=s}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Na[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}$(Ua,"type","Grayscale"),$(Ua,"defaults",{mode:"average"}),$(Ua,"uniformLocations",["uMode"]),Zt.setClass(Ua);const qa=tt(tt({},Ra),{},{rotation:0});class Ka extends Ba{calculateMatrix(){const t=this.rotation*Math.PI,e=ee(t),s=se(t),i=1/3,r=Math.sqrt(i)*s,n=1-e;this.matrix=[e+n/3,i*n-r,i*n+r,0,0,i*n+r,e+i*n,i*n-r,0,0,i*n-r,i*n+r,e+i*n,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}$(Ka,"type","HueRotation"),$(Ka,"defaults",qa),Zt.setClass(Ka);class Ja extends Ma{applyTo2d(t){let{imageData:{data:e}}=t;for(let s=0;s<e.length;s+=4)e[s]=255-e[s],e[s+1]=255-e[s+1],e[s+2]=255-e[s+2],this.alpha&&(e[s+3]=255-e[s+3])}getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform int uInvert;\n  uniform int uAlpha;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    if (uInvert == 1) {\n      if (uAlpha == 1) {\n        gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);\n      } else {\n        gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n      }\n    } else {\n      gl_FragColor = color;\n    }\n  }\n"}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}$(Ja,"type","Invert"),$(Ja,"defaults",{alpha:!1,invert:!0}),$(Ja,"uniformLocations",["uInvert","uAlpha"]),Zt.setClass(Ja);class Za extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uStepH;\n  uniform float uNoise;\n  uniform float uSeed;\n  varying vec2 vTexCoord;\n  float rand(vec2 co, float seed, float vScale) {\n    return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n  }\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const s=this.noise;for(let i=0;i<e.length;i+=4){const t=(.5-Math.random())*s;e[i]+=t,e[i+1]+=t,e[i+2]+=t}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}}$(Za,"type","Noise"),$(Za,"defaults",{noise:0}),$(Za,"uniformLocations",["uNoise","uSeed"]),Zt.setClass(Za);class $a extends Ma{applyTo2d(t){let{imageData:{data:e,width:s,height:i}}=t;for(let r=0;r<i;r+=this.blocksize)for(let t=0;t<s;t+=this.blocksize){const n=4*r*s+4*t,o=e[n],a=e[n+1],h=e[n+2],c=e[n+3];for(let l=r;l<Math.min(r+this.blocksize,i);l++)for(let i=t;i<Math.min(t+this.blocksize,s);i++){const t=4*l*s+4*i;e[t]=o,e[t+1]=a,e[t+2]=h,e[t+3]=c}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uBlocksize;\n  uniform float uStepW;\n  uniform float uStepH;\n  varying vec2 vTexCoord;\n  void main() {\n    float blockW = uBlocksize * uStepW;\n    float blockH = uBlocksize * uStepH;\n    int posX = int(vTexCoord.x / blockW);\n    int posY = int(vTexCoord.y / blockH);\n    float fposX = float(posX);\n    float fposY = float(posY);\n    vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n    vec4 color = texture2D(uTexture, squareCoords);\n    gl_FragColor = color;\n  }\n"}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}$($a,"type","Pixelate"),$($a,"defaults",{blocksize:4}),$($a,"uniformLocations",["uBlocksize"]),Zt.setClass($a);class Qa extends Ma{getFragmentSource(){return"\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n  gl_FragColor = texture2D(uTexture, vTexCoord);\n  if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n    gl_FragColor.a = 0.0;\n  }\n}\n"}applyTo2d(t){let{imageData:{data:e}}=t;const s=255*this.distance,i=new Os(this.color).getSource(),r=[i[0]-s,i[1]-s,i[2]-s],n=[i[0]+s,i[1]+s,i[2]+s];for(let o=0;o<e.length;o+=4){const t=e[o],s=e[o+1],i=e[o+2];t>r[0]&&s>r[1]&&i>r[2]&&t<n[0]&&s<n[1]&&i<n[2]&&(e[o+3]=0)}}sendUniformData(t,e){const s=new Os(this.color).getSource(),i=this.distance,r=[0+s[0]/255-i,0+s[1]/255-i,0+s[2]/255-i,1],n=[s[0]/255+i,s[1]/255+i,s[2]/255+i,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,n)}}$(Qa,"type","RemoveColor"),$(Qa,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),$(Qa,"uniformLocations",["uLow","uHigh"]),Zt.setClass(Qa);class th extends Ma{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,s=this.getFilterWindow(),i=new Array(s);for(let r=1;r<=s;r++)i[r-1]=t(r*e);return i}generateShader(t){const e=new Array(t);for(let s=1;s<=t;s++)e[s-1]="".concat(s,".0 * uDelta");return"\n      precision highp float;\n      uniform sampler2D uTexture;\n      uniform vec2 uDelta;\n      varying vec2 vTexCoord;\n      uniform float uTaps[".concat(t,"];\n      void main() {\n        vec4 color = texture2D(uTexture, vTexCoord);\n        float sum = 1.0;\n        ").concat(e.map((t,e)=>"\n              color += texture2D(uTexture, vTexCoord + ".concat(t,") * uTaps[").concat(e,"] + texture2D(uTexture, vTexCoord - ").concat(t,") * uTaps[").concat(e,"];\n              sum += 2.0 * uTaps[").concat(e,"];\n            ")).join("\n"),"\n        gl_FragColor = color / sum;\n      }\n    ")}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){wa(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;const s=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(s)/s}}applyTo2d(t){const e=t.imageData,s=this.scaleX,i=this.scaleY;this.rcpScaleX=1/s,this.rcpScaleY=1/i;const r=e.width,n=e.height,o=Math.round(r*s),a=Math.round(n*i);let h;h="sliceHack"===this.resizeType?this.sliceByTwo(t,r,n,o,a):"hermite"===this.resizeType?this.hermiteFastResize(t,r,n,o,a):"bilinear"===this.resizeType?this.bilinearFiltering(t,r,n,o,a):"lanczos"===this.resizeType?this.lanczosResize(t,r,n,o,a):new ImageData(o,a),t.imageData=h}sliceByTwo(t,e,s,i,r){const n=t.imageData,o=.5;let a=!1,h=!1,c=e*o,l=s*o;const u=t.filterBackend.resources;let d=0,g=0;const f=e;let p=0;u.sliceByTwo||(u.sliceByTwo=ue());const m=u.sliceByTwo;(m.width<1.5*e||m.height<s)&&(m.width=1.5*e,m.height=s);const v=m.getContext("2d");for(v.clearRect(0,0,1.5*e,s),v.putImageData(n,0,0),i=Math.floor(i),r=Math.floor(r);!a||!h;)e=c,s=l,i<Math.floor(c*o)?c=Math.floor(c*o):(c=i,a=!0),r<Math.floor(l*o)?l=Math.floor(l*o):(l=r,h=!0),v.drawImage(m,d,g,e,s,f,p,c,l),d=f,g=p,p+=l;return v.getImageData(d,g,i,r)}lanczosResize(t,e,s,i,r){const n=t.imageData.data,o=t.ctx.createImageData(i,r),a=o.data,h=this.lanczosCreate(this.lanczosLobes),c=this.rcpScaleX,l=this.rcpScaleY,u=2/this.rcpScaleX,d=2/this.rcpScaleY,g=Math.ceil(c*this.lanczosLobes/2),f=Math.ceil(l*this.lanczosLobes/2),p={},m={x:0,y:0},v={x:0,y:0};return function t(y){let _,x,C,b,w,S,T,O,k,D,M;for(m.x=(y+.5)*c,v.x=Math.floor(m.x),_=0;_<r;_++){for(m.y=(_+.5)*l,v.y=Math.floor(m.y),w=0,S=0,T=0,O=0,k=0,x=v.x-g;x<=v.x+g;x++)if(!(x<0||x>=e)){D=Math.floor(1e3*Math.abs(x-m.x)),p[D]||(p[D]={});for(let t=v.y-f;t<=v.y+f;t++)t<0||t>=s||(M=Math.floor(1e3*Math.abs(t-m.y)),p[D][M]||(p[D][M]=h(Math.sqrt(Math.pow(D*u,2)+Math.pow(M*d,2))/1e3)),C=p[D][M],C>0&&(b=4*(t*e+x),w+=C,S+=C*n[b],T+=C*n[b+1],O+=C*n[b+2],k+=C*n[b+3]))}b=4*(_*i+y),a[b]=S/w,a[b+1]=T/w,a[b+2]=O/w,a[b+3]=k/w}return++y<i?t(y):o}(0)}bilinearFiltering(t,e,s,i,r){let n,o,a,h,c,l,u,d,g,f,p,m,v,y=0;const _=this.rcpScaleX,x=this.rcpScaleY,C=4*(e-1),b=t.imageData.data,w=t.ctx.createImageData(i,r),S=w.data;for(u=0;u<r;u++)for(d=0;d<i;d++)for(c=Math.floor(_*d),l=Math.floor(x*u),g=_*d-c,f=x*u-l,v=4*(l*e+c),p=0;p<4;p++)n=b[v+p],o=b[v+4+p],a=b[v+C+p],h=b[v+C+4+p],m=n*(1-g)*(1-f)+o*g*(1-f)+a*f*(1-g)+h*g*f,S[y++]=m;return w}hermiteFastResize(t,e,s,i,r){const n=this.rcpScaleX,o=this.rcpScaleY,a=Math.ceil(n/2),h=Math.ceil(o/2),c=t.imageData.data,l=t.ctx.createImageData(i,r),u=l.data;for(let d=0;d<r;d++)for(let t=0;t<i;t++){const s=4*(t+d*i);let r=0,l=0,g=0,f=0,p=0,m=0,v=0;const y=(d+.5)*o;for(let i=Math.floor(d*o);i<(d+1)*o;i++){const s=Math.abs(y-(i+.5))/h,o=(t+.5)*n,u=s*s;for(let h=Math.floor(t*n);h<(t+1)*n;h++){let t=Math.abs(o-(h+.5))/a;const s=Math.sqrt(u+t*t);s>1&&s<-1||(r=2*s*s*s-3*s*s+1,r>0&&(t=4*(h+i*e),v+=r*c[t+3],g+=r,c[t+3]<255&&(r=r*c[t+3]/250),f+=r*c[t],p+=r*c[t+1],m+=r*c[t+2],l+=r))}}u[s]=f/l,u[s+1]=p/l,u[s+2]=m/l,u[s+3]=v/g}return l}}$(th,"type","Resize"),$(th,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),$(th,"uniformLocations",["uDelta","uTaps"]),Zt.setClass(th);class eh extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uSaturation;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float rgMax = max(color.r, color.g);\n    float rgbMax = max(rgMax, color.b);\n    color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n    color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n    color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.saturation;for(let i=0;i<e.length;i+=4){const t=e[i],r=e[i+1],n=e[i+2],o=Math.max(t,r,n);e[i]+=o!==t?(o-t)*s:0,e[i+1]+=o!==r?(o-r)*s:0,e[i+2]+=o!==n?(o-n)*s:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}$(eh,"type","Saturation"),$(eh,"defaults",{saturation:0}),$(eh,"uniformLocations",["uSaturation"]),Zt.setClass(eh);class sh extends Ma{getFragmentSource(){return"\n  precision highp float;\n  uniform sampler2D uTexture;\n  uniform float uVibrance;\n  varying vec2 vTexCoord;\n  void main() {\n    vec4 color = texture2D(uTexture, vTexCoord);\n    float max = max(color.r, max(color.g, color.b));\n    float avg = (color.r + color.g + color.b) / 3.0;\n    float amt = (abs(max - avg) * 2.0) * uVibrance;\n    color.r += max != color.r ? (max - color.r) * amt : 0.00;\n    color.g += max != color.g ? (max - color.g) * amt : 0.00;\n    color.b += max != color.b ? (max - color.b) * amt : 0.00;\n    gl_FragColor = color;\n  }\n"}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let i=0;i<e.length;
1i+=4){const t=e[i],r=e[i+1],n=e[i+2],o=Math.max(t,r,n),a=(t+r+n)/3,h=2*Math.abs(o-a)/255*s;e[i]+=o!==t?(o-t)*h:0,e[i+1]+=o!==r?(o-r)*h:0,e[i+2]+=o!==n?(o-n)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}$(sh,"type","Vibrance"),$(sh,"defaults",{vibrance:0}),$(sh,"uniformLocations",["uVibrance"]),Zt.setClass(sh);const ih={class:"canvas-actions"},rh=["onClick"],nh={style:{"line-height":"22px",color:"#23262f"}},oh=625,ah=22,hh=12,ch=b(s({__name:"CanvasEdit",props:{editableRegion:{},persistKey:{}},emits:["change"],setup(t,{expose:e,emit:s}){const{t:b}=X(),w=t;let S,T,O;const k=i(null),D=r({list:[],index:-1}),M=i(0),E=i(null);function j(){if(!S||!k.value)return void(E.value=null);const t=S.getObjects().filter(t=>{const e=t.data;return!e?.isBackgroundImage&&!e?.isEditableArea});if(0===t.length)return void(E.value=null);const{canvasLeft:e,canvasTop:s,canvasWidth:i,canvasHeight:r}=k.value,n=e+i,o=s+r;let a=1/0,h=1/0,c=-1/0,l=-1/0;for(const u of t){const t=u.getBoundingRect(),i=Math.max(t.left,e),r=Math.max(t.top,s),d=Math.min(t.left+t.width,n),g=Math.min(t.top+t.height,o);d>i&&g>r&&(a=Math.min(a,i),h=Math.min(h,r),c=Math.max(c,d),l=Math.max(l,g))}E.value=a<1/0?{width:c-a,height:l-h}:null}const P=i(!1);let A=!1,F=0;let L=null,I=null,R=null,B=null;function V(){return w.persistKey?`canvas-edit:${w.persistKey}`:null}function H(){const t=S.toDatalessJSON(["selectable","evented","visible","data"]);return Array.isArray(t.objects)&&(t.objects=t.objects.filter(t=>!t?.data?.isBackgroundImage&&!t?.data?.isEditableArea)),t}function z(){if(!S)return;const t=S.getObjects().filter(t=>{const e=t.data;return!e?.isBackgroundImage&&!e?.isEditableArea}).length;M.value=t}async function G(){try{const t=new URL(""+new URL("mosaic.BfDG-adi.png",import.meta.url).href,import.meta.url).href,e=await la.fromURL(t,{crossOrigin:"anonymous"});return new fo({source:e.getElement(),repeat:"repeat"})}catch(t){return console.error("Failed to load mosaic pattern:",t),null}}async function N(){const t=w.editableRegion;if(!t?.url)return;if(!(!!T&&S.getObjects().includes(T))){F++;try{const e=await la.fromURL(t.url,{crossOrigin:"anonymous"}),s=t.x/100*e.width,i=t.y/100*e.height,r=t.width/100*e.width,n=t.height/100*e.height,o=oh/Math.max(r,n),a=r*o,h=n*o,c=(oh-a)/2,l=(oh-h)/2,u=c-s*o,d=l-i*o;if(e.scale(o),e.set({left:u,top:d,selectable:!1,evented:!1,visible:!1,data:{isBackgroundImage:!0}}),T=e,k.value={canvasLeft:c,canvasTop:l,canvasWidth:a,canvasHeight:h,originalLeft:s,originalTop:i,originalWidth:r,originalHeight:n,scale:o},B||(B=await G()),O=new sn({left:c,top:l,width:a,height:h,fill:B||"#e1e4ee",selectable:!1,evented:!1,data:{isEditableArea:!0}}),S.add(O),S.add(e),S.sendObjectToBack(O),S.sendObjectToBack(e),S.renderAll(),z(),0===D.list.length){const t=JSON.stringify(H());D.list.push(t),D.index=0,U()}}catch(e){console.error("Failed to load background image:",e)}finally{F=Math.max(0,F-1)}}}function U(){try{const t=V();if(!t||!S)return;const e={history:D.list,index:D.index};localStorage.setItem(t,JSON.stringify(e))}catch(t){}}function q(){try{if(sessionStorage.getItem("new_remake"))return;const t=V();if(!t||!S)return;const e=localStorage.getItem(t);if(!e)return;const s=JSON.parse(e);let i,r;s.history&&Array.isArray(s.history)?(i=s.history,r=s.index??0):(i=[e],r=0);const n="string"==typeof i[r]?JSON.parse(i[r]):i[r];P.value=!0,S.loadFromJSON(n).then(()=>{const t=S.getObjects();for(const e of t){const t=e.data;t?.isBackgroundImage?(T=e,T.evented=!1,T.selectable=!1,T.visible=!1):t?.isEditableArea?(O=e,O.evented=!1,O.selectable=!1):Q(e)}N(),D.list.splice(0,D.list.length,...i),D.index=r,S.renderAll()}).finally(()=>{P.value=!1})}catch(t){}}function K(t,e="#0E81E6"){return function(s,i,r){s.save(),s.beginPath(),s.arc(i,r,11,0,2*Math.PI),s.fillStyle=e,s.fill(),s.translate(i,r),t(s),s.restore()}}const J=K(t=>{L&&t.drawImage(L,-6,-6,hh,hh)},"#0E81E6"),Z=K(t=>{I&&t.drawImage(I,-6,-6,hh,hh)},"#FF5858"),$=K(t=>{R&&t.drawImage(R,-6,-6,hh,hh)},"#0E81E6");function Q(t){if(t.set({hasBorders:!0,borderColor:"#2f80ed",borderScaleFactor:1,transparentCorners:!0}),k.value){const{canvasLeft:e,canvasTop:s,canvasWidth:i,canvasHeight:r}=k.value;t.clipPath=new sn({left:e,top:s,width:i,height:r,absolutePositioned:!0})}const e=new Bi({x:-.5,y:-.5,cursorStyle:"crosshair",sizeX:ah,sizeY:ah,withConnection:!0,render:(t,e,s)=>J(t,e,s),actionHandler:ba.rotationWithSnapping}),s=new Bi({x:.5,y:-.5,cursorStyle:"pointer",sizeX:ah,sizeY:ah,withConnection:!0,render:(t,e,s)=>Z(t,e,s),mouseUpHandler:(t,e)=>{const s=e.target;return s&&s.canvas?.remove(s),!0}}),i=new Bi({x:.5,y:.5,cursorStyle:"se-resize",sizeX:ah,sizeY:ah,withConnection:!0,render:(t,e,s)=>$(t,e,s),actionHandler:ba.scalingEqually,actionName:"scale"});t.controls={tl:e,tr:s,br:i}}const tt=n(()=>[{label:b("product.remake.revoke"),icon:"icon-fanhuishangyibu",enabled:D.index>0,onClick:()=>{D.index>0&&rt(D.index-1)}},{label:b("product.remake.recover"),icon:"icon-fanhuixiayibu",enabled:D.index<D.list.length-1,onClick:()=>{D.index<D.list.length-1&&rt(D.index+1)}},{label:b("product.remake.clear"),icon:"icon-quanbuqingchu",onClick:()=>{!function(){if(!S)return;P.value=!0;try{const t=S.getObjects().slice();for(const e of t){const t=e.data;
1t?.isBackgroundImage||t?.isEditableArea||S.remove(e)}S.requestRenderAll()}catch(t){console.error("clearCanvas error",t)}finally{P.value=!1,z(),it()}}()}}]),et=s,st=Y(async()=>{if(!A&&k.value&&T){A=!0,S.off("after:render",st),O&&S.sendObjectToBack(O),T&&S.sendObjectToBack(T);try{const{canvasLeft:t,canvasTop:e,canvasWidth:s,canvasHeight:i}=k.value,r=await S.toBlob({left:t,top:e,width:s,height:i,multiplier:1}),n=T.left,o=T.top,a=T.getScaledWidth(),h=T.getScaledHeight(),c=new Zn(null,{width:a,height:h,backgroundColor:"transparent"}),l=await T.clone(["data"]);l.set({left:0,top:0,visible:!0,selectable:!1,evented:!1}),c.add(l);const u=S.getObjects().filter(t=>{const e=t.data;return!e?.isBackgroundImage&&!e?.isEditableArea});for(const g of u){const r=await g.clone(["data"]);r.set({left:(r.left||0)-n,top:(r.top||0)-o}),r.clipPath=new sn({left:t-n,top:e-o,width:s,height:i,absolutePositioned:!0}),c.add(r)}c.renderAll();const d=await c.toBlob({multiplier:1});c.dispose(),et("change",[{name:"full.png",blob:d,url:URL.createObjectURL(d),width:a,height:h},{name:"remake.png",blob:r,url:URL.createObjectURL(r),width:s,height:i}])}catch(t){console.error("toBlob error",t)}finally{S.on("after:render",st),A=!1}}},100);function it(){if(P.value||F>0)return;D.index<D.list.length-1&&D.list.splice(D.index+1);const t=JSON.stringify(H());D.list.length>0&&D.list[D.index]===t||(D.list.push(t),D.list.length>20&&D.list.shift(),D.index=D.list.length-1,U())}function rt(t){if(t<0||t>=D.list.length)return;P.value=!0;const e=D.list[t],s="string"==typeof e?JSON.parse(e):e;S.loadFromJSON(s).then(()=>{const e=S.getObjects();for(const t of e){const e=t.data;e?.isBackgroundImage?(T=t,T.evented=!1,T.selectable=!1,T.visible=!1):e?.isEditableArea?(O=t,O.evented=!1,O.selectable=!1):Q(t)}N(),D.index=t,S.renderAll()}).catch(t=>{console.log("restoreState error",t)}).finally(()=>{P.value=!1})}function nt(t,e={},s){return new Promise((i,r)=>{if(!(e?.data?.isBackgroundImage||e?.data?.isEditableArea)&&!P.value&&M.value>=10)return r(y.error(b("product.remake.maxImages",{count:10})));la.fromURL(t,{crossOrigin:"anonymous"}).then(t=>{const r=s||Math.min(150/t.width,150/t.height);t.scale(s||r);const n=t.getScaledWidth(),o=t.getScaledHeight();let a=(oh-n)/2+15*M.value,h=(oh-o)/2+15*M.value;if(k.value){const{canvasLeft:t,canvasTop:e,canvasWidth:s,canvasHeight:i}=k.value;a=t+(s-n)/2+10*M.value,h=e+(i-o)/2+10*M.value}const c=e.x?e.x-n/2:a,l=e.y?e.y-o/2:h;t.set(Object.assign({left:c,top:l},e)),Q(t),S.add(t),O&&S.sendObjectToBack(O),T&&S.sendObjectToBack(T),i(t)}).catch(t=>{console.log(t),r(t)}).finally(()=>{S.renderAll()})})}function ot(t){try{const e=t.dataTransfer,s=e?.getData("application/x-seame-image-url")||e?.getData("text/plain");if(!s)return;const i=S.getViewportPoint(t);nt(s,{x:i.x,y:i.y})}catch(e){}}return o(async()=>{try{const t=new URL("data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%20427321965'%3e%3cpath%20id='Vector'%20d='M6.60279%200.751343C9.58902%200.751343%2012.0099%203.17194%2012.0099%206.15782C12.0099%209.1437%209.58902%2011.5643%206.60279%2011.5643C5.84028%2011.5652%205.08624%2011.4044%204.39042%2011.0926C3.69461%2010.7807%203.07282%2010.3249%202.56608%209.75523L3.29033%209.21218C3.71183%209.67026%204.22392%2010.0358%204.79414%2010.2856C5.36435%2010.5354%205.98025%2010.664%206.60279%2010.6632C9.09127%2010.6632%2011.1087%208.646%2011.1087%206.15782C11.1087%203.66964%209.09127%201.65242%206.60279%201.65242C4.11431%201.65242%202.09686%203.66964%202.09686%206.15782C2.09686%206.19417%202.09716%206.23051%202.09806%206.26685L1.19897%205.96439C1.30111%203.06802%203.68114%200.751343%206.60279%200.751343Z'%20fill='white'/%3e%3cpath%20id='Vector_2'%20d='M2.55613%204.84675C2.63013%204.75784%202.7355%204.70081%202.8504%204.68746C2.9653%204.67411%203.08093%204.70546%203.17335%204.77503C3.26577%204.84459%203.32789%204.94704%203.34685%205.06115C3.36581%205.17525%203.34015%205.29228%203.27519%205.388L3.24756%205.42464L2.02359%206.88859C1.98381%206.93619%201.93463%206.97505%201.87913%207.00276C1.82363%207.03046%201.763%207.0464%201.70105%207.04959C1.63911%207.05278%201.57717%207.04314%201.51912%207.02127C1.46107%206.99941%201.40816%206.9658%201.3637%206.92253L1.33216%206.88859L0.108498%205.42464C0.0344448%205.33603%20-0.00275767%205.22237%200.00457102%205.10713C0.0118997%204.99188%200.0632%204.88385%200.14788%204.80534C0.232561%204.72682%200.344156%204.68382%200.459625%204.68521C0.575095%204.6866%200.685622%204.73228%200.768389%204.81281L0.799626%204.84675L1.67788%205.89711L2.55613%204.84675Z'%20fill='white'/%3e%3c/g%3e%3c/svg%3e",import.meta.url).href,e=new URL("data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1760703756307'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5368'%20width='16'%20height='16'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M912.564706%20160.346353H106.556235a46.260706%2046.260706%200%201%200%200%2092.581647h58.24753a45.778824%2045.778824%200%200%200-0.843294%208.613647v600.726588c0%2072.643765%2058.970353%20131.614118%20131.614117%20131.614118h427.91153c72.643765%200%20133.300706-58.970353%20133.300706-131.614118V261.421176a45.959529%2045.959529%200%200%200-0.843295-8.613647h56.621177a46.260706%2046.260706%200%200%200%200.12047-92.461176zM764.385882%20261.421176v600.726589c0%2021.684706-19.275294%2039.092706-40.96%2039.092706H295.695059a39.092706%2039.092706%200%200%201-39.092706-39.092706V261.421176a45.778824%2045.778824%200%200%200-0.843294-8.613647h509.470117a44.574118%2044.574118%200%200%200-0.843294%208.613647z'%20p-id='5369'%20
1data-spm-anchor-id='a313x.manage_type_myprojects.0.i1.5f303a81AA6sk2'%20class=''%20fill='%23ffffff'%3e%3c/path%3e%3cpath%20d='M411.226353%20762.518588a46.260706%2046.260706%200%200%200%2046.260706-46.320941V453.571765a46.260706%2046.260706%200%201%200-92.581647%200v262.746353a46.320941%2046.320941%200%200%200%2046.320941%2046.20047z%20m196.487529%200a46.260706%2046.260706%200%200%200%2046.260706-46.320941V450.258824a46.260706%2046.260706%200%201%200-92.521412%200v265.938823a46.381176%2046.381176%200%200%200%2046.260706%2046.260706zM362.014118%20122.699294h307.501176c22.889412%200%2041.441882-20.660706%2041.441882-46.320941%200-25.479529-18.552471-46.260706-41.441882-46.260706H362.014118c-22.889412%200-41.441882%2020.660706-41.441883%2046.260706%200%2025.539765%2018.552471%2046.320941%2041.441883%2046.320941z'%20p-id='5370'%20data-spm-anchor-id='a313x.manage_type_myprojects.0.i4.5f303a81AA6sk2'%20class=''%20fill='%23ffffff'%3e%3c/path%3e%3c/svg%3e",import.meta.url).href,s=new URL("data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20id='Vector'%20d='M0.508594%200.868099C0.508594%200.855208%200.517187%200.842318%200.520052%200.829427C0.522917%200.816536%200.528646%200.797917%200.534375%200.783594C0.541632%200.768338%200.549761%200.753513%200.558723%200.739193C0.564066%200.727287%200.57029%200.715797%200.577344%200.704818C0.610343%200.653791%200.65379%200.610343%200.704817%200.577344C0.714843%200.570182%200.727735%200.564453%200.737761%200.558724L0.783593%200.528646C0.79886%200.52783%200.81416%200.52783%200.829427%200.528646L0.872396%200.508594C0.902136%200.502897%200.932348%200.500019%200.962629%200.5H3.70833C3.82989%200.5%203.94647%200.548289%204.03242%200.634243C4.11838%200.720197%204.16667%200.836776%204.16667%200.958333C4.16667%201.07989%204.11838%201.19647%204.03242%201.28242C3.94647%201.36838%203.82989%201.41667%203.70833%201.41667H2.06549L5.40703%204.75964C5.44964%204.80209%205.48346%204.85253%205.50653%204.90808C5.5296%204.96363%205.54148%205.02318%205.54148%205.08333C5.54148%205.14348%205.5296%205.20304%205.50653%205.25859C5.48346%205.31414%205.44964%205.36458%205.40703%205.40703C5.36458%205.44964%205.31414%205.48346%205.25859%205.50653C5.20304%205.5296%205.14348%205.54148%205.08333%205.54148C5.02318%205.54148%204.96363%205.529
16%204.90808%205.50653C4.85253%205.48346%204.80209%205.44964%204.75964%205.40703L1.41667%202.06549V3.70833C1.41667%203.82989%201.36838%203.94647%201.28242%204.03242C1.19647%204.11838%201.07989%204.16667%200.958333%204.16667C0.836775%204.16667%200.720196%204.11838%200.634242%204.03242C0.548288%203.94647%200.5%203.82989%200.5%203.70833V0.958333C0.500019%200.928052%200.502896%200.89784%200.508594%200.868099ZM7.24036%206.59297L10.5833%209.93451V8.29167C10.5833%208.17011%2010.6316%208.05353%2010.7176%207.96758C10.8035%207.88162%2010.9201%207.83333%2011.0417%207.83333C11.1632%207.83333%2011.2798%207.88162%2011.3658%207.96758C11.4517%208.05353%2011.5%208.17011%2011.5%208.29167V11.0417C11.5%2011.0719%2011.4971%2011.1022%2011.4914%2011.1319C11.4914%2011.1448%2011.4828%2011.1577%2011.4799%2011.1706C11.4771%2011.1835%2011.4714%2011.2021%2011.4656%2011.2164C11.4584%2011.2317%2011.4502%2011.2465%2011.4413%2011.2608C11.4359%2011.2727%2011.4297%2011.2842%2011.4227%2011.2952C11.39%2011.3465%2011.3465%2011.39%2011.2952%2011.4227C11.2842%2011.4297%2011.2727%2011.4359%2011.2608%2011.4413C11.2465%2011.4502%2011.2317%2011.4584%2011.2164%2011.4656L11.1706%2011.4799L11.1319%2011.4914C11.1022%2011.4971%2011.0719%2011.5%2011.0417%2011.5H8.29167C8.17011%2011.5%208.05353%2011.4517%207.96758%2011.3658C7.88162%2011.2798%207.83333%2011.1632%207.83333%2011.0417C7.83333%2010.9201%207.88162%2010.8035%207.96758%2010.7176C8.05353%2010.6316%208.17011%2010.5833%208.29167%2010.5833H9.93451L6.59297%207.24036C6.51397%207.15318%206.47153%207.03895%206.47442%206.92134C6.47732%206.80372%206.52533%206.69172%206.60853%206.60853C6.69172%206.52533%206.80372%206.47732%206.92133%206.47442C7.03895%206.47153%207.15318%206.51397%207.24036%206.59297Z'%20fill='white'/%3e%3c/svg%3e",import.meta.url).href;L=new Image,L.src=t,I=new Image,I.src=e,R=new Image,R.src=s}catch(t){}B=await G(),S=new Zn("canvas",{width:oh,height:oh,preserveObjectStacking:!0,backgroundColor:"#f5f5f5"}),S.on("object:modified",function(){it(),j()}),S.on("object:added",function(){z(),it(),j()}),S.on("object:removed",function(){z(),it(),j()}),S.on("object:moving",function(){j()}),S.on("object:scaling",function(){j()}),S.on("after:render",st),q(),N()}),a(()=>w.persistKey,(t,e)=>{t!==e&&(sessionStorage.getItem("new_remake")||q())}),a(()=>w.editableRegion,()=>{N()},{deep:!0}),h(()=>{if(U(),sessionStorage.getItem("new_remake"))try{sessionStorage.removeItem("new_remake")}catch(t){}}),e({addImage:nt,objectCount:M,materialBounds:E,editableRect:k}),(t,e)=>{const s=W;return l(),c(u,null,[d("div",ih,[(l(!0),c(u,null,f(p(tt),t=>(l(),c("div",{key:t.label,class:"canvas-action",onClick:t.onClick},[d("div",{class:_(["action-icon",{"action-disabled":!t.enabled}])},[x(s,{"icon-class":t.icon},null,8,["icon-class"])],2),d("span",nh,C(t.label),1)],8,rh))),128))]),g(t.$slots,"between",{},void 0,!0),d("div",{class:"canvas-box",style:v({width:oh+"px",height:oh+"px"}),onDragover:e[0]||(e[0]=m(t=>t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),["prevent"])),onDrop:m(ot,["prevent"])},[...e[1]||(e[1]=[d("canvas",{id:"canvas"},null,-1)])],36)],64)}}}),[["__scopeId","data-v-446f2e58"]]),lh={class:"remake-page"},uh={class:"remake-container"},dh={class:"remake-left"},gh={class:"remake-preview-container"},fh={class:"remake-title"},ph={class:"remake-desc"},mh={class:"remake-preview-wrapper"},vh={class:"remake-preview"},yh={class:"effect"},_h={class:"preview-image-wrapper"},xh=["src"],Ch={key:0,class:"custom-area-label"},bh={class:"remake-my"},wh={class:"upload-list"},Sh={class:"upload-item upload-trigger"},Th=["onClick"],Oh=["src","onDragstart"],kh={class:"upload-list"},Dh=["onClick"],Mh=["src","onDragstart"],Eh={class:"remake-right"},jh={class:"remake-tip"},Ph={key:0,class:"size-estimation"},Ah={class:"size-estimation-header"},Fh={class:"size-estimation-title"},Lh={class:"size-estimation-value"},Ih={class:"size-estimation-tip"},Rh=b(s({__name:"index",setup(s){const{t:h}=X(),{xyLogEvent:g}=O(),m=i("1"),_=w(),b=S(),W=_.params.spu,Y=_.query.sku,$=i(),Q=i([]),tt=i(),et=i(),st=i(),it=n(()=>$.value?.is_single_created?$.value?.second_creation:$.value?.skus?.find(t=>t.sku===Y)?.second_creation),rt=n(()=>
1{if(!it.value||!it.value.custom_area)return{url:"",x:0,y:0,width:0,height:0};const{custom_area:t}=it.value;return{url:it.value.tpl_img_url||"",x:t.x||0,y:t.y||0,width:t.width||0,height:t.height||0,physicalWidth:it.value.physical_width,physicalHeight:it.value.physical_height}}),nt=n(()=>!(!rt.value?.physicalWidth||!rt.value?.physicalHeight)),ot=n(()=>{const t=st.value?.materialBounds,e=st.value?.editableRect;if(!t||!e||!nt.value)return null;const s=rt.value.physicalWidth,i=rt.value.physicalHeight,r=Math.round(t.width/e.canvasWidth*s*10)/10,n=Math.round(t.height/e.canvasHeight*i*10)/10;return{width:r.toFixed(1),height:n.toFixed(1)}}),at=n(()=>ot.value?`${ot.value.width} cm x ${ot.value.height} cm`:"-- cm x -- cm"),ht=r({upload:!1,create:!1}),ct=V(F,{resource_types:[21]}),lt=V(L,{generation_method:4}),ut=n(()=>[{label:h("menu.marketplace"),path:"/"},{label:$.value?.name,path:_.path.replace("/remake","/details")},{label:tt.value?.name}]);async function dt(){if(g({event_name:"log_click_client",obj_info:{element_name:"create_product",product_type:P($.value?.product_type,2)}}),!st.value?.objectCount)return J.confirm({content:h("product.remake.noCreateTips"),centered:!0,onOk:()=>b.back(),onCancel:()=>{}});try{ht.create=!0;const s=et.value?.map(async t=>{const e=new File([t.blob],t.name,{type:t.blob.type});console.log(e);const{url:s}=await H(e,19);return console.log(s),{url:s,width:Math.round(t.width),height:Math.round(t.height)}}),i=await Promise.all(s),r=await(t={app_id:it.value?.relate_id,generated_images_info:i,sku:Y,spu:W,title:$.value?.second_creation?.relate_name,print_width:ot.value?parseFloat(ot.value.width):void 0,print_height:ot.value?parseFloat(ot.value.height):void 0},e({url:"/api/v1/model/work/create-plane-creation",method:"POST",data:t}));b.push({path:_.path.replace("/remake","/details"),query:{..._.query,remake_id:r.data.id}})}catch(s){if(console.error(s),105120===s?.code)return y.error(h("product.remake.appDeleted"));y.error(h("product.remake.createError"))}finally{ht.create=!1}var t}function gt(t,e){try{t.dataTransfer?.setData("text/plain",e),t.dataTransfer?.setData("application/x-seame-image-url",e),t.dataTransfer&&(t.dataTransfer.effectAllowed="copy")}catch(s){}}function ft(t){t.size>33554432?y.error(h("product.remake.uploadImageTooLarge")):(ht.upload=!0,H(t,21).then(({url:e})=>{ct.list.value.unshift({file_url:e,file_name:t.name,file_size:t.size,file_type:t.type})}).finally(()=>ht.upload=!1))}const pt=i(0);return T(t=>{const e=Date.now()-pt.value;g({event_name:"log_page_leave_client",obj_info:{page_view:e,next_page_name:A(t.name)}})}),o(()=>{pt.value=Date.now(),g({event_name:"log_page_expose_client",obj_info:{}}),e({url:"/api/v1/source/small/fallback-images",method:"GET"}).then(t=>{Q.value=t.data.images}),I({spu:W}).then(t=>{$.value=t.data}).catch(t=>{if(console.log("res",t),104011===t?.code)return y.error(h("product.details.notFound"))}),ct.load(),lt.load()}),a(it,()=>{it.value&&R({id:it.value?.relate_id}).then(t=>{tt.value=t.data}).catch(t=>{if(console.log("res",t),104038===t?.code)return y.error(h("product.details.notFound"))})}),(e,s)=>{const i=z,r=N,n=G,o=Z,a=t,g=U,y=q,_=K;return l(),c("div",lh,[x(B,{items:p(ut)},null,8,["items"]),d("div",uh,[d("div",dh,[d("div",gh,[d("h2",fh,C(p(tt)?.name)+C(p(h)("product.remake.intro")),1),d("p",ph,C(p(tt)?.description),1),d("div",mh,[d("div",vh,[d("div",yh,C(p(h)("product.remake.effect")),1),d("div",_h,[p(et)?.[0]?.url?(l(),c("img",{key:0,src:p(et)?.[0]?.url,alt:"canvasImage"},null,8,xh)):k("",!0),p(rt)?.width&&p(rt)?.height?(l(),c("div",{key:1,class:"editable-area-border",style:v({left:p(rt).x+"%",top:p(rt).y+"%",width:p(rt).width+"%",height:p(rt).height+"%"})},[p(nt)?(l(),c("div",Ch,C(p(rt).physicalWidth?.toFixed(1))+"cm x "+C(p(rt).physicalHeight?.toFixed(1))+"cm ",1)):k("",!0)],4)):k("",!0)])]),x(i,{class:"remake-complete",loading:p(ht).create,onClick:dt},{default:D(()=>[M(C(p(h)("product.remake.complete")),1)]),_:1},8,["loading"])])]),d("div",bh,[x(y,{"active-key":p(m),"onUpdate:activeKey":s[0]||(s[0]=t=>j(m)?m.value=t:null)},{default:D(()=>[x(g,{key:"1",tab:p(h)("product.remake.materials")},{default:D(()=>[x(a,{loading:p(ct).loading.value,empty:!1,onLoad:p(ct).load},{default:D(()=>[d("div",wh,[x(o,{"show-upload-list":!1,disabled:p(ht).upload,"before-upload":ft,accept:"image/*"},{default:D(()=>[x(n,{spinning:p(ht).upload},{default:D(()=>
1[d("div",Sh,[p(ht).upload?k("",!0):(l(),E(r,{key:0}))])]),_:1},8,["spinning"])]),_:1},8,["disabled"]),(l(!0),c(u,null,f(p(ct).list.value.map(t=>t.file_url).concat(p(Q)),t=>(l(),c("div",{key:t,class:"upload-item",onClick:e=>p(st)?.addImage(t)},[d("img",{src:t,draggable:"",alt:"",srcset:"",onDragstart:e=>gt(e,t)},null,40,Oh)],8,Th))),128))])]),_:1},8,["loading","onLoad"])]),_:1},8,["tab"]),x(g,{key:"2",tab:p(h)("product.remake.myWork")},{default:D(()=>[x(a,{loading:p(lt).loading.value,empty:p(lt).empty.value,"no-data":{height:"200px"},onLoad:p(lt).load},{default:D(()=>[d("div",kh,[(l(!0),c(u,null,f(p(lt).list.value,t=>(l(),c("div",{key:t.id,class:"upload-item",onClick:e=>p(st)?.addImage(t.generated_images_info[0].url)},[d("img",{src:t.generated_images_info[0].url,alt:"",srcset:"",onDragstart:e=>gt(e,t.generated_images_info[0].url)},null,40,Mh)],8,Dh))),128))])]),_:1},8,["loading","empty","onLoad"])]),_:1},8,["tab"])]),_:1},8,["active-key"])])]),x(_,{type:"vertical",class:"remake-divider"}),d("div",Eh,[d("div",jh,C(p(h)("product.remake.dragImagesTip")),1),x(ch,{ref_key:"refCanvasEdit",ref:st,"editable-region":p(rt),"persist-key":`${p(W)||""}_${p(Y)||""}_${p(it)?.relate_id||""}`,onChange:s[1]||(s[1]=t=>et.value=t)},{between:D(()=>[p(nt)?(l(),c("div",Ph,[d("div",Ah,[d("span",Fh,C(p(h)("product.remake.sizeEstimation"))+":",1),d("span",Lh,C(p(at)),1)]),d("p",Ih,C(p(h)("product.remake.sizeEstimationTip")),1)])):k("",!0)]),_:1},8,["editable-region","persist-key"])])])])}}}),[["__scopeId","data-v-d1bceb3f"]]);export{Rh as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.